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