Skip to content

Commit

Permalink
Merge pull request #497 from pennam/fix-sign-compare
Browse files Browse the repository at this point in the history
OTA: fix sign-compare compiler warnings
  • Loading branch information
pennam authored Jul 23, 2024
2 parents 8dcbf51 + ee008cb commit 5591857
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/ota/interface/OTAInterfaceDefault.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ void OTADefaultCloudProcessInterface::parseOta(uint8_t* buffer, size_t buf_len)

break;
}
case OtaDownloadFile:
case OtaDownloadFile: {
uint32_t contentLength = http_client->contentLength();
context->decoder.decompress(cursor, buf_len - (cursor-buffer)); // TODO verify return value

context->calculatedCrc32 = crc_update(
Expand All @@ -195,22 +196,23 @@ void OTADefaultCloudProcessInterface::parseOta(uint8_t* buffer, size_t buf_len)
context->downloadedSize += (cursor-buffer);

if((millis() - context->lastReportTime) > 10000) { // Report the download progress each X millisecond
DEBUG_VERBOSE("OTA Download Progress %d/%d", context->downloadedSize, http_client->contentLength());
DEBUG_VERBOSE("OTA Download Progress %d/%d", context->downloadedSize, contentLength);

reportStatus(context->downloadedSize);
context->lastReportTime = millis();
}

// TODO there should be no more bytes available when the download is completed
if(context->downloadedSize == http_client->contentLength()) {
if(context->downloadedSize == contentLength) {
context->downloadState = OtaDownloadCompleted;
}

if(context->downloadedSize > http_client->contentLength()) {
if(context->downloadedSize > contentLength) {
context->downloadState = OtaDownloadError;
}
// TODO fail if we exceed a timeout? and available is 0 (client is broken)
break;
}
case OtaDownloadCompleted:
return;
default:
Expand Down

0 comments on commit 5591857

Please sign in to comment.