接前一篇文章:ESP-IDF OTA机制详解(12)
上一回解析完了esp_ota_begin函数,本文回到esp_https_ota_perform函数,并继续对于该函数其余内容进行解析。为了便于理解和回顾,再次贴出该函数源码,在C:\Espressif\frameworks\esp-idf-v5.2.1\components\esp_https_ota\src\esp_https_ota.c中,如下:
esp_err_t esp_https_ota_perform(esp_https_ota_handle_t https_ota_handle)
{
esp_https_ota_t *handle = (esp_https_ota_t *)https_ota_handle;
if (handle == NULL) {
ESP_LOGE(TAG, "esp_https_ota_perform: Invalid argument");
return ESP_ERR_INVALID_ARG;
}
if (handle->state < ESP_HTTPS_OTA_BEGIN) {
ESP_LOGE(TAG, "esp_https_ota_perform: Invalid state");
return ESP_FAIL;
}
esp_err_t err;
int data_read;
const int erase_size = handle->bulk_flash_erase ? OTA_SIZE_UNKN