Skip to content

Add offset to ESP32 error codes #389

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions src/utility/ota/OTA-esp32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,24 @@
a commercial license, send an email to [email protected].
*/

#ifdef ARDUINO_ARCH_ESP32

/******************************************************************************
* INCLUDE
******************************************************************************/

#include <AIoTC_Config.h>

#if defined ARDUINO_ARCH_ESP32 && OTA_ENABLED

#include "OTA.h"
#include <Arduino_DebugUtils.h>
#include <Arduino_ESP32_OTA.h>
#include "tls/utility/SHA256.h"

#include <esp_ota_ops.h>

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

#define ESP32_OTA_ERROR_BASE (-300)

/******************************************************************************
* FUNCTION DEFINITION
******************************************************************************/
Expand All @@ -43,29 +46,29 @@ 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 */
ota.reset();

return static_cast<int>(OTAError::None);
return static_cast<int>(Arduino_ESP32_OTA::Error::None);
}

String esp32_getOTAImageSHA256()
Expand Down