@@ -212,6 +212,18 @@ static void ota_example_task(void *pvParameter)
212
212
task_fatal_error ();
213
213
}
214
214
215
+ update_partition = esp_ota_get_next_update_partition (NULL );
216
+ ESP_LOGI (TAG , "Writing to partition subtype %d at offset 0x%x" ,
217
+ update_partition -> subtype , update_partition -> address );
218
+ assert (update_partition != NULL );
219
+
220
+ err = esp_ota_begin (update_partition , OTA_SIZE_UNKNOWN , & update_handle );
221
+ if (err != ESP_OK ) {
222
+ ESP_LOGE (TAG , "esp_ota_begin failed, error=%d" , err );
223
+ task_fatal_error ();
224
+ }
225
+ ESP_LOGI (TAG , "esp_ota_begin succeeded" );
226
+
215
227
/*send GET request to http server*/
216
228
const char * GET_FORMAT =
217
229
"GET %s HTTP/1.0\r\n"
@@ -234,18 +246,6 @@ static void ota_example_task(void *pvParameter)
234
246
ESP_LOGI (TAG , "Send GET request to server succeeded" );
235
247
}
236
248
237
- update_partition = esp_ota_get_next_update_partition (NULL );
238
- ESP_LOGI (TAG , "Writing to partition subtype %d at offset 0x%x" ,
239
- update_partition -> subtype , update_partition -> address );
240
- assert (update_partition != NULL );
241
-
242
- err = esp_ota_begin (update_partition , OTA_SIZE_UNKNOWN , & update_handle );
243
- if (err != ESP_OK ) {
244
- ESP_LOGE (TAG , "esp_ota_begin failed, error=%d" , err );
245
- task_fatal_error ();
246
- }
247
- ESP_LOGI (TAG , "esp_ota_begin succeeded" );
248
-
249
249
bool resp_body_start = false, flag = true;
250
250
/*deal with all receive packet*/
251
251
while (flag ) {
0 commit comments