From ee28a2136a8ce59c48803617bf06fe7f4e7634f1 Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Thu, 6 Aug 2020 08:27:03 +0200 Subject: [PATCH] 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, }; --- src/WiFiStorage.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/WiFiStorage.h b/src/WiFiStorage.h index 249ed1c8..54f744a0 100644 --- a/src/WiFiStorage.h +++ b/src/WiFiStorage.h @@ -58,8 +58,12 @@ class WiFiStorageClass WiFiDrv::downloadFile(url, strlen(url), filename, strlen(filename)); return true; } - static bool downloadOTA(const char * url) { - return (WiFiDrv::downloadOTA(url, strlen(url)) == 0); + static bool downloadOTA(const char * url, uint8_t * res_ota_download = NULL) { + uint8_t const res = WiFiDrv::downloadOTA(url, strlen(url)); + if (res_ota_download) + *res_ota_download = res; + bool const success = (res == 0); + return success; } @@ -78,8 +82,8 @@ class WiFiStorageClass static bool download(String url, String filename) { return download(url.c_str(), filename.c_str()); } - static bool download(String url) { - return downloadOTA(url.c_str()); + static bool download(String url, uint8_t * res_ota_download = NULL) { + return downloadOTA(url.c_str(), res_ota_download); } };