From ea6e6cfcbd0feda8fe9d664d9790c269adf21964 Mon Sep 17 00:00:00 2001 From: "nilesh.kale" Date: Wed, 6 Nov 2024 14:23:04 +0530 Subject: [PATCH] feat: enabled configurable session resumption support in ota examples This commit added config option to enable session ticket support while performing ota. This helps in optimizing latency while downloading ota over multiple HTTP requests. closes https://github.com/espressif/esp-idf/issues/14783 --- examples/system/ota/advanced_https_ota/main/Kconfig.projbuild | 4 +++- .../ota/advanced_https_ota/main/advanced_https_ota_example.c | 3 +++ examples/system/ota/pre_encrypted_ota/main/Kconfig.projbuild | 4 +++- .../system/ota/pre_encrypted_ota/main/pre_encrypted_ota.c | 3 +++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/examples/system/ota/advanced_https_ota/main/Kconfig.projbuild b/examples/system/ota/advanced_https_ota/main/Kconfig.projbuild index 0b1612451f..3c05c92944 100644 --- a/examples/system/ota/advanced_https_ota/main/Kconfig.projbuild +++ b/examples/system/ota/advanced_https_ota/main/Kconfig.projbuild @@ -31,9 +31,11 @@ menu "Example Configuration" config EXAMPLE_ENABLE_PARTIAL_HTTP_DOWNLOAD bool "Enable partial HTTP download" default n + select ESP_TLS_CLIENT_SESSION_TICKETS help This enables use of Range header in esp_https_ota component. - Firmware image will be downloaded over multiple HTTP requests. + The firmware image will be downloaded over multiple HTTP requests, + with session resumption enabled between them. config EXAMPLE_HTTP_REQUEST_SIZE int "HTTP request size" diff --git a/examples/system/ota/advanced_https_ota/main/advanced_https_ota_example.c b/examples/system/ota/advanced_https_ota/main/advanced_https_ota_example.c index 14054486b2..631e6ac388 100644 --- a/examples/system/ota/advanced_https_ota/main/advanced_https_ota_example.c +++ b/examples/system/ota/advanced_https_ota/main/advanced_https_ota_example.c @@ -129,6 +129,9 @@ void advanced_ota_example_task(void *pvParameter) .cert_pem = (char *)server_cert_pem_start, .timeout_ms = CONFIG_EXAMPLE_OTA_RECV_TIMEOUT, .keep_alive_enable = true, +#ifdef CONFIG_EXAMPLE_ENABLE_PARTIAL_HTTP_DOWNLOAD + .save_client_session = true, +#endif }; #ifdef CONFIG_EXAMPLE_FIRMWARE_UPGRADE_URL_FROM_STDIN diff --git a/examples/system/ota/pre_encrypted_ota/main/Kconfig.projbuild b/examples/system/ota/pre_encrypted_ota/main/Kconfig.projbuild index 18a21ffbb3..bf2e0236c1 100644 --- a/examples/system/ota/pre_encrypted_ota/main/Kconfig.projbuild +++ b/examples/system/ota/pre_encrypted_ota/main/Kconfig.projbuild @@ -31,9 +31,11 @@ menu "Example Configuration" config EXAMPLE_ENABLE_PARTIAL_HTTP_DOWNLOAD bool "Enable partial HTTP download" default n + select ESP_TLS_CLIENT_SESSION_TICKETS help This enables use of Range header in esp_https_ota component. - Firmware image will be downloaded over multiple HTTP requests. + The firmware image will be downloaded over multiple HTTP requests, + with session resumption enabled between them. config EXAMPLE_HTTP_REQUEST_SIZE int "HTTP request size" diff --git a/examples/system/ota/pre_encrypted_ota/main/pre_encrypted_ota.c b/examples/system/ota/pre_encrypted_ota/main/pre_encrypted_ota.c index 599838a2f1..e606b2a1c9 100644 --- a/examples/system/ota/pre_encrypted_ota/main/pre_encrypted_ota.c +++ b/examples/system/ota/pre_encrypted_ota/main/pre_encrypted_ota.c @@ -108,6 +108,9 @@ void pre_encrypted_ota_task(void *pvParameter) .cert_pem = server_cert_pem_start, .timeout_ms = CONFIG_EXAMPLE_OTA_RECV_TIMEOUT, .keep_alive_enable = true, +#ifdef CONFIG_EXAMPLE_ENABLE_PARTIAL_HTTP_DOWNLOAD + .save_client_session = true, +#endif }; esp_decrypt_cfg_t cfg = {}; cfg.rsa_priv_key = rsa_private_pem_start;