smaller fixes and using new esphttpdutils component

This commit is contained in:
2021-08-06 17:11:38 +02:00
parent bbc1f643e2
commit b76c6c7bf2
3 changed files with 19 additions and 15 deletions

View File

@ -7,12 +7,15 @@ set(sources
) )
set(dependencies set(dependencies
esp_https_ota
expected
fmt
cpputils cpputils
espchrono espchrono
espcpputils espcpputils
esp_https_ota esphttpdutils
expected
fmt
) )
idf_component_register( idf_component_register(

View File

@ -13,7 +13,7 @@
// local includes // local includes
#include "cleanuphelper.h" #include "cleanuphelper.h"
#include "espstrutils.h" #include "esphttpdutils.h"
#include "tickchrono.h" #include "tickchrono.h"
using namespace std::chrono_literals; using namespace std::chrono_literals;
@ -155,8 +155,8 @@ tl::expected<void, std::string> EspAsyncOta::trigger(std::string_view url, std::
if (url.empty()) if (url.empty())
return tl::make_unexpected("empty firmware url"); return tl::make_unexpected("empty firmware url");
if (const auto result = espcpputils::urlverify(url); !result) if (const auto result = esphttpdutils::urlverify(url); !result)
return result; return tl::make_unexpected(fmt::format("could not verify firmware url: {}", result.error()));
m_url = std::string{url}; m_url = std::string{url};
m_cert_pem = cert_pem; m_cert_pem = cert_pem;

View File

@ -14,20 +14,21 @@
#include "taskutils.h" #include "taskutils.h"
#include "wrappers/event_group.h" #include "wrappers/event_group.h"
#include "espchrono.h" #include "espchrono.h"
#include "cpptypesafeenum.h"
enum OtaCloudUpdateStatus #define OtaCloudUpdateStatusValues(x) \
{ x(Idle) \
Idle, x(Updating) \
Updating, x(Failed) \
Failed, x(Succeeded) \
Succeeded, x(NotReady)
NotReady DECLARE_TYPESAFE_ENUM(OtaCloudUpdateStatus, : uint8_t, OtaCloudUpdateStatusValues)
}; IMPLEMENT_TYPESAFE_ENUM(OtaCloudUpdateStatus, : uint8_t, OtaCloudUpdateStatusValues)
class EspAsyncOta class EspAsyncOta
{ {
public: 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(); ~EspAsyncOta();
tl::expected<void, std::string> startTask(); tl::expected<void, std::string> startTask();