Good morning. I'm working on a ESP32 Arduino project and I'm running into some troubles while getting the OTA to work. I saw there's a specific library that ESP put out to do OTA, but the compiler is displaying some "redefinition" errors and other minor stuff, but most importantly it says it couldn't find types and variables that should be defined in the library esp_https_ota.h that I already included.
So this is my library that should execute the OTA:
#include "esp_ota_ops.h"
#include "esp_https_ota.h"
int compareFirmwares(int current, int next);
void MA_checkForOTA()
{
Serial.printf("\nChecking if OTA is needed...\n");
Serial.printf("Current firmware version: %s\nComparing firmwares...\n", fop.all_vars.FIRM_VERSION);
int cmp = compareFirmwares(fop.all_vars.FIRM_VERSION, fop.all_vars.NEXT_FIRM_VERSION);
switch (cmp)
{
case 0:
{
Serial.printf("Firmware versions are the same. OTA not needed.\n");
fop.operations.retcode = STATUS_FIRMWARE_UPDATE_UNNECESSARY;
break;
}
case 1:
{
Serial.printf("WARNING: FIRMWARE VERSION USED IS GREATER THAN REQUESTED.\n");
fop.operations.retcode = STATUS_FIRMWARE_UPDATE_UNNECESSARY;
break;
}
case 2:
{
Serial.printf("There's a new firmware version. Starting OTA...\n");
fop.operations.retcode = STATUS_FIRMWARE_UPDATE_NECESSARY;
fop.operations.opcode = WKF_EXEC_OTA;
break;
}
}
}
void MA_firmwareUpgrade()
{
if (fop.all_vars.UPGRADE_NEEDED == true)
{
esp_https_ota_config_t config;
config.http_config.url = (char*) malloc(sizeof(char)*strlen(fop.all_vars.CERT_URL));
strcpy(config.http_config.url, (const char*) fop.all_vars.FIRM_URL);
//strcpy(.cert_pem, (char*)server_cert_pem_start);
config.http_config.cert_pem = (char *) malloc(sizeof(char)*strlen(fop.all_vars.CERT_URL));
strcpy(config.http_config.cert_pem, (const char*) fop.all_vars.CERT_URL);
esp_err_t ret = esp_https_ota(&config);
if (ret == ESP_OK)
{
fop.operations.retcode = STATUS_FIRMWARE_UPDATE_OK;
fop.operations.opcode = PROC_HARD_REBOOT;
}
else
{
fop.operations.retcode = STATUS_FIRMWARE_UPDATE_FAIL;
fop.operations.opcode = WKF_DSPLY_IMAGE;
}
}
else
{
Serial.printf("\nWARNING. OTA ABORTED BY VENDOR. UPGRADE NOT NEEDED AT THIS TIME.\n");
fop.operations.retcode = STATUS_FIRMWARE_UPDATE_UNNECESSARY;
fop.operations.opcode = WKF_DSPLY_IMAGE;
}
}
int compareFirmwares(int current, int next)
{
if (current > next)
return 1;
if (next > current)
return 2;
if (current == next)
return 0;
}
While the library esp_https_ota could be found at this link:
The output of the compiler is attached as a .txt file to this message.
Also, given those "redefinition" errors, I'm afraid some libraries I used prior in the project do make use of the same functions of esp_http_client...
Any help to solve those errors would be greatly appreciated...
console_debug.txt (9.8 KB)