@@ -182,7 +182,8 @@ void OTADefaultCloudProcessInterface::parseOta(uint8_t* buffer, size_t buf_len)
182182
183183 break ;
184184 }
185- case OtaDownloadFile:
185+ case OtaDownloadFile: {
186+ uint32_t contentLength = http_client->contentLength ();
186187 context->decoder .decompress (cursor, buf_len - (cursor-buffer)); // TODO verify return value
187188
188189 context->calculatedCrc32 = crc_update (
@@ -195,22 +196,23 @@ void OTADefaultCloudProcessInterface::parseOta(uint8_t* buffer, size_t buf_len)
195196 context->downloadedSize += (cursor-buffer);
196197
197198 if ((millis () - context->lastReportTime ) > 10000 ) { // Report the download progress each X millisecond
198- DEBUG_VERBOSE (" OTA Download Progress %d/%d" , context->downloadedSize , http_client-> contentLength () );
199+ DEBUG_VERBOSE (" OTA Download Progress %d/%d" , context->downloadedSize , contentLength);
199200
200201 reportStatus (context->downloadedSize );
201202 context->lastReportTime = millis ();
202203 }
203204
204205 // TODO there should be no more bytes available when the download is completed
205- if (context->downloadedSize == http_client-> contentLength () ) {
206+ if (context->downloadedSize == contentLength) {
206207 context->downloadState = OtaDownloadCompleted;
207208 }
208209
209- if (context->downloadedSize > http_client-> contentLength () ) {
210+ if (context->downloadedSize > contentLength) {
210211 context->downloadState = OtaDownloadError;
211212 }
212213 // TODO fail if we exceed a timeout? and available is 0 (client is broken)
213214 break ;
215+ }
214216 case OtaDownloadCompleted:
215217 return ;
216218 default :
0 commit comments