-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix ota download byte count #514
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #514 +/- ##
=======================================
Coverage 95.39% 95.39%
=======================================
Files 33 33
Lines 1520 1520
=======================================
Hits 1450 1450
Misses 70 70 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
Memory usage change @ 84cda53
Click for full report table
Click for full report CSV
|
/* Avoid tight loop and allow yield */ | ||
delay(1); | ||
continue; | ||
} | ||
|
||
http_res = http_client->read(context->buffer, context->buf_len); | ||
http_res = http_client->read(context->buffer, (available > context->buf_len) ? context->buf_len : available); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HttpClient::read(buf, len)
reads at most len bytes, I think that this is superfluous, since it is already being performed under the hood.
@@ -159,7 +160,7 @@ void OTADefaultCloudProcessInterface::parseOta(uint8_t* buffer, size_t buf_len) | |||
for(uint8_t* cursor=(uint8_t*)buffer; cursor<buffer+buf_len; ) { | |||
switch(context->downloadState) { | |||
case OtaDownloadHeader: { | |||
uint32_t copied = buf_len < sizeof(context->header.buf) ? buf_len : sizeof(context->header.buf); | |||
const uint32_t copied = context->headerCopiedBytes + buf_len < sizeof(context->header.buf) ? buf_len : sizeof(context->header.buf) - context->headerCopiedBytes; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is far more readable this way. It is exactly the same.
const uint32_t copied = context->headerCopiedBytes + buf_len < sizeof(context->header.buf) ? buf_len : sizeof(context->header.buf) - context->headerCopiedBytes; | |
const uint32_t copied = buf_len < sizeof(context->header.buf) - context->headerCopiedBytes ? buf_len : sizeof(context->header.buf) - context->headerCopiedBytes; |
No description provided.