From e1a6846ac381a5988b6e9ce580346374954e0754 Mon Sep 17 00:00:00 2001 From: Mahavir Jain Date: Tue, 22 Oct 2019 14:44:05 +0530 Subject: [PATCH] examples/ota: disable WiFi power save mode for optimal performance --- .../main/advanced_https_ota_example.c | 11 +++++++++++ .../ota/native_ota_example/main/native_ota_example.c | 11 +++++++++++ .../ota/simple_ota_example/main/simple_ota_example.c | 11 +++++++++++ 3 files changed, 33 insertions(+) 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 3f05a3f37a..e6b4bd15c8 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 @@ -20,6 +20,10 @@ #include "nvs_flash.h" #include "protocol_examples_common.h" +#if CONFIG_EXAMPLE_CONNECT_WIFI +#include "esp_wifi.h" +#endif + static const char *TAG = "advanced_https_ota_example"; extern const uint8_t server_cert_pem_start[] asm("_binary_ca_cert_pem_start"); extern const uint8_t server_cert_pem_end[] asm("_binary_ca_cert_pem_end"); @@ -130,6 +134,13 @@ void app_main(void) */ ESP_ERROR_CHECK(example_connect()); +#if CONFIG_EXAMPLE_CONNECT_WIFI + /* Ensure to disable any WiFi power save mode, this allows best throughput + * and hence timings for overall OTA operation. + */ + esp_wifi_set_ps(WIFI_PS_NONE); +#endif // CONFIG_EXAMPLE_CONNECT_WIFI + xTaskCreate(&advanced_ota_example_task, "advanced_ota_example_task", 1024 * 8, NULL, 5, NULL); } diff --git a/examples/system/ota/native_ota_example/main/native_ota_example.c b/examples/system/ota/native_ota_example/main/native_ota_example.c index ae885b1676..08b6c9bb62 100644 --- a/examples/system/ota/native_ota_example/main/native_ota_example.c +++ b/examples/system/ota/native_ota_example/main/native_ota_example.c @@ -21,6 +21,10 @@ #include "driver/gpio.h" #include "protocol_examples_common.h" +#if CONFIG_EXAMPLE_CONNECT_WIFI +#include "esp_wifi.h" +#endif + #define BUFFSIZE 1024 #define HASH_LEN 32 /* SHA-256 digest length */ @@ -283,5 +287,12 @@ void app_main(void) */ ESP_ERROR_CHECK(example_connect()); +#if CONFIG_EXAMPLE_CONNECT_WIFI + /* Ensure to disable any WiFi power save mode, this allows best throughput + * and hence timings for overall OTA operation. + */ + esp_wifi_set_ps(WIFI_PS_NONE); +#endif // CONFIG_EXAMPLE_CONNECT_WIFI + xTaskCreate(&ota_example_task, "ota_example_task", 8192, NULL, 5, NULL); } diff --git a/examples/system/ota/simple_ota_example/main/simple_ota_example.c b/examples/system/ota/simple_ota_example/main/simple_ota_example.c index f85186e2b6..494c85f54f 100644 --- a/examples/system/ota/simple_ota_example/main/simple_ota_example.c +++ b/examples/system/ota/simple_ota_example/main/simple_ota_example.c @@ -21,6 +21,10 @@ #include "nvs_flash.h" #include "protocol_examples_common.h" +#if CONFIG_EXAMPLE_CONNECT_WIFI +#include "esp_wifi.h" +#endif + static const char *TAG = "simple_ota_example"; extern const uint8_t server_cert_pem_start[] asm("_binary_ca_cert_pem_start"); extern const uint8_t server_cert_pem_end[] asm("_binary_ca_cert_pem_end"); @@ -117,5 +121,12 @@ void app_main(void) */ ESP_ERROR_CHECK(example_connect()); +#if CONFIG_EXAMPLE_CONNECT_WIFI + /* Ensure to disable any WiFi power save mode, this allows best throughput + * and hence timings for overall OTA operation. + */ + esp_wifi_set_ps(WIFI_PS_NONE); +#endif // CONFIG_EXAMPLE_CONNECT_WIFI + xTaskCreate(&simple_ota_example_task, "ota_example_task", 8192, NULL, 5, NULL); }