为什么这么慢呢?
Code: Select all
esp_err_t ota_finish_err = ESP_OK;
esp_http_client_config_t config = {
.url = OTA_FIRMWARE_UPGRADE_URI,
.cert_pem = NULL, //(char *)server_cert_pem_start,
};
esp_https_ota_config_t ota_config = {
.http_config = &config,
};
esp_https_ota_handle_t https_ota_handle = NULL;
esp_err_t err = esp_https_ota_begin(&ota_config, &https_ota_handle);
if (err != ESP_OK) {
ESP_LOGE(TAG, "ESP HTTPS OTA Begin failed");
vTaskDelete(NULL);
}
esp_app_desc_t app_desc;
err = esp_https_ota_get_img_desc(https_ota_handle, &app_desc);
if (err != ESP_OK) {
ESP_LOGE(TAG, "esp_https_ota_read_img_desc failed");
goto ota_end;
}
err = validate_image_header(&app_desc);
if (err != ESP_OK) {
ESP_LOGE(TAG, "image header verification failed");
goto ota_end;
}
i = 0;
len = 0;
percent = 0;
while (1) {
//vTaskDelay(1000 / portTICK_PERIOD_MS);
err = esp_https_ota_perform(https_ota_handle);
if (err != ESP_ERR_HTTPS_OTA_IN_PROGRESS) {
break;
}
// esp_https_ota_perform returns after every read operation which gives user the ability to
// monitor the status of OTA upgrade by calling esp_https_ota_get_image_len_read, which gives length of image
// data read so far.
len = esp_https_ota_get_image_len_read(https_ota_handle);
if ((len - i) > 14336) {
percent++;
ESP_LOGE(TAG, "Image bytes read: %d, OTA : %d%%", len, percent);
i = len;
}
}