Skip to content

Commit b7c1ad7

Browse files
committed
Merge branch 'feature/add_api_to_get_last_status_code_logged_during_ota_v5.0' into 'release/v5.0'
feat(esp_https_ota): added API to get last status code logged from http resonse (v5.0) See merge request espressif/esp-idf!33612
2 parents 339a6c3 + 7a163ad commit b7c1ad7

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

components/esp_https_ota/include/esp_https_ota.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,21 @@ esp_err_t esp_https_ota_get_img_desc(esp_https_ota_handle_t https_ota_handle, es
235235
int esp_https_ota_get_image_len_read(esp_https_ota_handle_t https_ota_handle);
236236

237237

238+
/**
239+
* @brief This function returns the HTTP status code of the last HTTP response.
240+
*
241+
* @note This API should be called only after esp_https_ota_begin() has been called.
242+
* This can be used to check the HTTP status code of the OTA download process.
243+
*
244+
* @param[in] https_ota_handle pointer to esp_https_ota_handle_t structure
245+
*
246+
* @return
247+
* - -1 On failure
248+
* - HTTP status code
249+
*/
250+
int esp_https_ota_get_status_code(esp_https_ota_handle_t https_ota_handle);
251+
252+
238253
/**
239254
* @brief This function returns OTA image total size.
240255
*

components/esp_https_ota/src/esp_https_ota.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,15 @@ esp_err_t esp_https_ota_abort(esp_https_ota_handle_t https_ota_handle)
697697
return err;
698698
}
699699

700+
int esp_https_ota_get_status_code(esp_https_ota_handle_t https_ota_handle)
701+
{
702+
esp_https_ota_t *handle = (esp_https_ota_t *) https_ota_handle;
703+
if (handle == NULL || handle->http_client == NULL) {
704+
return -1;
705+
}
706+
return esp_http_client_get_status_code(handle->http_client);
707+
}
708+
700709
int esp_https_ota_get_image_len_read(esp_https_ota_handle_t https_ota_handle)
701710
{
702711
esp_https_ota_t *handle = (esp_https_ota_t *)https_ota_handle;

0 commit comments

Comments
 (0)