kopia lustrzana https://github.com/espressif/esp-idf
esp_https_ota: Added esp_https_ota_get_image_size() to retrieve total size of OTA update
Signed-off-by: Shubham Kulkarni <shubham.kulkarni@espressif.com> Closes: https://github.com/espressif/esp-idf/pull/6880pull/7041/head
rodzic
74f9ce437f
commit
c73a17cc27
|
@ -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) {
|
||||
|
|
Ładowanie…
Reference in New Issue