diff --git a/src/utility/ota/OTA-esp32.cpp b/src/utility/ota/OTA-esp32.cpp index 443187c7d..6fdd517e5 100644 --- a/src/utility/ota/OTA-esp32.cpp +++ b/src/utility/ota/OTA-esp32.cpp @@ -15,21 +15,24 @@ a commercial license, send an email to license@arduino.cc. */ +#ifdef ARDUINO_ARCH_ESP32 + /****************************************************************************** * INCLUDE ******************************************************************************/ -#include - -#if defined ARDUINO_ARCH_ESP32 && OTA_ENABLED - -#include "OTA.h" #include #include #include "tls/utility/SHA256.h" #include +/****************************************************************************** + * DEFINES + ******************************************************************************/ + +#define ESP32_OTA_ERROR_BASE (-300) + /****************************************************************************** * FUNCTION DEFINITION ******************************************************************************/ @@ -43,7 +46,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 +54,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,13 +62,13 @@ 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 */ ota.reset(); - return static_cast(OTAError::None); + return static_cast(Arduino_ESP32_OTA::Error::None); } String esp32_getOTAImageSHA256()