Skip to content

Commit faf3fa5

Browse files
committed
mbed-cloud-client 4.13.3
1 parent 660b307 commit faf3fa5

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## Changelog for Izuma Device Management Client
22

3+
### Release 4.13.3 (18.05.2024)
4+
5+
- Bugfix - incorrect firmware download progress
6+
37
### Release 4.13.2 (10.12.2023)
48

59
- `PAL_MAX_FOLDER_DEPTH_CHAR` increased from 66 to 128 bytes for Linux targets.

fota/fota_app_ifs.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,18 @@ void fota_app_on_download_progress(size_t downloaded_size, size_t current_chunk_
6767
FOTA_ASSERT(total_size);
6868
static const uint32_t print_range_percent = 5;
6969

70-
total_size /= 100;
7170
// In case total size is less then 100B return without printing progress
7271
if (total_size == 0) {
7372
return;
7473
}
7574

76-
uint32_t progress = (downloaded_size + current_chunk_size) / total_size;
77-
uint32_t prev_progress = downloaded_size / total_size;
75+
// In case total size is too small to track progress meaningfully
76+
if (total_size < 100) {
77+
return;
78+
}
79+
80+
uint32_t progress = ((downloaded_size + current_chunk_size) * 100) / total_size;
81+
uint32_t prev_progress = (downloaded_size * 100) / total_size;
7882

7983
if (downloaded_size == 0 || ((progress / print_range_percent) > (prev_progress / print_range_percent))) {
8084
FOTA_APP_PRINT("Downloading firmware. %" PRIu32 "%c", progress, '%');

fota/fota_shim_layer.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,18 @@ void fota_app_on_download_progress(size_t downloaded_size, size_t current_chunk_
5555

5656
static const uint32_t print_range_percent = 5;
5757

58-
total_size /= 100;
5958
// In case total size is less then 100B return without printing progress
6059
if (total_size == 0) {
6160
return;
6261
}
6362

64-
uint32_t progress = (downloaded_size + current_chunk_size) / total_size;
65-
uint32_t prev_progress = downloaded_size / total_size;
63+
// In case total size is too small to track progress meaningfully
64+
if (total_size < 100) {
65+
return;
66+
}
67+
68+
uint32_t progress = ((downloaded_size + current_chunk_size) * 100) / total_size;
69+
uint32_t prev_progress = (downloaded_size * 100) / total_size;
6670

6771
if (downloaded_size == 0 || ((progress / print_range_percent) > (prev_progress / print_range_percent))) {
6872
FOTA_APP_PRINT("Downloading firmware. %" PRIu32 "%c", progress, '%');

0 commit comments

Comments
 (0)