This commit is contained in:
J. Nick Koston 2025-06-30 12:09:07 -05:00
parent 088bea9ccd
commit 981177da23
No known key found for this signature in database
3 changed files with 39 additions and 1 deletions

View File

@ -13,13 +13,41 @@ using ota_base::OTAResponseTypes;
using ota_base::OTAState;
// Re-export specific enum values for backward compatibility
// (in case external components use ota::OTA_STARTED, etc.)
// OTAState values
static constexpr auto OTA_COMPLETED = ota_base::OTA_COMPLETED;
static constexpr auto OTA_STARTED = ota_base::OTA_STARTED;
static constexpr auto OTA_IN_PROGRESS = ota_base::OTA_IN_PROGRESS;
static constexpr auto OTA_ABORT = ota_base::OTA_ABORT;
static constexpr auto OTA_ERROR = ota_base::OTA_ERROR;
// OTAResponseTypes values
static constexpr auto OTA_RESPONSE_OK = ota_base::OTA_RESPONSE_OK;
static constexpr auto OTA_RESPONSE_REQUEST_AUTH = ota_base::OTA_RESPONSE_REQUEST_AUTH;
static constexpr auto OTA_RESPONSE_HEADER_OK = ota_base::OTA_RESPONSE_HEADER_OK;
static constexpr auto OTA_RESPONSE_AUTH_OK = ota_base::OTA_RESPONSE_AUTH_OK;
static constexpr auto OTA_RESPONSE_UPDATE_PREPARE_OK = ota_base::OTA_RESPONSE_UPDATE_PREPARE_OK;
static constexpr auto OTA_RESPONSE_BIN_MD5_OK = ota_base::OTA_RESPONSE_BIN_MD5_OK;
static constexpr auto OTA_RESPONSE_RECEIVE_OK = ota_base::OTA_RESPONSE_RECEIVE_OK;
static constexpr auto OTA_RESPONSE_UPDATE_END_OK = ota_base::OTA_RESPONSE_UPDATE_END_OK;
static constexpr auto OTA_RESPONSE_SUPPORTS_COMPRESSION = ota_base::OTA_RESPONSE_SUPPORTS_COMPRESSION;
static constexpr auto OTA_RESPONSE_CHUNK_OK = ota_base::OTA_RESPONSE_CHUNK_OK;
static constexpr auto OTA_RESPONSE_ERROR_MAGIC = ota_base::OTA_RESPONSE_ERROR_MAGIC;
static constexpr auto OTA_RESPONSE_ERROR_UPDATE_PREPARE = ota_base::OTA_RESPONSE_ERROR_UPDATE_PREPARE;
static constexpr auto OTA_RESPONSE_ERROR_AUTH_INVALID = ota_base::OTA_RESPONSE_ERROR_AUTH_INVALID;
static constexpr auto OTA_RESPONSE_ERROR_WRITING_FLASH = ota_base::OTA_RESPONSE_ERROR_WRITING_FLASH;
static constexpr auto OTA_RESPONSE_ERROR_UPDATE_END = ota_base::OTA_RESPONSE_ERROR_UPDATE_END;
static constexpr auto OTA_RESPONSE_ERROR_INVALID_BOOTSTRAPPING = ota_base::OTA_RESPONSE_ERROR_INVALID_BOOTSTRAPPING;
static constexpr auto OTA_RESPONSE_ERROR_WRONG_CURRENT_FLASH_CONFIG =
ota_base::OTA_RESPONSE_ERROR_WRONG_CURRENT_FLASH_CONFIG;
static constexpr auto OTA_RESPONSE_ERROR_WRONG_NEW_FLASH_CONFIG = ota_base::OTA_RESPONSE_ERROR_WRONG_NEW_FLASH_CONFIG;
static constexpr auto OTA_RESPONSE_ERROR_ESP8266_NOT_ENOUGH_SPACE =
ota_base::OTA_RESPONSE_ERROR_ESP8266_NOT_ENOUGH_SPACE;
static constexpr auto OTA_RESPONSE_ERROR_ESP32_NOT_ENOUGH_SPACE = ota_base::OTA_RESPONSE_ERROR_ESP32_NOT_ENOUGH_SPACE;
static constexpr auto OTA_RESPONSE_ERROR_NO_UPDATE_PARTITION = ota_base::OTA_RESPONSE_ERROR_NO_UPDATE_PARTITION;
static constexpr auto OTA_RESPONSE_ERROR_MD5_MISMATCH = ota_base::OTA_RESPONSE_ERROR_MD5_MISMATCH;
static constexpr auto OTA_RESPONSE_ERROR_RP2040_NOT_ENOUGH_SPACE = ota_base::OTA_RESPONSE_ERROR_RP2040_NOT_ENOUGH_SPACE;
static constexpr auto OTA_RESPONSE_ERROR_UNKNOWN = ota_base::OTA_RESPONSE_ERROR_UNKNOWN;
#ifdef USE_OTA_STATE_CALLBACK
using ota_base::OTAGlobalCallback;

View File

@ -91,6 +91,14 @@ class OTAGlobalCallback {
OTAGlobalCallback *get_global_ota_callback();
void register_ota_platform(OTAComponent *ota_caller);
// TODO: When web_server is updated to use ota_base, we need to add thread-safe
// callback execution. The web_server OTA runs in a separate task, so callbacks
// need to be deferred to the main loop task to avoid race conditions.
// This could be implemented using:
// - A queue of callback events that the main loop processes
// - Or using App.schedule() to defer callback execution to the main loop
// Example: App.schedule([=]() { state_callback_.call(state, progress, error); });
#endif
} // namespace ota_base

View File

@ -110,6 +110,8 @@ class WebServerBase : public Component {
void add_handler(AsyncWebHandler *handler);
// TODO: In future PR, update this to use ota_base instead of duplicating OTA code
// Important: OTA callbacks must be thread-safe as web server OTA runs in a separate task
void add_ota_handler();
void set_port(uint16_t port) { port_ = port; }