33
33
# include < WiFiNINA.h> /* WiFiStorage */
34
34
#endif
35
35
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
+
36
64
/* *****************************************************************************
37
65
* FUNCTION DEFINITION
38
66
******************************************************************************/
39
67
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
+
40
81
int samd_onOTARequest (char const * ota_url)
41
82
{
42
83
watchdog_reset ();
@@ -53,7 +94,8 @@ int samd_onOTARequest(char const * ota_url)
53
94
if (!WiFiStorage.downloadOTA (ota_url, &nina_ota_err_code))
54
95
{
55
96
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);
57
99
}
58
100
59
101
/* Perform the reset to reboot to SxU. */
0 commit comments