Skip to content

Commit

Permalink
Add offset to UNO WiFi R4 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 b3c0886
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/utility/ota/OTA-unor4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
#define OTA_MAGIC (*((volatile uint16_t *) &R_SYSTEM->VBTBKR[4]))
#define OTA_SIZE (*((volatile uint32_t *) &R_SYSTEM->VBTBKR[6]))

#define UNO_WIFI_R4_OTA_ERROR_BASE (-400)

/******************************************************************************
* FUNCTION DEFINITION
******************************************************************************/
Expand Down Expand Up @@ -99,23 +101,23 @@ int unor4_onOTARequest(char const * ota_url)
if ((ota_err = ota.begin("/update.bin")) != OTAUpdate::Error::None)
{
DEBUG_ERROR("OTAUpdate::begin() failed with %d", static_cast<int>(ota_err));
return static_cast<int>(ota_err);
return (UNO_WIFI_R4_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,"/update.bin");
if (ota_download <= 0)
{
DEBUG_ERROR("OTAUpdate::download() failed with %d", ota_download);
return ota_download;
return (UNO_WIFI_R4_OTA_ERROR_BASE + ota_download);
}
DEBUG_VERBOSE("OTAUpdate::download() %d bytes downloaded", static_cast<int>(ota_download));

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

/* Store update size and write OTA magin number */
Expand All @@ -125,7 +127,7 @@ int unor4_onOTARequest(char const * ota_url)
if ((ota_err = ota.update("/update.bin")) != OTAUpdate::Error::None)
{
DEBUG_ERROR("OTAUpdate::update() failed with %d", static_cast<int>(ota_err));
return static_cast<int>(ota_err);
return (UNO_WIFI_R4_OTA_ERROR_BASE + static_cast<int>(ota_err));
}

return static_cast<int>(OTAUpdate::Error::None);
Expand Down

0 comments on commit b3c0886

Please sign in to comment.