File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -59,19 +59,24 @@ OTACloudProcessInterface::State UNOR4OTACloudProcess::startOTA() {
5959
6060OTACloudProcessInterface::State UNOR4OTACloudProcess::fetch () {
6161 String fv = WiFi.firmwareVersion ();
62- if (fv >= " 0.5.0" ) {
62+ /* Firmware supports non blocking OTA */
63+ if (fv >= " 0.5.0" ) {
6364 auto progress = ota.downloadProgress ();
65+ if (progress < 0 ) {
66+ return OtaDownloadFail;
67+ }
6468
65- if ((millis () - context->lastReportTime ) > 5000 ) { // Report the download progress each X millisecond
69+ if ((millis () - context->lastReportTime ) > 5000 ) { // Report the download progress each X millisecond
6670 DEBUG_VERBOSE (" OTA Download Progress %d/%d" , progress, context->downloadSize );
6771
6872 reportStatus (progress);
6973 context->lastReportTime = millis ();
7074 }
7175
72- if (progress < context->downloadSize ) {
76+ /* It is safe to cast progress here because we are sure that is positive */
77+ if ((size_t )progress < context->downloadSize ) {
7378 return Fetch;
74- } else if ( progress > context->downloadSize || progress < 0 ) {
79+ } else if (( size_t ) progress > context->downloadSize ) {
7580 return OtaDownloadFail;
7681 } else {
7782 return FlashOTA;
@@ -84,7 +89,6 @@ OTACloudProcessInterface::State UNOR4OTACloudProcess::fetch() {
8489 }
8590
8691 DEBUG_VERBOSE (" OTAUpdate::download() %d bytes downloaded" , ota_download);
87-
8892 return FlashOTA;
8993 }
9094}
You can’t perform that action at this time.
0 commit comments