I've been toying around the idea of using AI to semi-automatically port code to newer SDK versions. It's usually not very practical with C/C++ due to the sheer amount of header files where everything is defined. But now that we got VisualGDB's symbol-level editing working, I decided to give it another try with ESP-IDF, and it worked rather well.
I took an older open-source MQTT demo that was made with ESP-IDF 4.1, and failed to build on v5.5 due to some minor API changes. It was mostly things like this:
Code: Select all
esp_mqtt_client_config_t mqtt_cfg = {
.uri = sysCfg.mqtt_host,
.port = sysCfg.mqtt_port,
.client_id = sysCfg.device_id,
.username = sysCfg.mqtt_user,
.password = sysCfg.mqtt_pass,
.disable_clean_session = !sysCfg.mqtt_cleansession,
.keepalive = sysCfg.mqtt_keepalive,
};
Code: Select all
esp_mqtt_client_config_t mqtt_cfg = {
.broker = {
.address = {
.uri = sysCfg.mqtt_host,
.port = sysCfg.mqtt_port,
}
},
.credentials = {
.client_id = sysCfg.device_id,
.username = sysCfg.mqtt_user,
.authentication = {.password = sysCfg.mqtt_pass},
},
.session = {
.disable_clean_session = !sysCfg.mqtt_cleansession,
.keepalive = sysCfg.mqtt_keepalive,
},
};
VisualGDB's magic is that it packs code, definitions, and error messages together. The AI model sees something like this:
Code: Select all
esp_mqtt_client_config_t mqtt_cfg = {
.uri = sysCfg.mqtt_host, <<<ERROR: invalid field 'uri'
.port = sysCfg.mqtt_port,
We made a step-by-step tutorial on the new technique here: https://visualgdb.com/tutorials/ai/esp32/upgrading/
We also just got the VisualGDB's Clang-based C/C++ logic running directly on Linux and MacOS, so it will be soon available as a stand-alone product for folks that don't use Windows.
Any feedback is welcome.