thingsboard / thingsboard-client-sdk

Client SDK to connect with ThingsBoard IoT Platform from IoT devices (Arduino, Espressif, etc.)
MIT License
151 stars 120 forks source link

problems with OTA updater #215

Open radontec opened 1 month ago

radontec commented 1 month ago

I would like to use the OTA Espressif_Updater

include .

The #include brings problems with it.

The esp_ota_ops.h I have integrated.

include

include

include "esp_ota_ops.h"

include

However, I can see in the configuration.h that I have ESP_IDF_VERSION_MAJOR 3. What exactly does that mean?

# ifndef THINGSBOARD_USE_ESP_PARTITION ´# ifdef __has_include # if __has_include() && ESP_IDF_VERSION_MAJOR >= 4 ´# define THINGSBOARD_USE_ESP_PARTITION 1 ´# else ´# define THINGSBOARD_USE_ESP_PARTITION 0 ´# endif ´# else ´# define THINGSBOARD_USE_ESP_PARTITION 0 ´# endif ´# endif

that's why I get these errors:

src/main.cpp:5180:127: error: 'updater' was not declared in this scope const OTA_Update_Callback callback(&progressCallback, &updatedCallback, CURRENT_FIRMWARE_TITLE, CURRENT_FIRMWARE_VERSION, &updater, FIRMWARE_FAILURE_RETRIES, FIRMWARE_PACKET_SIZE); ^ src/main.cpp:5587:1: error: 'Espressif_Updater' does not name a type Espressif_Updater updater;

Is this possibly due to the version?

[platformio] src_dir = src data_dir = data

default_envs = ESP32-ser ;default_envs = ESP32-ota

[env:ESP32-ser] platform = espressif32

board = esp32dev framework = arduino

MathewHDYT commented 1 month ago

Previously I simply assumed that all components exist with ESP_IDF_MAJOR_VERSION 4 so v4.x.x. Therefore if you actually have the component but are not on that version you are not able to use that component with the library.

If fixed that in my fork already and now it really checks for the exact version that implements the used APIs like I need them. Meaning if you can use the component normally you can use it with the library.

Until my fork is finished and merged you can simply replace the below code with the # ifndef THINGSBOARD_USE_ESP_PARTITION in your Configuration.h file.

// Use the esp_ota_ops header internally for handling the writing of ota update data, as long as the header exists,
// to allow users that do have the needed component to use the Espressif_Updater instead of only the Arduino_ESP32_Updater.
// Only exists following major version 1 minor version 0 on ESP32 (https://github.com/espressif/esp-idf/releases/v0.9) and major version 3 minor version 0 on ESP8266 (https://github.com/espressif/ESP8266_RTOS_SDK/releases/tag/v3.0-rc1).
// Additionally, for all the expected API calls to be implemented atleast, major version 2 minor version 1 on ESP32 and major version 3 minor version 0 on ESP8266 is required.
#  ifndef THINGSBOARD_USE_ESP_PARTITION
#    ifdef __has_include
#      if __has_include(<esp_ota_ops.h>) && (!defined(ESP32) || ((ESP_IDF_VERSION_MAJOR == 2 && ESP_IDF_VERSION_MINOR >= 1) || ESP_IDF_VERSION_MAJOR > 2)) && (!defined(ESP8266) || ESP_IDF_VERSION_MAJOR >= 3)
#        define THINGSBOARD_USE_ESP_PARTITION 1
#      else
#        define THINGSBOARD_USE_ESP_PARTITION 0
#      endif
#    else
#      define THINGSBOARD_USE_ESP_PARTITION 0
#    endif
#  endif