From f7114610478e3542968629a7f08a8e791170b32b Mon Sep 17 00:00:00 2001 From: pennam Date: Mon, 16 Oct 2023 11:31:45 +0200 Subject: [PATCH] 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 443187c7..041974b6 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 */