Доброе утро. Я работаю над проектом ESP32 Arduino, и у меня возникают некоторые проблемы при работе OTA. Я видел, что есть специальная c библиотека, которую ESP выпустил для выполнения OTA, но компилятор отображает некоторые ошибки «переопределения» и другие мелочи, но самое главное, он говорит, что не может найти типы и переменные, которые должны быть определены в библиотека esp_https_ota.h, которую я уже включил.
Итак, моя библиотека должна выполнять 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;
}
Хотя библиотеку esp_https_ota можно найти по этой ссылке:
https://github.com/espressif/esp-idf/blob/master/components/esp_https_ota/include/esp_https_ota.h
Вывод компилятора следующий:
In file included from C:\Users\gd\Documents\Arduino\ma_epaper\ma_epaper.ino:61:0:
C:\Users\gd\Documents\Arduino\libraries\MA_Libs/MA_OTA.h: In function 'void MA_firmwareUpgrade()':
C:\Users\gd\Documents\Arduino\libraries\MA_Libs/MA_OTA.h:53:7: error: 'esp_https_ota_config_t' was not declared in this scope
esp_https_ota_config_t config;
^
C:\Users\gd\Documents\Arduino\libraries\MA_Libs/MA_OTA.h:54:7: error: 'config' was not declared in this scope
config.http_config.url = (char*) malloc(sizeof(char)*strlen(fop.all_vars.CERT_URL));
^
C:\Users\gd\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4/tools/sdk/include/nghttp/http_parser.h:95:6: error: redeclaration of 'HTTP_DELETE'
XX(0, DELETE, DELETE) \
^
C:\Users\gd\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4/tools/sdk/include/nghttp/http_parser.h:138:45: note: in definition of macro 'XX'
#define XX(num, name, string) HTTP_##name = num,
^
C:\Users\gd\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4/tools/sdk/include/nghttp/http_parser.h:139:3: note: in expansion of macro 'HTTP_METHOD_MAP'
HTTP_METHOD_MAP(XX)
^
In file included from C:\Users\gd\Documents\Arduino\ma_epaper\ma_epaper.ino:18:0:
C:\Program Files (x86)\Arduino\libraries\ESPAsyncWebServer\src/ESPAsyncWebServer.h:64:3: note: previous declaration 'WebRequestMethod HTTP_DELETE'
HTTP_DELETE = 0b00000100,
^
In file included from C:\Users\gd\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4/tools/sdk/include/esp_http_client/esp_http_client.h:19:0,
from C:\Users\gd\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4/tools/sdk/include/esp_https_ota/esp_https_ota.h:17,
from C:\Users\gd\Documents\Arduino\libraries\MA_Libs/MA_OTA.h:13,
from C:\Users\gd\Documents\Arduino\ma_epaper\ma_epaper.ino:61:
C:\Users\gd\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4/tools/sdk/include/nghttp/http_parser.h:96:6: error: redeclaration of 'HTTP_GET'
XX(1, GET, GET) \
^
C:\Users\gd\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4/tools/sdk/include/nghttp/http_parser.h:138:45: note: in definition of macro 'XX'
#define XX(num, name, string) HTTP_##name = num,
^
C:\Users\gd\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4/tools/sdk/include/nghttp/http_parser.h:139:3: note: in expansion of macro 'HTTP_METHOD_MAP'
HTTP_METHOD_MAP(XX)
^
In file included from C:\Users\gd\Documents\Arduino\ma_epaper\ma_epaper.ino:18:0:
C:\Program Files (x86)\Arduino\libraries\ESPAsyncWebServer\src/ESPAsyncWebServer.h:62:3: note: previous declaration 'WebRequestMethod HTTP_GET'
HTTP_GET = 0b00000001,
^
In file included from C:\Users\gd\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4/tools/sdk/include/esp_http_client/esp_http_client.h:19:0,
from C:\Users\gd\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4/tools/sdk/include/esp_https_ota/esp_https_ota.h:17,
from C:\Users\gd\Documents\Arduino\libraries\MA_Libs/MA_OTA.h:13,
from C:\Users\gd\Documents\Arduino\ma_epaper\ma_epaper.ino:61:
C:\Users\gd\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4/tools/sdk/include/nghttp/http_parser.h:97:6: error: redeclaration of 'HTTP_HEAD'
XX(2, HEAD, HEAD) \
^
C:\Users\gd\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4/tools/sdk/include/nghttp/http_parser.h:138:45: note: in definition of macro 'XX'
#define XX(num, name, string) HTTP_##name = num,
^
C:\Users\gd\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4/tools/sdk/include/nghttp/http_parser.h:139:3: note: in expansion of macro 'HTTP_METHOD_MAP'
HTTP_METHOD_MAP(XX)
^
In file included from C:\Users\gd\Documents\Arduino\ma_epaper\ma_epaper.ino:18:0:
C:\Program Files (x86)\Arduino\libraries\ESPAsyncWebServer\src/ESPAsyncWebServer.h:67:3: note: previous declaration 'WebRequestMethod HTTP_HEAD'
HTTP_HEAD = 0b00100000,
^
In file included from C:\Users\gd\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4/tools/sdk/include/esp_http_client/esp_http_client.h:19:0,
from C:\Users\gd\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4/tools/sdk/include/esp_https_ota/esp_https_ota.h:17,
from C:\Users\gd\Documents\Arduino\libraries\MA_Libs/MA_OTA.h:13,
from C:\Users\gd\Documents\Arduino\ma_epaper\ma_epaper.ino:61:
C:\Users\gd\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4/tools/sdk/include/nghttp/http_parser.h:98:6: error: redeclaration of 'HTTP_POST'
XX(3, POST, POST) \
^
C:\Users\gd\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4/tools/sdk/include/nghttp/http_parser.h:138:45: note: in definition of macro 'XX'
#define XX(num, name, string) HTTP_##name = num,
^
C:\Users\gd\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4/tools/sdk/include/nghttp/http_parser.h:139:3: note: in expansion of macro 'HTTP_METHOD_MAP'
HTTP_METHOD_MAP(XX)
^
In file included from C:\Users\gd\Documents\Arduino\ma_epaper\ma_epaper.ino:18:0:
C:\Program Files (x86)\Arduino\libraries\ESPAsyncWebServer\src/ESPAsyncWebServer.h:63:3: note: previous declaration 'WebRequestMethod HTTP_POST'
HTTP_POST = 0b00000010,
^
In file included from C:\Users\gd\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4/tools/sdk/include/esp_http_client/esp_http_client.h:19:0,
from C:\Users\gd\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4/tools/sdk/include/esp_https_ota/esp_https_ota.h:17,
from C:\Users\gd\Documents\Arduino\libraries\MA_Libs/MA_OTA.h:13,
from C:\Users\gd\Documents\Arduino\ma_epaper\ma_epaper.ino:61:
C:\Users\gd\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4/tools/sdk/include/nghttp/http_parser.h:99:6: error: redeclaration of 'HTTP_PUT'
XX(4, PUT, PUT) \
^
C:\Users\gd\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4/tools/sdk/include/nghttp/http_parser.h:138:45: note: in definition of macro 'XX'
#define XX(num, name, string) HTTP_##name = num,
^
C:\Users\gd\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4/tools/sdk/include/nghttp/http_parser.h:139:3: note: in expansion of macro 'HTTP_METHOD_MAP'
HTTP_METHOD_MAP(XX)
^
In file included from C:\Users\gd\Documents\Arduino\ma_epaper\ma_epaper.ino:18:0:
C:\Program Files (x86)\Arduino\libraries\ESPAsyncWebServer\src/ESPAsyncWebServer.h:65:3: note: previous declaration 'WebRequestMethod HTTP_PUT'
HTTP_PUT = 0b00001000,
^
In file included from C:\Users\gd\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4/tools/sdk/include/esp_http_client/esp_http_client.h:19:0,
from C:\Users\gd\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4/tools/sdk/include/esp_https_ota/esp_https_ota.h:17,
from C:\Users\gd\Documents\Arduino\libraries\MA_Libs/MA_OTA.h:13,
from C:\Users\gd\Documents\Arduino\ma_epaper\ma_epaper.ino:61:
C:\Users\gd\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4/tools/sdk/include/nghttp/http_parser.h:102:6: error: redeclaration of 'HTTP_OPTIONS'
XX(6, OPTIONS, OPTIONS) \
^
C:\Users\gd\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4/tools/sdk/include/nghttp/http_parser.h:138:45: note: in definition of macro 'XX'
#define XX(num, name, string) HTTP_##name = num,
^
C:\Users\gd\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4/tools/sdk/include/nghttp/http_parser.h:139:3: note: in expansion of macro 'HTTP_METHOD_MAP'
HTTP_METHOD_MAP(XX)
^
In file included from C:\Users\gd\Documents\Arduino\ma_epaper\ma_epaper.ino:18:0:
C:\Program Files (x86)\Arduino\libraries\ESPAsyncWebServer\src/ESPAsyncWebServer.h:68:3: note: previous declaration 'WebRequestMethod HTTP_OPTIONS'
HTTP_OPTIONS = 0b01000000,
^
In file included from C:\Users\gd\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4/tools/sdk/include/esp_http_client/esp_http_client.h:19:0,
from C:\Users\gd\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4/tools/sdk/include/esp_https_ota/esp_https_ota.h:17,
from C:\Users\gd\Documents\Arduino\libraries\MA_Libs/MA_OTA.h:13,
from C:\Users\gd\Documents\Arduino\ma_epaper\ma_epaper.ino:61:
C:\Users\gd\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4/tools/sdk/include/nghttp/http_parser.h:128:6: error: redeclaration of 'HTTP_PATCH'
XX(28, PATCH, PATCH) \
^
C:\Users\gd\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4/tools/sdk/include/nghttp/http_parser.h:138:45: note: in definition of macro 'XX'
#define XX(num, name, string) HTTP_##name = num,
^
C:\Users\gd\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4/tools/sdk/include/nghttp/http_parser.h:139:3: note: in expansion of macro 'HTTP_METHOD_MAP'
HTTP_METHOD_MAP(XX)
^
In file included from C:\Users\gd\Documents\Arduino\ma_epaper\ma_epaper.ino:18:0:
C:\Program Files (x86)\Arduino\libraries\ESPAsyncWebServer\src/ESPAsyncWebServer.h:66:3: note: previous declaration 'WebRequestMethod HTTP_PATCH'
HTTP_PATCH = 0b00010000,
^
Кроме того, учитывая эти ошибки "переопределения", я боюсь, что некоторые библиотеки, которые я использовал ранее в проекте, действительно используют из тех же функций esp_http_client ...
Любая помощь для решения этих ошибок будет принята с благодарностью ...