From 9ec02af1732437693913e0e108380c796520d078 Mon Sep 17 00:00:00 2001 From: Fritz Elfert Date: Wed, 19 Oct 2022 21:00:07 +0200 Subject: [PATCH] Improve OTA error handling --- components/esp_https_ota/src/esp_https_ota.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/components/esp_https_ota/src/esp_https_ota.c b/components/esp_https_ota/src/esp_https_ota.c index d326c2bea..6da7a918a 100644 --- a/components/esp_https_ota/src/esp_https_ota.c +++ b/components/esp_https_ota/src/esp_https_ota.c @@ -64,6 +64,13 @@ esp_err_t esp_https_ota(const esp_http_client_config_t *config) } esp_http_client_fetch_headers(client); + int http_status = esp_http_client_get_status_code(client); + if (400 <= http_status) { + ESP_LOGE(TAG, "HTTP request returned error %d", http_status); + http_cleanup(client); + return ESP_FAIL; + } + esp_ota_handle_t update_handle = 0; const esp_partition_t *update_partition = NULL; ESP_LOGI(TAG, "Starting OTA...");