From 1ed4429455a5a9f51c534c1bf0fbbdfbcf73b05e Mon Sep 17 00:00:00 2001 From: Chen Wu Date: Tue, 21 Aug 2018 16:47:34 +0800 Subject: [PATCH] fix: ota beacon timeout --- examples/system/ota/main/ota_example_main.c | 24 ++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/examples/system/ota/main/ota_example_main.c b/examples/system/ota/main/ota_example_main.c index cfbfc76d..4f7694c7 100644 --- a/examples/system/ota/main/ota_example_main.c +++ b/examples/system/ota/main/ota_example_main.c @@ -212,6 +212,18 @@ static void ota_example_task(void *pvParameter) task_fatal_error(); } + update_partition = esp_ota_get_next_update_partition(NULL); + ESP_LOGI(TAG, "Writing to partition subtype %d at offset 0x%x", + update_partition->subtype, update_partition->address); + assert(update_partition != NULL); + + err = esp_ota_begin(update_partition, OTA_SIZE_UNKNOWN, &update_handle); + if (err != ESP_OK) { + ESP_LOGE(TAG, "esp_ota_begin failed, error=%d", err); + task_fatal_error(); + } + ESP_LOGI(TAG, "esp_ota_begin succeeded"); + /*send GET request to http server*/ const char *GET_FORMAT = "GET %s HTTP/1.0\r\n" @@ -234,18 +246,6 @@ static void ota_example_task(void *pvParameter) ESP_LOGI(TAG, "Send GET request to server succeeded"); } - update_partition = esp_ota_get_next_update_partition(NULL); - ESP_LOGI(TAG, "Writing to partition subtype %d at offset 0x%x", - update_partition->subtype, update_partition->address); - assert(update_partition != NULL); - - err = esp_ota_begin(update_partition, OTA_SIZE_UNKNOWN, &update_handle); - if (err != ESP_OK) { - ESP_LOGE(TAG, "esp_ota_begin failed, error=%d", err); - task_fatal_error(); - } - ESP_LOGI(TAG, "esp_ota_begin succeeded"); - bool resp_body_start = false, flag = true; /*deal with all receive packet*/ while (flag) {