Skip to content

Commit fe47676

Browse files
Merge branch 'feature/add_api_to_get_last_status_code_logged_during_ota' into 'master'
feat(esp_https_ota): added API to get last status code logged from http resonse Closes IDFGH-13394 See merge request espressif/esp-idf!33356
2 parents 794c604 + 70d4414 commit fe47676

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
@@ -239,6 +239,21 @@ esp_err_t esp_https_ota_get_img_desc(esp_https_ota_handle_t https_ota_handle, es
239239
int esp_https_ota_get_image_len_read(esp_https_ota_handle_t https_ota_handle);
240240

241241

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

components/esp_https_ota/src/esp_https_ota.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,15 @@ esp_err_t esp_https_ota_abort(esp_https_ota_handle_t https_ota_handle)
724724
return err;
725725
}
726726

727+
int esp_https_ota_get_status_code(esp_https_ota_handle_t https_ota_handle)
728+
{
729+
esp_https_ota_t *handle = (esp_https_ota_t *) https_ota_handle;
730+
if (handle == NULL || handle->http_client == NULL) {
731+
return -1;
732+
}
733+
return esp_http_client_get_status_code(handle->http_client);
734+
}
735+
727736
int esp_https_ota_get_image_len_read(esp_https_ota_handle_t https_ota_handle)
728737
{
729738
esp_https_ota_t *handle = (esp_https_ota_t *)https_ota_handle;

0 commit comments

Comments
 (0)