From 3c7991813d8a8f47009305a63d7d8d0d422fb8fb Mon Sep 17 00:00:00 2001 From: Shubham Kulkarni Date: Mon, 6 Jul 2020 11:31:57 +0530 Subject: [PATCH 1/2] esp_http_client.h: Add error codes in HttpStatus_Code esp_https_ota.c: Add checks for HTTP error codes Closes: https://github.com/espressif/esp-idf/issues/5537 --- components/esp_http_client/include/esp_http_client.h | 7 ++++++- components/esp_https_ota/src/esp_https_ota.c | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/components/esp_http_client/include/esp_http_client.h b/components/esp_http_client/include/esp_http_client.h index 2857ba919..3ad04b49d 100644 --- a/components/esp_http_client/include/esp_http_client.h +++ b/components/esp_http_client/include/esp_http_client.h @@ -142,7 +142,12 @@ typedef enum { HttpStatus_TemporaryRedirect = 307, /* 4xx - Client Error */ - HttpStatus_Unauthorized = 401 + HttpStatus_Unauthorized = 401, + HttpStatus_Forbidden = 403, + HttpStatus_NotFound = 404, + + /* 5xx - Server Error */ + HttpStatus_InternalError = 500 } HttpStatus_Code; #define ESP_ERR_HTTP_BASE (0x7000) /*!< Starting number of HTTP error codes */ diff --git a/components/esp_https_ota/src/esp_https_ota.c b/components/esp_https_ota/src/esp_https_ota.c index 75fdb9dcb..f5a5150ff 100644 --- a/components/esp_https_ota/src/esp_https_ota.c +++ b/components/esp_https_ota/src/esp_https_ota.c @@ -68,6 +68,12 @@ static esp_err_t _http_handle_response_code(esp_http_client_handle_t http_client } } else if (status_code == HttpStatus_Unauthorized) { esp_http_client_add_auth(http_client); + } else if(status_code == HttpStatus_NotFound || status_code == HttpStatus_Forbidden) { + ESP_LOGE(TAG, "File not found(%d)", status_code); + return ESP_FAIL; + } else if (status_code == HttpStatus_InternalError) { + ESP_LOGE(TAG, "Server error occurred(%d)", status_code); + return ESP_FAIL; } char upgrade_data_buf[DEFAULT_OTA_BUF_SIZE]; From 60fcf1bae654fd064421e2161eeb7e669527be08 Mon Sep 17 00:00:00 2001 From: Shubham Kulkarni Date: Tue, 7 Jul 2020 10:25:25 +0530 Subject: [PATCH 2/2] Increase receive timeout in sdkconfig.ci to fix CI failures --- examples/system/ota/advanced_https_ota/sdkconfig.ci | 2 +- examples/system/ota/native_ota_example/sdkconfig.ci | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/system/ota/advanced_https_ota/sdkconfig.ci b/examples/system/ota/advanced_https_ota/sdkconfig.ci index 577551e00..0edbed76b 100644 --- a/examples/system/ota/advanced_https_ota/sdkconfig.ci +++ b/examples/system/ota/advanced_https_ota/sdkconfig.ci @@ -1,4 +1,4 @@ CONFIG_EXAMPLE_FIRMWARE_UPGRADE_URL="FROM_STDIN" CONFIG_EXAMPLE_SKIP_COMMON_NAME_CHECK=y CONFIG_EXAMPLE_SKIP_VERSION_CHECK=y -CONFIG_EXAMPLE_OTA_RECV_TIMEOUT=2000 +CONFIG_EXAMPLE_OTA_RECV_TIMEOUT=3000 diff --git a/examples/system/ota/native_ota_example/sdkconfig.ci b/examples/system/ota/native_ota_example/sdkconfig.ci index fad2c0a8c..190829198 100644 --- a/examples/system/ota/native_ota_example/sdkconfig.ci +++ b/examples/system/ota/native_ota_example/sdkconfig.ci @@ -1,4 +1,4 @@ CONFIG_EXAMPLE_FIRMWARE_UPG_URL="FROM_STDIN" CONFIG_EXAMPLE_SKIP_COMMON_NAME_CHECK=y CONFIG_EXAMPLE_SKIP_VERSION_CHECK=y -CONFIG_EXAMPLE_OTA_RECV_TIMEOUT=2000 +CONFIG_EXAMPLE_OTA_RECV_TIMEOUT=3000