mgmt: hawkbit: add CONFIG_HAWKBIT_SAVE_PROGRESS_INTERVAL
add CONFIG_HAWKBIT_SAVE_PROGRESS_INTERVAL, to be able to set a interval, how often the progress is saved. Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
This commit is contained in:
parent
4cd44e7da2
commit
3c88970cec
2 changed files with 33 additions and 15 deletions
|
@ -199,6 +199,15 @@ config HAWKBIT_SAVE_PROGRESS
|
||||||
This is especially useful for large updates over unreliable networks or in
|
This is especially useful for large updates over unreliable networks or in
|
||||||
resource-constrained environments.
|
resource-constrained environments.
|
||||||
|
|
||||||
|
config HAWKBIT_SAVE_PROGRESS_INTERVAL
|
||||||
|
int "Save the hawkBit update download progress interval"
|
||||||
|
default 5
|
||||||
|
range 0 100
|
||||||
|
depends on HAWKBIT_SAVE_PROGRESS
|
||||||
|
help
|
||||||
|
Set the interval (in percent) that the hawkBit update download progress will be saved.
|
||||||
|
0 means that the progress will be saved every time a new chunk is downloaded.
|
||||||
|
|
||||||
module = HAWKBIT
|
module = HAWKBIT
|
||||||
module-str = Log Level for hawkbit
|
module-str = Log Level for hawkbit
|
||||||
module-help = Enables logging for hawkBit code.
|
module-help = Enables logging for hawkBit code.
|
||||||
|
|
|
@ -953,28 +953,37 @@ static void response_download_cb(struct http_response *rsp, enum http_final_call
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rsp->body_found) {
|
if (!rsp->body_found) {
|
||||||
body_data = rsp->body_frag_start;
|
return;
|
||||||
body_len = rsp->body_frag_len;
|
|
||||||
|
|
||||||
ret = flash_img_buffered_write(&hb_context->flash_ctx, body_data, body_len,
|
|
||||||
final_data == HTTP_DATA_FINAL);
|
|
||||||
if (ret < 0) {
|
|
||||||
LOG_ERR("Failed to write flash: %d", ret);
|
|
||||||
hb_context->code_status = HAWKBIT_DOWNLOAD_ERROR;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef CONFIG_HAWKBIT_SAVE_PROGRESS
|
|
||||||
stream_flash_progress_save(&hb_context->flash_ctx.stream, "hawkbit/flash_progress");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
body_data = rsp->body_frag_start;
|
||||||
|
body_len = rsp->body_frag_len;
|
||||||
|
|
||||||
|
ret = flash_img_buffered_write(&hb_context->flash_ctx, body_data, body_len,
|
||||||
|
final_data == HTTP_DATA_FINAL);
|
||||||
|
if (ret < 0) {
|
||||||
|
LOG_ERR("Failed to write flash: %d", ret);
|
||||||
|
hb_context->code_status = HAWKBIT_DOWNLOAD_ERROR;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined CONFIG_HAWKBIT_SAVE_PROGRESS && IS_EQ(CONFIG_HAWKBIT_SAVE_PROGRESS_INTERVAL, 0)
|
||||||
|
stream_flash_progress_save(&hb_context->flash_ctx.stream, "hawkbit/flash_progress");
|
||||||
|
#endif
|
||||||
|
|
||||||
hb_context->dl.downloaded_size = flash_img_bytes_written(&hb_context->flash_ctx);
|
hb_context->dl.downloaded_size = flash_img_bytes_written(&hb_context->flash_ctx);
|
||||||
|
|
||||||
downloaded = hb_context->dl.downloaded_size * 100 / hb_context->dl.file_size;
|
downloaded = hb_context->dl.downloaded_size * 100 / hb_context->dl.file_size;
|
||||||
|
|
||||||
if (downloaded != download_progress) {
|
if (downloaded != download_progress) {
|
||||||
|
#if defined CONFIG_HAWKBIT_SAVE_PROGRESS && !IS_EQ(CONFIG_HAWKBIT_SAVE_PROGRESS_INTERVAL, 0)
|
||||||
|
if ((downloaded / CONFIG_HAWKBIT_SAVE_PROGRESS_INTERVAL) >
|
||||||
|
(download_progress / CONFIG_HAWKBIT_SAVE_PROGRESS_INTERVAL)) {
|
||||||
|
stream_flash_progress_save(&hb_context->flash_ctx.stream,
|
||||||
|
"hawkbit/flash_progress");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
download_progress = downloaded;
|
download_progress = downloaded;
|
||||||
LOG_DBG("Downloaded: %u%% (%u / %u)", download_progress,
|
LOG_DBG("Downloaded: %u%% (%u / %u)", download_progress,
|
||||||
hb_context->dl.downloaded_size, hb_context->dl.file_size);
|
hb_context->dl.downloaded_size, hb_context->dl.file_size);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue