Skip to content

Commit

Permalink
Add offset to ESP32 OTA error codes
Browse files Browse the repository at this point in the history
  • Loading branch information
pennam committed Oct 23, 2023
1 parent 6a9acc2 commit f711461
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/utility/ota/OTA-esp32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@

#include <esp_ota_ops.h>

/******************************************************************************
* DEFINES
******************************************************************************/

#define ESP32_OTA_ERROR_BASE (-300)

/******************************************************************************
* FUNCTION DEFINITION
******************************************************************************/
Expand All @@ -43,23 +49,23 @@ 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<int>(ota_err));
return static_cast<int>(ota_err);
return (ESP32_OTA_ERROR_BASE + static_cast<int>(ota_err));
}

/* Download the OTA file from the web storage location. */
int const ota_download = ota.download(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<int>(ota_download));

/* Verify update integrity and apply */
if ((ota_err = ota.update()) != Arduino_ESP32_OTA::Error::None)
{
DEBUG_ERROR("Arduino_ESP_OTA::update() failed with %d", static_cast<int>(ota_err));
return static_cast<int>(ota_err);
return (ESP32_OTA_ERROR_BASE + static_cast<int>(ota_err));
}

/* Perform the reset to reboot */
Expand Down

0 comments on commit f711461

Please sign in to comment.