diff --git a/components/esp_rainmaker/Kconfig.projbuild b/components/esp_rainmaker/Kconfig.projbuild index 2be5f1a..b2e7a94 100644 --- a/components/esp_rainmaker/Kconfig.projbuild +++ b/components/esp_rainmaker/Kconfig.projbuild @@ -135,6 +135,15 @@ menu "ESP RainMaker Config" help This allows you to skip the project name check. + config ESP_RMAKER_OTA_HTTP_RX_BUFFER_SIZE + int "OTA HTTP receive buffer size" + default 1024 + range 512 LWIP_TCP_WND_DEFAULT + help + Increasing this value beyond the default would speed up the OTA download process. + However, please ensure that your application has enough memory headroom to allow this, + else, the OTA may fail. + endmenu menu "ESP RainMaker Scheduling" diff --git a/components/esp_rainmaker/src/ota/esp_rmaker_ota.c b/components/esp_rainmaker/src/ota/esp_rmaker_ota.c index e23da67..80cffd5 100644 --- a/components/esp_rainmaker/src/ota/esp_rmaker_ota.c +++ b/components/esp_rainmaker/src/ota/esp_rmaker_ota.c @@ -28,7 +28,8 @@ static const char *TAG = "esp_rmaker_ota"; #define OTA_REBOOT_TIMER_SEC 10 -#define DEF_HTTP_BUFFER_SIZE 1024 +#define DEF_HTTP_TX_BUFFER_SIZE 1024 +#define DEF_HTTP_RX_BUFFER_SIZE CONFIG_ESP_RMAKER_OTA_HTTP_RX_BUFFER_SIZE extern const char esp_rmaker_ota_def_cert[] asm("_binary_rmaker_ota_server_crt_start"); const char *ESP_RMAKER_OTA_DEFAULT_SERVER_CERT = esp_rmaker_ota_def_cert; @@ -129,7 +130,7 @@ static esp_err_t esp_rmaker_ota_default_cb(esp_rmaker_ota_handle_t ota_handle, e if (!ota_data->url) { return ESP_FAIL; } - int buffer_size_tx = DEF_HTTP_BUFFER_SIZE; + int buffer_size_tx = DEF_HTTP_TX_BUFFER_SIZE; /* In case received url is longer, we will increase the tx buffer size * to accomodate the longer url and other headers. */ @@ -141,7 +142,7 @@ static esp_err_t esp_rmaker_ota_default_cb(esp_rmaker_ota_handle_t ota_handle, e .url = ota_data->url, .cert_pem = ota_data->server_cert, .timeout_ms = 5000, - .buffer_size = DEF_HTTP_BUFFER_SIZE, + .buffer_size = DEF_HTTP_RX_BUFFER_SIZE, .buffer_size_tx = buffer_size_tx }; #ifdef CONFIG_ESP_RMAKER_SKIP_COMMON_NAME_CHECK