From bbbc924fcde1f805871aacc38b40293598e3d075 Mon Sep 17 00:00:00 2001 From: Sebastien Date: Sat, 12 Sep 2020 16:05:49 -0400 Subject: [PATCH] Add nvs "wifi_ps" to disable wifi power save mode - release Set disable_ps = n to disable power save mode. This may help with wifi signal stability, but will likely result in a higher power consumption. --- components/wifi-manager/wifi_manager.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/components/wifi-manager/wifi_manager.c b/components/wifi-manager/wifi_manager.c index 9852113b..cfa25efb 100644 --- a/components/wifi-manager/wifi_manager.c +++ b/components/wifi-manager/wifi_manager.c @@ -272,10 +272,18 @@ void wifi_manager_init_wifi(){ ESP_LOGD(TAG, "Initializing wifi. Setting WiFi mode to WIFI_MODE_NULL"); ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_NULL) ); ESP_LOGD(TAG, "Initializing wifi. Starting wifi"); - if (gpio36_39_used) { - ESP_LOGW(TAG, "GPIO 36 or 39 are in use, need to disable WiFi PowerSave!"); - esp_wifi_set_ps(WIFI_PS_NONE); + char * disable_ps = config_alloc_get_default(NVS_TYPE_STR, "disable_ps", "n", 0); + + if (gpio36_39_used || (disable_ps && strcasecmp(disable_ps,"y"))) { + if(gpio36_39_used){ + ESP_LOGW(TAG, "GPIO 36 or 39 are in use, need to disable WiFi PowerSave!"); } + else { + ESP_LOGW(TAG, "wifi powersave config is disabled. Disabling WiFi PowerSave!"); + } + esp_wifi_set_ps(WIFI_PS_NONE); + } + FREE_AND_NULL(disable_ps); ESP_ERROR_CHECK( esp_wifi_start() ); taskYIELD();