Skip to content

Commit ee28a21

Browse files
committed
Allow to retrieve the error code from the nina module that happend during OTA download:
typedef enum OTA_Error { ERR_NO_ERROR = 0, ERR_OPEN = 1, ERR_LENGTH = 2, ERR_CRC = 3, ERR_RENAME = 4, };
1 parent 2c4518c commit ee28a21

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/WiFiStorage.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,12 @@ class WiFiStorageClass
5858
WiFiDrv::downloadFile(url, strlen(url), filename, strlen(filename));
5959
return true;
6060
}
61-
static bool downloadOTA(const char * url) {
62-
return (WiFiDrv::downloadOTA(url, strlen(url)) == 0);
61+
static bool downloadOTA(const char * url, uint8_t * res_ota_download = NULL) {
62+
uint8_t const res = WiFiDrv::downloadOTA(url, strlen(url));
63+
if (res_ota_download)
64+
*res_ota_download = res;
65+
bool const success = (res == 0);
66+
return success;
6367
}
6468

6569

@@ -78,8 +82,8 @@ class WiFiStorageClass
7882
static bool download(String url, String filename) {
7983
return download(url.c_str(), filename.c_str());
8084
}
81-
static bool download(String url) {
82-
return downloadOTA(url.c_str());
85+
static bool download(String url, uint8_t * res_ota_download = NULL) {
86+
return downloadOTA(url.c_str(), res_ota_download);
8387
}
8488
};
8589

0 commit comments

Comments
 (0)