From b55f4c897cd31d20adde08e3425b5250e5aa09b4 Mon Sep 17 00:00:00 2001 From: "ethan.du" Date: Mon, 27 Apr 2020 14:30:34 +0800 Subject: [PATCH] bugfix release ota fetch --- uiot/ota/src/ota_client.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/uiot/ota/src/ota_client.c b/uiot/ota/src/ota_client.c index 4b4fab4..d2a6723 100644 --- a/uiot/ota/src/ota_client.c +++ b/uiot/ota/src/ota_client.c @@ -327,12 +327,12 @@ void IOT_OTA_Clear(void *handle) memset(h_ota->url, 0, strlen(h_ota->url)); memset(h_ota->version, 0, strlen(h_ota->version)); memset(h_ota->md5sum, 0, strlen(h_ota->md5sum)); - h_ota->state = OTA_STATE_UNINITED; h_ota->size_last_fetched = 0; h_ota->size_fetched = 0; h_ota->size_file = 0; ota_lib_md5_deinit(h_ota->md5); - h_ota->md5 = ota_lib_md5_init(); + h_ota->md5 = ota_lib_md5_init(); + h_ota->state = OTA_STATE_INITED; return; } @@ -454,6 +454,7 @@ int IOT_OTA_FetchYield(void *handle, char *buf, size_t buf_len, size_t range_len ret = ofc_fetch(h_ota->ch_fetch, h_ota->size_fetched ,buf, buf_len, range_len, timeout_s); /* range download send request too often maybe cutdown by server, need reconnect and continue to download. */ if(ret == ERR_HTTP_CONN_ERROR) { + ofc_deinit(h_ota->ch_fetch); h_ota->ch_fetch = ofc_init(h_ota->url); ofc_connect(h_ota->ch_fetch); h_ota->state = OTA_STATE_FETCHING;