From be33da156e2731b4b61037e008577d069a366f23 Mon Sep 17 00:00:00 2001 From: LittleBuster Date: Wed, 11 Sep 2024 00:51:49 +0700 Subject: [PATCH] Fix OTA multiple definition build error --- library.properties | 2 +- src/core/ota.cpp | 35 +++++++++++++++++++++++++++++++++++ src/core/ota.h | 30 +----------------------------- 3 files changed, 37 insertions(+), 30 deletions(-) create mode 100644 src/core/ota.cpp diff --git a/library.properties b/library.properties index 6ff3e76..79a52f2 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Settings -version=1.0.15 +version=1.0.16 author=AlexGyver maintainer=AlexGyver sentence=Simple UI webface builder for esp8266/esp32 diff --git a/src/core/ota.cpp b/src/core/ota.cpp new file mode 100644 index 0000000..a4c9210 --- /dev/null +++ b/src/core/ota.cpp @@ -0,0 +1,35 @@ +#include "ota.h" + +namespace sets { + +bool beginOta(bool ota_flash, bool async) { + size_t ota_size = 0; + int ota_type = 0; + + if (ota_flash) { + ota_type = U_FLASH; +#ifdef ESP8266 + ota_size = (size_t)((ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000); +#else + ota_size = UPDATE_SIZE_UNKNOWN; +#endif + } else { +#ifdef ESP8266 + ota_type = U_FS; + close_all_fs(); +#ifndef GH_NO_FS + ota_size = (size_t)&_FS_end - (size_t)&_FS_start; +#endif +#else + ota_type = U_SPIFFS; + ota_size = UPDATE_SIZE_UNKNOWN; +#endif + } + +#ifdef ESP8266 + if (async) Update.runAsync(true); +#endif + return Update.begin(ota_size, ota_type); +} + +} diff --git a/src/core/ota.h b/src/core/ota.h index 64c247b..20b649f 100644 --- a/src/core/ota.h +++ b/src/core/ota.h @@ -12,34 +12,6 @@ namespace sets { -bool beginOta(bool ota_flash = true, bool async = false) { - size_t ota_size = 0; - int ota_type = 0; - - if (ota_flash) { - ota_type = U_FLASH; -#ifdef ESP8266 - ota_size = (size_t)((ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000); -#else - ota_size = UPDATE_SIZE_UNKNOWN; -#endif - } else { -#ifdef ESP8266 - ota_type = U_FS; - close_all_fs(); -#ifndef GH_NO_FS - ota_size = (size_t)&_FS_end - (size_t)&_FS_start; -#endif -#else - ota_type = U_SPIFFS; - ota_size = UPDATE_SIZE_UNKNOWN; -#endif - } - -#ifdef ESP8266 - if (async) Update.runAsync(true); -#endif - return Update.begin(ota_size, ota_type); -} +bool beginOta(bool ota_flash = true, bool async = false); } // namespace sets \ No newline at end of file