Skip to content

Commit 1f68652

Browse files
Merge branch 'feature/add_api_to_get_last_status_code_logged_during_ota_v5.3' into 'release/v5.3'
feat(esp_https_ota): added API to get last status code logged from http resonse (v5.3) See merge request espressif/esp-idf!33609
2 parents fbf7f2c + 186d534 commit 1f68652

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
@@ -236,6 +236,21 @@ esp_err_t esp_https_ota_get_img_desc(esp_https_ota_handle_t https_ota_handle, es
236236
int esp_https_ota_get_image_len_read(esp_https_ota_handle_t https_ota_handle);
237237

238238

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

components/esp_https_ota/src/esp_https_ota.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,15 @@ esp_err_t esp_https_ota_abort(esp_https_ota_handle_t https_ota_handle)
718718
return err;
719719
}
720720

721+
int esp_https_ota_get_status_code(esp_https_ota_handle_t https_ota_handle)
722+
{
723+
esp_https_ota_t *handle = (esp_https_ota_t *) https_ota_handle;
724+
if (handle == NULL || handle->http_client == NULL) {
725+
return -1;
726+
}
727+
return esp_http_client_get_status_code(handle->http_client);
728+
}
729+
721730
int esp_https_ota_get_image_len_read(esp_https_ota_handle_t https_ota_handle)
722731
{
723732
esp_https_ota_t *handle = (esp_https_ota_t *)https_ota_handle;

0 commit comments

Comments
 (0)