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() {
59
59
60
60
OTACloudProcessInterface::State UNOR4OTACloudProcess::fetch () {
61
61
String fv = WiFi.firmwareVersion ();
62
- if (fv >= " 0.5.0" ) {
62
+ /* Firmware supports non blocking OTA */
63
+ if (fv >= " 0.5.0" ) {
63
64
auto progress = ota.downloadProgress ();
65
+ if (progress < 0 ) {
66
+ return OtaDownloadFail;
67
+ }
64
68
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
66
70
DEBUG_VERBOSE (" OTA Download Progress %d/%d" , progress, context->downloadSize );
67
71
68
72
reportStatus (progress);
69
73
context->lastReportTime = millis ();
70
74
}
71
75
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 ) {
73
78
return Fetch;
74
- } else if ( progress > context->downloadSize || progress < 0 ) {
79
+ } else if (( size_t ) progress > context->downloadSize ) {
75
80
return OtaDownloadFail;
76
81
} else {
77
82
return FlashOTA;
@@ -84,7 +89,6 @@ OTACloudProcessInterface::State UNOR4OTACloudProcess::fetch() {
84
89
}
85
90
86
91
DEBUG_VERBOSE (" OTAUpdate::download() %d bytes downloaded" , ota_download);
87
-
88
92
return FlashOTA;
89
93
}
90
94
}
You can’t perform that action at this time.
0 commit comments