Skip to content

Commit 2443207

Browse files
committed
Reorder SAMD OTA error codes
1 parent 9bb4dcc commit 2443207

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
@@ -33,10 +33,51 @@
3333
# include <WiFiNINA.h> /* WiFiStorage */
3434
#endif
3535

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

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

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

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

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
******************************************************************************/
3434

3535
#define RP2040_OTA_ERROR_BASE (-100)
36-
#define NINAFW_OTA_ERROR_BASE (-200)
3736

3837
/******************************************************************************
3938
* TYPEDEF

0 commit comments

Comments
 (0)