Skip to content

Commit 2d86712

Browse files
fixup! defining OTAInterface
1 parent 3dfcaba commit 2d86712

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/ota/interface/OTAInterfaceDefault.cpp

+9-5
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ OTACloudProcessInterface::State OTADefaultCloudProcessInterface::fetch() {
9999
http_res = http_client->read(buffer, buf_len);
100100

101101
if(http_res < 0) {
102-
DEBUG_INFO("Download read error %d", http_res);
102+
DEBUG_VERBOSE("OTA ERROR: Download read error %d", http_res);
103103
res = OtaDownloadFail;
104104
goto exit;
105105
}
@@ -114,16 +114,17 @@ OTACloudProcessInterface::State OTADefaultCloudProcessInterface::fetch() {
114114
// validate CRC
115115
context->calculatedCrc32 ^= 0xFFFFFFFF; // finalize CRC
116116
if(context->header.header.crc32 == context->calculatedCrc32) {
117-
DEBUG_INFO("Ota download completed successfully");
117+
DEBUG_VERBOSE("Ota download completed successfully");
118118
res = FlashOTA;
119119
} else {
120120
res = OtaHeaderCrcFail;
121121
}
122122
} else if(context->downloadState == OtaDownloadError) {
123-
DEBUG_VERBOSE("OtaDownloadError");
123+
DEBUG_VERBOSE("OTA ERROR: OtaDownloadError");
124124

125125
res = OtaDownloadFail;
126126
} else if(context->downloadState == OtaDownloadMagicNumberMismatch) {
127+
DEBUG_VERBOSE("OTA ERROR: Magic number mismatch");
127128
res = OtaHeaterMagicNumberFail;
128129
}
129130

@@ -158,7 +159,6 @@ void OTADefaultCloudProcessInterface::parseOta(uint8_t* buffer, size_t buf_len)
158159
);
159160

160161
if(context->header.header.magic_number != OtaMagicNumber) {
161-
DEBUG_VERBOSE("Magic number mismatch");
162162
context->downloadState = OtaDownloadMagicNumberMismatch;
163163
return;
164164
}
@@ -178,7 +178,10 @@ void OTADefaultCloudProcessInterface::parseOta(uint8_t* buffer, size_t buf_len)
178178
cursor += buf_len - (cursor-buffer);
179179
context->downloadedSize += (cursor-buffer);
180180

181-
DEBUG_VERBOSE("Download %d/%d", context->downloadedSize, http_client->contentLength());
181+
if(float(context->downloadedSize - context->prevDownloadedSize)/http_client->contentLength() > 0.05) {
182+
DEBUG_VERBOSE("Download %d/%d", context->downloadedSize, http_client->contentLength());
183+
reportStatus(context->downloadedSize);
184+
}
182185

183186
// TODO there should be no more bytes available when the download is completed
184187
if(context->downloadedSize == http_client->contentLength()) {
@@ -220,6 +223,7 @@ OTADefaultCloudProcessInterface::Context::Context(
220223
, calculatedCrc32(0xFFFFFFFF)
221224
, headerCopiedBytes(0)
222225
, downloadedSize(0)
226+
, prevDownloadedSize(0)
223227
, decoder(putc) { }
224228

225229
static const uint32_t crc_table[256] = {

src/ota/interface/OTAInterfaceDefault.h

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class OTADefaultCloudProcessInterface: public OTACloudProcessInterface {
6969
uint32_t calculatedCrc32;
7070
uint32_t headerCopiedBytes;
7171
uint32_t downloadedSize;
72+
uint32_t prevDownloadedSize;
7273

7374
// LZSS decoder
7475
LZSSDecoder decoder;

0 commit comments

Comments
 (0)