feat: report OTA download progress over MQTT
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
|
||||
typedef struct {
|
||||
char url[BANBAN_FULLOTA2_URL_MAX];
|
||||
banban_fullfota2_progress_cb_t progress_cb;
|
||||
banban_fullfota2_finished_cb_t finished_cb;
|
||||
} banban_fullfota2_request_t;
|
||||
|
||||
@@ -171,6 +172,9 @@ static void banban_fullfota2_task(void *argument)
|
||||
printf("[FULLOTA2] download progress=%d%% bytes=%d/%d\r\n",
|
||||
progress, written, content_length);
|
||||
while (next_progress <= progress) {
|
||||
if (g_fullfota2_request.progress_cb != NULL) {
|
||||
g_fullfota2_request.progress_cb(next_progress);
|
||||
}
|
||||
next_progress += 10;
|
||||
}
|
||||
}
|
||||
@@ -219,6 +223,7 @@ failed:
|
||||
}
|
||||
|
||||
int banban_fullfota2_start(const char *url,
|
||||
banban_fullfota2_progress_cb_t progress_cb,
|
||||
banban_fullfota2_finished_cb_t finished_cb)
|
||||
{
|
||||
int ret;
|
||||
@@ -239,6 +244,7 @@ int banban_fullfota2_start(const char *url,
|
||||
|
||||
memset(&g_fullfota2_request, 0, sizeof(g_fullfota2_request));
|
||||
memcpy(g_fullfota2_request.url, url, url_length + 1);
|
||||
g_fullfota2_request.progress_cb = progress_cb;
|
||||
g_fullfota2_request.finished_cb = finished_cb;
|
||||
g_fullfota2_running = 1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user