diff --git a/CMakeLists.txt b/CMakeLists.txt index e61bd75..d0301b6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,12 +7,15 @@ set(sources ) set(dependencies + esp_https_ota + + expected + fmt + cpputils espchrono espcpputils - esp_https_ota - expected - fmt + esphttpdutils ) idf_component_register( diff --git a/src/espasyncota.cpp b/src/espasyncota.cpp index 446b5a8..47f1b11 100644 --- a/src/espasyncota.cpp +++ b/src/espasyncota.cpp @@ -13,7 +13,7 @@ // local includes #include "cleanuphelper.h" -#include "espstrutils.h" +#include "esphttpdutils.h" #include "tickchrono.h" using namespace std::chrono_literals; @@ -155,8 +155,8 @@ tl::expected EspAsyncOta::trigger(std::string_view url, std:: if (url.empty()) return tl::make_unexpected("empty firmware url"); - if (const auto result = espcpputils::urlverify(url); !result) - return result; + if (const auto result = esphttpdutils::urlverify(url); !result) + return tl::make_unexpected(fmt::format("could not verify firmware url: {}", result.error())); m_url = std::string{url}; m_cert_pem = cert_pem; diff --git a/src/espasyncota.h b/src/espasyncota.h index 27aa286..792cb87 100644 --- a/src/espasyncota.h +++ b/src/espasyncota.h @@ -14,20 +14,21 @@ #include "taskutils.h" #include "wrappers/event_group.h" #include "espchrono.h" +#include "cpptypesafeenum.h" -enum OtaCloudUpdateStatus -{ - Idle, - Updating, - Failed, - Succeeded, - NotReady -}; +#define OtaCloudUpdateStatusValues(x) \ + x(Idle) \ + x(Updating) \ + x(Failed) \ + x(Succeeded) \ + x(NotReady) +DECLARE_TYPESAFE_ENUM(OtaCloudUpdateStatus, : uint8_t, OtaCloudUpdateStatusValues) +IMPLEMENT_TYPESAFE_ENUM(OtaCloudUpdateStatus, : uint8_t, OtaCloudUpdateStatusValues) class EspAsyncOta { public: - EspAsyncOta(const char *taskName="asyncOtaTask", uint32_t stackSize=2048, espcpputils::CoreAffinity coreAffinity=espcpputils::CoreAffinity::Core1); + EspAsyncOta(const char *taskName="asyncOtaTask", uint32_t stackSize=4096, espcpputils::CoreAffinity coreAffinity=espcpputils::CoreAffinity::Core1); ~EspAsyncOta(); tl::expected startTask();