From 9f51546023cbce8f581bbd80cf0ea6e42bc267e8 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 30 Jun 2025 10:33:43 -0500 Subject: [PATCH] Extract OTA backend functionality into separate ota_base component --- .../esp32_ble_tracker/esp32_ble_tracker.cpp | 2 +- .../components/esphome/ota/ota_esphome.cpp | 15 +++--- esphome/components/esphome/ota/ota_esphome.h | 2 +- .../http_request/ota/ota_http_request.cpp | 13 ++--- .../http_request/ota/ota_http_request.h | 2 +- .../micro_wake_word/micro_wake_word.cpp | 2 +- esphome/components/ota/__init__.py | 10 +--- esphome/components/ota/automation.h | 2 +- .../ota/{ota_backend.cpp => ota.cpp} | 2 +- esphome/components/ota/ota.h | 52 +++++++++++++++++++ esphome/components/ota_base/__init__.py | 16 ++++++ esphome/components/ota_base/ota_backend.cpp | 9 ++++ .../{ota => ota_base}/ota_backend.h | 44 ++-------------- .../ota_backend_arduino_esp32.cpp | 6 +-- .../ota_backend_arduino_esp32.h | 4 +- .../ota_backend_arduino_esp8266.cpp | 6 +-- .../ota_backend_arduino_esp8266.h | 4 +- .../ota_backend_arduino_libretiny.cpp | 6 +-- .../ota_backend_arduino_libretiny.h | 4 +- .../ota_backend_arduino_rp2040.cpp | 6 +-- .../ota_backend_arduino_rp2040.h | 4 +- .../{ota => ota_base}/ota_backend_esp_idf.cpp | 6 +-- .../{ota => ota_base}/ota_backend_esp_idf.h | 4 +- .../media_player/speaker_media_player.cpp | 2 +- 24 files changed, 130 insertions(+), 93 deletions(-) rename esphome/components/ota/{ota_backend.cpp => ota.cpp} (95%) create mode 100644 esphome/components/ota/ota.h create mode 100644 esphome/components/ota_base/__init__.py create mode 100644 esphome/components/ota_base/ota_backend.cpp rename esphome/components/{ota => ota_base}/ota_backend.h (56%) rename esphome/components/{ota => ota_base}/ota_backend_arduino_esp32.cpp (90%) rename esphome/components/{ota => ota_base}/ota_backend_arduino_esp32.h (92%) rename esphome/components/{ota => ota_base}/ota_backend_arduino_esp8266.cpp (92%) rename esphome/components/{ota => ota_base}/ota_backend_arduino_esp8266.h (93%) rename esphome/components/{ota => ota_base}/ota_backend_arduino_libretiny.cpp (90%) rename esphome/components/{ota => ota_base}/ota_backend_arduino_libretiny.h (91%) rename esphome/components/{ota => ota_base}/ota_backend_arduino_rp2040.cpp (92%) rename esphome/components/{ota => ota_base}/ota_backend_arduino_rp2040.h (92%) rename esphome/components/{ota => ota_base}/ota_backend_esp_idf.cpp (95%) rename esphome/components/{ota => ota_base}/ota_backend_esp_idf.h (93%) diff --git a/esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp b/esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp index d950ccb5f1..290b2ead08 100644 --- a/esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp +++ b/esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp @@ -18,7 +18,7 @@ #include #ifdef USE_OTA -#include "esphome/components/ota/ota_backend.h" +#include "esphome/components/ota/ota.h" #endif #ifdef USE_ESP32_BLE_SOFTWARE_COEXISTENCE diff --git a/esphome/components/esphome/ota/ota_esphome.cpp b/esphome/components/esphome/ota/ota_esphome.cpp index 4cc82b9094..5c662bbcfc 100644 --- a/esphome/components/esphome/ota/ota_esphome.cpp +++ b/esphome/components/esphome/ota/ota_esphome.cpp @@ -2,12 +2,13 @@ #ifdef USE_OTA #include "esphome/components/md5/md5.h" #include "esphome/components/network/util.h" -#include "esphome/components/ota/ota_backend.h" -#include "esphome/components/ota/ota_backend_arduino_esp32.h" -#include "esphome/components/ota/ota_backend_arduino_esp8266.h" -#include "esphome/components/ota/ota_backend_arduino_libretiny.h" -#include "esphome/components/ota/ota_backend_arduino_rp2040.h" -#include "esphome/components/ota/ota_backend_esp_idf.h" +#include "esphome/components/ota/ota.h" // For OTAComponent and callbacks +#include "esphome/components/ota_base/ota_backend.h" // For OTABackend class +#include "esphome/components/ota_base/ota_backend_arduino_esp32.h" +#include "esphome/components/ota_base/ota_backend_arduino_esp8266.h" +#include "esphome/components/ota_base/ota_backend_arduino_libretiny.h" +#include "esphome/components/ota_base/ota_backend_arduino_rp2040.h" +#include "esphome/components/ota_base/ota_backend_esp_idf.h" #include "esphome/core/application.h" #include "esphome/core/hal.h" #include "esphome/core/log.h" @@ -149,7 +150,7 @@ void ESPHomeOTAComponent::handle_() { buf[1] = USE_OTA_VERSION; this->writeall_(buf, 2); - backend = ota::make_ota_backend(); + backend = ota_base::make_ota_backend(); // Read features - 1 byte if (!this->readall_(buf, 1)) { diff --git a/esphome/components/esphome/ota/ota_esphome.h b/esphome/components/esphome/ota/ota_esphome.h index e0d09ff37e..ce5f2a59b9 100644 --- a/esphome/components/esphome/ota/ota_esphome.h +++ b/esphome/components/esphome/ota/ota_esphome.h @@ -4,7 +4,7 @@ #ifdef USE_OTA #include "esphome/core/helpers.h" #include "esphome/core/preferences.h" -#include "esphome/components/ota/ota_backend.h" +#include "esphome/components/ota/ota.h" #include "esphome/components/socket/socket.h" namespace esphome { diff --git a/esphome/components/http_request/ota/ota_http_request.cpp b/esphome/components/http_request/ota/ota_http_request.cpp index 4d9e868c74..ce7c5a6b88 100644 --- a/esphome/components/http_request/ota/ota_http_request.cpp +++ b/esphome/components/http_request/ota/ota_http_request.cpp @@ -6,11 +6,12 @@ #include "esphome/components/md5/md5.h" #include "esphome/components/watchdog/watchdog.h" -#include "esphome/components/ota/ota_backend.h" -#include "esphome/components/ota/ota_backend_arduino_esp32.h" -#include "esphome/components/ota/ota_backend_arduino_esp8266.h" -#include "esphome/components/ota/ota_backend_arduino_rp2040.h" -#include "esphome/components/ota/ota_backend_esp_idf.h" +#include "esphome/components/ota/ota.h" // For OTAComponent and callbacks +#include "esphome/components/ota_base/ota_backend.h" // For OTABackend class +#include "esphome/components/ota_base/ota_backend_arduino_esp32.h" +#include "esphome/components/ota_base/ota_backend_arduino_esp8266.h" +#include "esphome/components/ota_base/ota_backend_arduino_rp2040.h" +#include "esphome/components/ota_base/ota_backend_esp_idf.h" namespace esphome { namespace http_request { @@ -115,7 +116,7 @@ uint8_t OtaHttpRequestComponent::do_ota_() { ESP_LOGV(TAG, "MD5Digest initialized"); ESP_LOGV(TAG, "OTA backend begin"); - auto backend = ota::make_ota_backend(); + auto backend = ota_base::make_ota_backend(); auto error_code = backend->begin(container->content_length); if (error_code != ota::OTA_RESPONSE_OK) { ESP_LOGW(TAG, "backend->begin error: %d", error_code); diff --git a/esphome/components/http_request/ota/ota_http_request.h b/esphome/components/http_request/ota/ota_http_request.h index 6a86b4ab43..20a7abba71 100644 --- a/esphome/components/http_request/ota/ota_http_request.h +++ b/esphome/components/http_request/ota/ota_http_request.h @@ -1,6 +1,6 @@ #pragma once -#include "esphome/components/ota/ota_backend.h" +#include "esphome/components/ota/ota.h" #include "esphome/core/component.h" #include "esphome/core/defines.h" #include "esphome/core/helpers.h" diff --git a/esphome/components/micro_wake_word/micro_wake_word.cpp b/esphome/components/micro_wake_word/micro_wake_word.cpp index 201d956a37..5b5d92aa59 100644 --- a/esphome/components/micro_wake_word/micro_wake_word.cpp +++ b/esphome/components/micro_wake_word/micro_wake_word.cpp @@ -9,7 +9,7 @@ #include "esphome/components/audio/audio_transfer_buffer.h" #ifdef USE_OTA -#include "esphome/components/ota/ota_backend.h" +#include "esphome/components/ota/ota.h" #endif namespace esphome { diff --git a/esphome/components/ota/__init__.py b/esphome/components/ota/__init__.py index 627c55e910..e990256969 100644 --- a/esphome/components/ota/__init__.py +++ b/esphome/components/ota/__init__.py @@ -8,10 +8,10 @@ from esphome.const import ( CONF_PLATFORM, CONF_TRIGGER_ID, ) -from esphome.core import CORE, coroutine_with_priority +from esphome.core import coroutine_with_priority CODEOWNERS = ["@esphome/core"] -AUTO_LOAD = ["md5", "safe_mode"] +AUTO_LOAD = ["safe_mode", "ota_base"] IS_PLATFORM_COMPONENT = True @@ -84,12 +84,6 @@ BASE_OTA_SCHEMA = cv.Schema( async def to_code(config): cg.add_define("USE_OTA") - if CORE.is_esp32 and CORE.using_arduino: - cg.add_library("Update", None) - - if CORE.is_rp2040 and CORE.using_arduino: - cg.add_library("Updater", None) - async def ota_to_code(var, config): await cg.past_safe_mode() diff --git a/esphome/components/ota/automation.h b/esphome/components/ota/automation.h index 7e1a60f3ce..c3ff8e33d7 100644 --- a/esphome/components/ota/automation.h +++ b/esphome/components/ota/automation.h @@ -1,6 +1,6 @@ #pragma once #ifdef USE_OTA_STATE_CALLBACK -#include "ota_backend.h" +#include "ota.h" #include "esphome/core/automation.h" diff --git a/esphome/components/ota/ota_backend.cpp b/esphome/components/ota/ota.cpp similarity index 95% rename from esphome/components/ota/ota_backend.cpp rename to esphome/components/ota/ota.cpp index 30de4ec4b3..a98170ab1d 100644 --- a/esphome/components/ota/ota_backend.cpp +++ b/esphome/components/ota/ota.cpp @@ -1,4 +1,4 @@ -#include "ota_backend.h" +#include "ota.h" namespace esphome { namespace ota { diff --git a/esphome/components/ota/ota.h b/esphome/components/ota/ota.h new file mode 100644 index 0000000000..99bb3a61f8 --- /dev/null +++ b/esphome/components/ota/ota.h @@ -0,0 +1,52 @@ +#pragma once + +#include "esphome/core/component.h" +#include "esphome/core/defines.h" +#include "esphome/components/ota_base/ota_backend.h" + +#ifdef USE_OTA_STATE_CALLBACK +#include "esphome/core/automation.h" +#endif + +namespace esphome { +namespace ota { + +// Import types from ota_base namespace for backward compatibility +using ota_base::OTABackend; +using ota_base::OTAResponseTypes; +using ota_base::OTAState; + +class OTAComponent : public Component { +#ifdef USE_OTA_STATE_CALLBACK + public: + void add_on_state_callback(std::function &&callback) { + this->state_callback_.add(std::move(callback)); + } + + protected: + CallbackManager state_callback_{}; +#endif +}; + +#ifdef USE_OTA_STATE_CALLBACK +class OTAGlobalCallback { + public: + void register_ota(OTAComponent *ota_caller) { + ota_caller->add_on_state_callback([this, ota_caller](ota_base::OTAState state, float progress, uint8_t error) { + this->state_callback_.call(state, progress, error, ota_caller); + }); + } + void add_on_state_callback(std::function &&callback) { + this->state_callback_.add(std::move(callback)); + } + + protected: + CallbackManager state_callback_{}; +}; + +OTAGlobalCallback *get_global_ota_callback(); +void register_ota_platform(OTAComponent *ota_caller); +#endif + +} // namespace ota +} // namespace esphome \ No newline at end of file diff --git a/esphome/components/ota_base/__init__.py b/esphome/components/ota_base/__init__.py new file mode 100644 index 0000000000..1a562b3d2f --- /dev/null +++ b/esphome/components/ota_base/__init__.py @@ -0,0 +1,16 @@ +import esphome.codegen as cg +from esphome.core import CORE, coroutine_with_priority + +CODEOWNERS = ["@esphome/core"] +AUTO_LOAD = ["md5"] + +ota_base_ns = cg.esphome_ns.namespace("ota_base") + + +@coroutine_with_priority(52.0) +async def to_code(config): + if CORE.is_esp32 and CORE.using_arduino: + cg.add_library("Update", None) + + if CORE.is_rp2040 and CORE.using_arduino: + cg.add_library("Updater", None) diff --git a/esphome/components/ota_base/ota_backend.cpp b/esphome/components/ota_base/ota_backend.cpp new file mode 100644 index 0000000000..d43974e37f --- /dev/null +++ b/esphome/components/ota_base/ota_backend.cpp @@ -0,0 +1,9 @@ +#include "ota_backend.h" + +namespace esphome { +namespace ota_base { + +// The make_ota_backend() implementation is provided by each platform-specific backend + +} // namespace ota_base +} // namespace esphome \ No newline at end of file diff --git a/esphome/components/ota/ota_backend.h b/esphome/components/ota_base/ota_backend.h similarity index 56% rename from esphome/components/ota/ota_backend.h rename to esphome/components/ota_base/ota_backend.h index bc8ab46643..3112245c88 100644 --- a/esphome/components/ota/ota_backend.h +++ b/esphome/components/ota_base/ota_backend.h @@ -1,15 +1,10 @@ #pragma once -#include "esphome/core/component.h" #include "esphome/core/defines.h" #include "esphome/core/helpers.h" -#ifdef USE_OTA_STATE_CALLBACK -#include "esphome/core/automation.h" -#endif - namespace esphome { -namespace ota { +namespace ota_base { enum OTAResponseTypes { OTA_RESPONSE_OK = 0x00, @@ -59,38 +54,7 @@ class OTABackend { virtual bool supports_compression() = 0; }; -class OTAComponent : public Component { -#ifdef USE_OTA_STATE_CALLBACK - public: - void add_on_state_callback(std::function &&callback) { - this->state_callback_.add(std::move(callback)); - } +std::unique_ptr make_ota_backend(); - protected: - CallbackManager state_callback_{}; -#endif -}; - -#ifdef USE_OTA_STATE_CALLBACK -class OTAGlobalCallback { - public: - void register_ota(OTAComponent *ota_caller) { - ota_caller->add_on_state_callback([this, ota_caller](OTAState state, float progress, uint8_t error) { - this->state_callback_.call(state, progress, error, ota_caller); - }); - } - void add_on_state_callback(std::function &&callback) { - this->state_callback_.add(std::move(callback)); - } - - protected: - CallbackManager state_callback_{}; -}; - -OTAGlobalCallback *get_global_ota_callback(); -void register_ota_platform(OTAComponent *ota_caller); -#endif -std::unique_ptr make_ota_backend(); - -} // namespace ota -} // namespace esphome +} // namespace ota_base +} // namespace esphome \ No newline at end of file diff --git a/esphome/components/ota/ota_backend_arduino_esp32.cpp b/esphome/components/ota_base/ota_backend_arduino_esp32.cpp similarity index 90% rename from esphome/components/ota/ota_backend_arduino_esp32.cpp rename to esphome/components/ota_base/ota_backend_arduino_esp32.cpp index 15dfc98a6c..34ba3ae6ff 100644 --- a/esphome/components/ota/ota_backend_arduino_esp32.cpp +++ b/esphome/components/ota_base/ota_backend_arduino_esp32.cpp @@ -8,11 +8,11 @@ #include namespace esphome { -namespace ota { +namespace ota_base { static const char *const TAG = "ota.arduino_esp32"; -std::unique_ptr make_ota_backend() { return make_unique(); } +std::unique_ptr make_ota_backend() { return make_unique(); } OTAResponseTypes ArduinoESP32OTABackend::begin(size_t image_size) { bool ret = Update.begin(image_size, U_FLASH); @@ -56,7 +56,7 @@ OTAResponseTypes ArduinoESP32OTABackend::end() { void ArduinoESP32OTABackend::abort() { Update.abort(); } -} // namespace ota +} // namespace ota_base } // namespace esphome #endif // USE_ESP32_FRAMEWORK_ARDUINO diff --git a/esphome/components/ota/ota_backend_arduino_esp32.h b/esphome/components/ota_base/ota_backend_arduino_esp32.h similarity index 92% rename from esphome/components/ota/ota_backend_arduino_esp32.h rename to esphome/components/ota_base/ota_backend_arduino_esp32.h index ac7fe9f14f..6fb9454c64 100644 --- a/esphome/components/ota/ota_backend_arduino_esp32.h +++ b/esphome/components/ota_base/ota_backend_arduino_esp32.h @@ -6,7 +6,7 @@ #include "esphome/core/helpers.h" namespace esphome { -namespace ota { +namespace ota_base { class ArduinoESP32OTABackend : public OTABackend { public: @@ -18,7 +18,7 @@ class ArduinoESP32OTABackend : public OTABackend { bool supports_compression() override { return false; } }; -} // namespace ota +} // namespace ota_base } // namespace esphome #endif // USE_ESP32_FRAMEWORK_ARDUINO diff --git a/esphome/components/ota/ota_backend_arduino_esp8266.cpp b/esphome/components/ota_base/ota_backend_arduino_esp8266.cpp similarity index 92% rename from esphome/components/ota/ota_backend_arduino_esp8266.cpp rename to esphome/components/ota_base/ota_backend_arduino_esp8266.cpp index 42edbf5d2b..38d0ad96c3 100644 --- a/esphome/components/ota/ota_backend_arduino_esp8266.cpp +++ b/esphome/components/ota_base/ota_backend_arduino_esp8266.cpp @@ -10,11 +10,11 @@ #include namespace esphome { -namespace ota { +namespace ota_base { static const char *const TAG = "ota.arduino_esp8266"; -std::unique_ptr make_ota_backend() { return make_unique(); } +std::unique_ptr make_ota_backend() { return make_unique(); } OTAResponseTypes ArduinoESP8266OTABackend::begin(size_t image_size) { bool ret = Update.begin(image_size, U_FLASH); @@ -68,7 +68,7 @@ void ArduinoESP8266OTABackend::abort() { esp8266::preferences_prevent_write(false); } -} // namespace ota +} // namespace ota_base } // namespace esphome #endif diff --git a/esphome/components/ota/ota_backend_arduino_esp8266.h b/esphome/components/ota_base/ota_backend_arduino_esp8266.h similarity index 93% rename from esphome/components/ota/ota_backend_arduino_esp8266.h rename to esphome/components/ota_base/ota_backend_arduino_esp8266.h index 7f44d7c965..3f9982a514 100644 --- a/esphome/components/ota/ota_backend_arduino_esp8266.h +++ b/esphome/components/ota_base/ota_backend_arduino_esp8266.h @@ -7,7 +7,7 @@ #include "esphome/core/macros.h" namespace esphome { -namespace ota { +namespace ota_base { class ArduinoESP8266OTABackend : public OTABackend { public: @@ -23,7 +23,7 @@ class ArduinoESP8266OTABackend : public OTABackend { #endif }; -} // namespace ota +} // namespace ota_base } // namespace esphome #endif diff --git a/esphome/components/ota/ota_backend_arduino_libretiny.cpp b/esphome/components/ota_base/ota_backend_arduino_libretiny.cpp similarity index 90% rename from esphome/components/ota/ota_backend_arduino_libretiny.cpp rename to esphome/components/ota_base/ota_backend_arduino_libretiny.cpp index 6b2cf80684..12d4b677a3 100644 --- a/esphome/components/ota/ota_backend_arduino_libretiny.cpp +++ b/esphome/components/ota_base/ota_backend_arduino_libretiny.cpp @@ -8,11 +8,11 @@ #include namespace esphome { -namespace ota { +namespace ota_base { static const char *const TAG = "ota.arduino_libretiny"; -std::unique_ptr make_ota_backend() { return make_unique(); } +std::unique_ptr make_ota_backend() { return make_unique(); } OTAResponseTypes ArduinoLibreTinyOTABackend::begin(size_t image_size) { bool ret = Update.begin(image_size, U_FLASH); @@ -56,7 +56,7 @@ OTAResponseTypes ArduinoLibreTinyOTABackend::end() { void ArduinoLibreTinyOTABackend::abort() { Update.abort(); } -} // namespace ota +} // namespace ota_base } // namespace esphome #endif // USE_LIBRETINY diff --git a/esphome/components/ota/ota_backend_arduino_libretiny.h b/esphome/components/ota_base/ota_backend_arduino_libretiny.h similarity index 91% rename from esphome/components/ota/ota_backend_arduino_libretiny.h rename to esphome/components/ota_base/ota_backend_arduino_libretiny.h index 11deb6e2f2..b1cf1df738 100644 --- a/esphome/components/ota/ota_backend_arduino_libretiny.h +++ b/esphome/components/ota_base/ota_backend_arduino_libretiny.h @@ -5,7 +5,7 @@ #include "esphome/core/defines.h" namespace esphome { -namespace ota { +namespace ota_base { class ArduinoLibreTinyOTABackend : public OTABackend { public: @@ -17,7 +17,7 @@ class ArduinoLibreTinyOTABackend : public OTABackend { bool supports_compression() override { return false; } }; -} // namespace ota +} // namespace ota_base } // namespace esphome #endif // USE_LIBRETINY diff --git a/esphome/components/ota/ota_backend_arduino_rp2040.cpp b/esphome/components/ota_base/ota_backend_arduino_rp2040.cpp similarity index 92% rename from esphome/components/ota/ota_backend_arduino_rp2040.cpp rename to esphome/components/ota_base/ota_backend_arduino_rp2040.cpp index ffeab2e93f..7276381919 100644 --- a/esphome/components/ota/ota_backend_arduino_rp2040.cpp +++ b/esphome/components/ota_base/ota_backend_arduino_rp2040.cpp @@ -10,11 +10,11 @@ #include namespace esphome { -namespace ota { +namespace ota_base { static const char *const TAG = "ota.arduino_rp2040"; -std::unique_ptr make_ota_backend() { return make_unique(); } +std::unique_ptr make_ota_backend() { return make_unique(); } OTAResponseTypes ArduinoRP2040OTABackend::begin(size_t image_size) { bool ret = Update.begin(image_size, U_FLASH); @@ -68,7 +68,7 @@ void ArduinoRP2040OTABackend::abort() { rp2040::preferences_prevent_write(false); } -} // namespace ota +} // namespace ota_base } // namespace esphome #endif // USE_RP2040 diff --git a/esphome/components/ota/ota_backend_arduino_rp2040.h b/esphome/components/ota_base/ota_backend_arduino_rp2040.h similarity index 92% rename from esphome/components/ota/ota_backend_arduino_rp2040.h rename to esphome/components/ota_base/ota_backend_arduino_rp2040.h index b189964ab3..fb6e90bb53 100644 --- a/esphome/components/ota/ota_backend_arduino_rp2040.h +++ b/esphome/components/ota_base/ota_backend_arduino_rp2040.h @@ -7,7 +7,7 @@ #include "esphome/core/macros.h" namespace esphome { -namespace ota { +namespace ota_base { class ArduinoRP2040OTABackend : public OTABackend { public: @@ -19,7 +19,7 @@ class ArduinoRP2040OTABackend : public OTABackend { bool supports_compression() override { return false; } }; -} // namespace ota +} // namespace ota_base } // namespace esphome #endif // USE_RP2040 diff --git a/esphome/components/ota/ota_backend_esp_idf.cpp b/esphome/components/ota_base/ota_backend_esp_idf.cpp similarity index 95% rename from esphome/components/ota/ota_backend_esp_idf.cpp rename to esphome/components/ota_base/ota_backend_esp_idf.cpp index 6f45fb75e4..eef4cb8026 100644 --- a/esphome/components/ota/ota_backend_esp_idf.cpp +++ b/esphome/components/ota_base/ota_backend_esp_idf.cpp @@ -12,9 +12,9 @@ #endif namespace esphome { -namespace ota { +namespace ota_base { -std::unique_ptr make_ota_backend() { return make_unique(); } +std::unique_ptr make_ota_backend() { return make_unique(); } OTAResponseTypes IDFOTABackend::begin(size_t image_size) { this->partition_ = esp_ota_get_next_update_partition(nullptr); @@ -111,6 +111,6 @@ void IDFOTABackend::abort() { this->update_handle_ = 0; } -} // namespace ota +} // namespace ota_base } // namespace esphome #endif diff --git a/esphome/components/ota/ota_backend_esp_idf.h b/esphome/components/ota_base/ota_backend_esp_idf.h similarity index 93% rename from esphome/components/ota/ota_backend_esp_idf.h rename to esphome/components/ota_base/ota_backend_esp_idf.h index ed66d9b970..a7e34cb5ae 100644 --- a/esphome/components/ota/ota_backend_esp_idf.h +++ b/esphome/components/ota_base/ota_backend_esp_idf.h @@ -8,7 +8,7 @@ #include namespace esphome { -namespace ota { +namespace ota_base { class IDFOTABackend : public OTABackend { public: @@ -26,6 +26,6 @@ class IDFOTABackend : public OTABackend { char expected_bin_md5_[32]; }; -} // namespace ota +} // namespace ota_base } // namespace esphome #endif diff --git a/esphome/components/speaker/media_player/speaker_media_player.cpp b/esphome/components/speaker/media_player/speaker_media_player.cpp index 2c30f17c78..2cebebd523 100644 --- a/esphome/components/speaker/media_player/speaker_media_player.cpp +++ b/esphome/components/speaker/media_player/speaker_media_player.cpp @@ -6,7 +6,7 @@ #include "esphome/components/audio/audio.h" #ifdef USE_OTA -#include "esphome/components/ota/ota_backend.h" +#include "esphome/components/ota/ota.h" #endif namespace esphome {