From f7114610478e3542968629a7f08a8e791170b32b Mon Sep 17 00:00:00 2001 From: pennam Date: Mon, 16 Oct 2023 11:31:45 +0200 Subject: [PATCH 1/3] Add offset to ESP32 OTA error codes --- src/utility/ota/OTA-esp32.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/utility/ota/OTA-esp32.cpp b/src/utility/ota/OTA-esp32.cpp index 443187c7d..041974b6f 100644 --- a/src/utility/ota/OTA-esp32.cpp +++ b/src/utility/ota/OTA-esp32.cpp @@ -30,6 +30,12 @@ #include +/****************************************************************************** + * DEFINES + ******************************************************************************/ + +#define ESP32_OTA_ERROR_BASE (-300) + /****************************************************************************** * FUNCTION DEFINITION ******************************************************************************/ @@ -43,7 +49,7 @@ int esp32_onOTARequest(char const * ota_url) if ((ota_err = ota.begin()) != Arduino_ESP32_OTA::Error::None) { DEBUG_ERROR("Arduino_ESP32_OTA::begin() failed with %d", static_cast(ota_err)); - return static_cast(ota_err); + return (ESP32_OTA_ERROR_BASE + static_cast(ota_err)); } /* Download the OTA file from the web storage location. */ @@ -51,7 +57,7 @@ int esp32_onOTARequest(char const * ota_url) if (ota_download <= 0) { DEBUG_ERROR("Arduino_ESP_OTA::download() failed with %d", ota_download); - return ota_download; + return (ESP32_OTA_ERROR_BASE + ota_download); } DEBUG_VERBOSE("Arduino_ESP_OTA::download() %d bytes downloaded", static_cast(ota_download)); @@ -59,7 +65,7 @@ int esp32_onOTARequest(char const * ota_url) if ((ota_err = ota.update()) != Arduino_ESP32_OTA::Error::None) { DEBUG_ERROR("Arduino_ESP_OTA::update() failed with %d", static_cast(ota_err)); - return static_cast(ota_err); + return (ESP32_OTA_ERROR_BASE + static_cast(ota_err)); } /* Perform the reset to reboot */ From aa757ffbfa5e8f96548b5e02005e16b677f5779a Mon Sep 17 00:00:00 2001 From: pennam Date: Mon, 23 Oct 2023 17:13:47 +0200 Subject: [PATCH 2/3] Avoid including OTA.h --- src/utility/ota/OTA-esp32.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/utility/ota/OTA-esp32.cpp b/src/utility/ota/OTA-esp32.cpp index 041974b6f..6b46ee853 100644 --- a/src/utility/ota/OTA-esp32.cpp +++ b/src/utility/ota/OTA-esp32.cpp @@ -23,7 +23,6 @@ #if defined ARDUINO_ARCH_ESP32 && OTA_ENABLED -#include "OTA.h" #include #include #include "tls/utility/SHA256.h" @@ -71,7 +70,7 @@ int esp32_onOTARequest(char const * ota_url) /* Perform the reset to reboot */ ota.reset(); - return static_cast(OTAError::None); + return static_cast(Arduino_ESP32_OTA::Error::None); } String esp32_getOTAImageSHA256() From ac8e23a507ec3268e6a1d0408a572fb5c1911770 Mon Sep 17 00:00:00 2001 From: pennam Date: Tue, 24 Oct 2023 08:52:02 +0200 Subject: [PATCH 3/3] Remove OTA_ENABLED define check --- src/utility/ota/OTA-esp32.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/utility/ota/OTA-esp32.cpp b/src/utility/ota/OTA-esp32.cpp index 6b46ee853..6fdd517e5 100644 --- a/src/utility/ota/OTA-esp32.cpp +++ b/src/utility/ota/OTA-esp32.cpp @@ -15,14 +15,12 @@ a commercial license, send an email to license@arduino.cc. */ +#ifdef ARDUINO_ARCH_ESP32 + /****************************************************************************** * INCLUDE ******************************************************************************/ -#include - -#if defined ARDUINO_ARCH_ESP32 && OTA_ENABLED - #include #include #include "tls/utility/SHA256.h"