From 62eb1587a1c1a24210ba673b166d74953a7d4c69 Mon Sep 17 00:00:00 2001 From: yuanjm Date: Wed, 14 Aug 2019 15:57:25 +0800 Subject: [PATCH] feat(http): Add Kconfig for user to configure HTTP buffer and ota buffer size --- components/esp_http_client/Kconfig | 8 ++++++++ components/esp_http_client/include/esp_http_client.h | 2 +- components/esp_https_ota/Kconfig | 12 ++++++++++++ components/esp_https_ota/src/esp_https_ota.c | 3 ++- 4 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 components/esp_https_ota/Kconfig diff --git a/components/esp_http_client/Kconfig b/components/esp_http_client/Kconfig index f4e1d1b0..755ec6bd 100644 --- a/components/esp_http_client/Kconfig +++ b/components/esp_http_client/Kconfig @@ -7,4 +7,12 @@ config ESP_HTTP_CLIENT_ENABLE_HTTPS help This option will enable https protocol by linking mbedtls library and initializing SSL transport +config HTTP_BUF_SIZE + int "Default HTTP Buffer Size (both send and receive)" + default 512 + range 512 1460 + help + Set HTTP Buffer Size. The larger buffer size will make send and receive more size packet once. + + endmenu diff --git a/components/esp_http_client/include/esp_http_client.h b/components/esp_http_client/include/esp_http_client.h index 4e940a6d..a1bba70f 100644 --- a/components/esp_http_client/include/esp_http_client.h +++ b/components/esp_http_client/include/esp_http_client.h @@ -24,7 +24,7 @@ extern "C" { #endif -#define DEFAULT_HTTP_BUF_SIZE (512) +#define DEFAULT_HTTP_BUF_SIZE CONFIG_HTTP_BUF_SIZE typedef struct esp_http_client *esp_http_client_handle_t; typedef struct esp_http_client_event *esp_http_client_event_handle_t; diff --git a/components/esp_https_ota/Kconfig b/components/esp_https_ota/Kconfig new file mode 100644 index 00000000..66592d97 --- /dev/null +++ b/components/esp_https_ota/Kconfig @@ -0,0 +1,12 @@ +menu "ESP HTTPS OTA" + +config OTA_BUF_SIZE + int "Default OTA Buffer Size" + default 256 + range 256 1460 + help + Set OTA Buffer Size. The larger buffer size will read more size packet once and can reduce upgrade cost time. + This buffer size depends on CONFIG_HTTP_BUF_SIZE. If you want to enlarge ota buffer size, please also enlarge CONFIG_HTTP_BUF_SIZE. + OTA_BUF_SIZE equals to 1460 can save 40% upgrade time in contrast to OTA_BUF_SIZE which equals to 256. + +endmenu diff --git a/components/esp_https_ota/src/esp_https_ota.c b/components/esp_https_ota/src/esp_https_ota.c index 2a96ba81..2f04d9b7 100644 --- a/components/esp_https_ota/src/esp_https_ota.c +++ b/components/esp_https_ota/src/esp_https_ota.c @@ -18,8 +18,9 @@ #include #include #include +#include "sdkconfig.h" -#define OTA_BUF_SIZE 256 +#define OTA_BUF_SIZE CONFIG_OTA_BUF_SIZE static const char *TAG = "esp_https_ota"; static void http_cleanup(esp_http_client_handle_t client)