mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'feature/ota_image_size' into 'master'
esp_https_ota: Added esp_https_ota_get_image_size() to retrieve total size of OTA update Closes IDFGH-5096 See merge request espressif/esp-idf!13496
This commit is contained in:
commit
fe02ef0fed
@ -201,6 +201,21 @@ esp_err_t esp_https_ota_get_img_desc(esp_https_ota_handle_t https_ota_handle, es
|
||||
*/
|
||||
int esp_https_ota_get_image_len_read(esp_https_ota_handle_t https_ota_handle);
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function returns OTA image total size.
|
||||
*
|
||||
* @note This API should be called after esp_https_ota_begin() has been already called.
|
||||
* This can be used to create some sort of progress indication
|
||||
* (in combination with esp_https_ota_get_image_len_read())
|
||||
*
|
||||
* @param[in] https_ota_handle pointer to esp_https_ota_handle_t structure
|
||||
*
|
||||
* @return
|
||||
* - -1 On failure or chunked encoding
|
||||
* - total bytes of image
|
||||
*/
|
||||
int esp_https_ota_get_image_size(esp_https_ota_handle_t https_ota_handle);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -246,6 +246,10 @@ esp_err_t esp_https_ota_begin(esp_https_ota_config_t *ota_config, esp_https_ota_
|
||||
goto http_cleanup;
|
||||
}
|
||||
|
||||
if (!https_ota_handle->partial_http_download) {
|
||||
https_ota_handle->image_length = esp_http_client_get_content_length(https_ota_handle->http_client);
|
||||
}
|
||||
|
||||
https_ota_handle->update_partition = NULL;
|
||||
ESP_LOGI(TAG, "Starting OTA...");
|
||||
https_ota_handle->update_partition = esp_ota_get_next_update_partition(NULL);
|
||||
@ -521,6 +525,18 @@ int esp_https_ota_get_image_len_read(esp_https_ota_handle_t https_ota_handle)
|
||||
return handle->binary_file_len;
|
||||
}
|
||||
|
||||
int esp_https_ota_get_image_size(esp_https_ota_handle_t https_ota_handle)
|
||||
{
|
||||
esp_https_ota_t *handle = (esp_https_ota_t *)https_ota_handle;
|
||||
if (handle == NULL) {
|
||||
return -1;
|
||||
}
|
||||
if (handle->state < ESP_HTTPS_OTA_BEGIN) {
|
||||
return -1;
|
||||
}
|
||||
return handle->image_length;
|
||||
}
|
||||
|
||||
esp_err_t esp_https_ota(const esp_http_client_config_t *config)
|
||||
{
|
||||
if (!config) {
|
||||
|
Loading…
Reference in New Issue
Block a user