Skip to content

Commit

Permalink
Merge branch 'feature/add_api_to_get_last_status_code_logged_during_o…
Browse files Browse the repository at this point in the history
…ta_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
  • Loading branch information
AdityaHPatwardhan committed Sep 23, 2024
2 parents fbf7f2c + 186d534 commit 1f68652
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
15 changes: 15 additions & 0 deletions components/esp_https_ota/include/esp_https_ota.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,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 the HTTP status code of the last HTTP response.
*
* @note This API should be called only after esp_https_ota_begin() has been called.
* This can be used to check the HTTP status code of the OTA download process.
*
* @param[in] https_ota_handle pointer to esp_https_ota_handle_t structure
*
* @return
* - -1 On failure
* - HTTP status code
*/
int esp_https_ota_get_status_code(esp_https_ota_handle_t https_ota_handle);


/**
* @brief This function returns OTA image total size.
*
Expand Down
9 changes: 9 additions & 0 deletions components/esp_https_ota/src/esp_https_ota.c
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,15 @@ esp_err_t esp_https_ota_abort(esp_https_ota_handle_t https_ota_handle)
return err;
}

int esp_https_ota_get_status_code(esp_https_ota_handle_t https_ota_handle)
{
esp_https_ota_t *handle = (esp_https_ota_t *) https_ota_handle;
if (handle == NULL || handle->http_client == NULL) {
return -1;
}
return esp_http_client_get_status_code(handle->http_client);
}

int esp_https_ota_get_image_len_read(esp_https_ota_handle_t https_ota_handle)
{
esp_https_ota_t *handle = (esp_https_ota_t *)https_ota_handle;
Expand Down

0 comments on commit 1f68652

Please sign in to comment.