Skip to content

Commit 7f1856b

Browse files
committed
Reorder SAMD OTA error codes
1 parent ef9d69d commit 7f1856b

File tree

2 files changed

+43
-2
lines changed

2 files changed

+43
-2
lines changed

Diff for: src/utility/ota/OTA-samd.cpp

+43-1
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,51 @@
3232
# include <WiFiNINA.h> /* WiFiStorage */
3333
#endif
3434

35+
/******************************************************************************
36+
* DEFINES
37+
******************************************************************************/
38+
39+
#define SAMD_OTA_ERROR_BASE (-200)
40+
41+
/******************************************************************************
42+
* TYPEDEF
43+
******************************************************************************/
44+
45+
enum class samdOTAError : int
46+
{
47+
None = 0,
48+
OtaHeaderCrc = SAMD_OTA_ERROR_BASE - 6,
49+
OtaDownload = SAMD_OTA_ERROR_BASE - 12,
50+
OpenUpdateFile = SAMD_OTA_ERROR_BASE - 19,
51+
Rename = SAMD_OTA_ERROR_BASE - 23,
52+
};
53+
54+
enum class ninaOTAError : int
55+
{
56+
None = 0,
57+
Open = 1,
58+
Length = 2,
59+
CRC = 3,
60+
Rename = 4,
61+
};
62+
3563
/******************************************************************************
3664
* FUNCTION DEFINITION
3765
******************************************************************************/
3866

67+
samdOTAError samd_getOTAError(ninaOTAError nina_ota_error_code)
68+
{
69+
switch(nina_ota_error_code)
70+
{
71+
case ninaOTAError::None: return samdOTAError::None;
72+
case ninaOTAError::Open: return samdOTAError::OpenUpdateFile;
73+
case ninaOTAError::Length: return samdOTAError::OtaDownload;
74+
case ninaOTAError::CRC: return samdOTAError::OtaHeaderCrc;
75+
case ninaOTAError::Rename: return samdOTAError::Rename;
76+
default: return samdOTAError::OtaDownload;
77+
}
78+
}
79+
3980
int samd_onOTARequest(char const * ota_url)
4081
{
4182
watchdog_reset();
@@ -52,7 +93,8 @@ int samd_onOTARequest(char const * ota_url)
5293
if (!WiFiStorage.downloadOTA(ota_url, &nina_ota_err_code))
5394
{
5495
DEBUG_ERROR("ArduinoIoTCloudTCP::%s error download to nina: %d", __FUNCTION__, nina_ota_err_code);
55-
return (NINAFW_OTA_ERROR_BASE - nina_ota_err_code);
96+
samdOTAError samd_ota_err_code = samd_getOTAError(static_cast<ninaOTAError>(nina_ota_err_code));
97+
return static_cast<int>(samd_ota_err_code);
5698
}
5799

58100
/* Perform the reset to reboot to SxU. */

Diff for: src/utility/ota/OTA.h

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
******************************************************************************/
3030

3131
#define RP2040_OTA_ERROR_BASE (-100)
32-
#define NINAFW_OTA_ERROR_BASE (-200)
3332

3433
/******************************************************************************
3534
* TYPEDEF

0 commit comments

Comments
 (0)