From 0ea9ea4447ab665d0884788292b1ee1ed7b2a221 Mon Sep 17 00:00:00 2001 From: Clemens Kirchgatterer Date: Mon, 14 May 2018 12:59:59 +0200 Subject: [PATCH] Fix WiFi.persistent(false); having no effect. (#1406) This PR calls `esp_wifi_set_storage(WIFI_STORAGE_RAM);` when persistent WiFi configuration is not desired. --- libraries/WiFi/src/WiFiGeneric.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/libraries/WiFi/src/WiFiGeneric.cpp b/libraries/WiFi/src/WiFiGeneric.cpp index 3ba6aae6..82f8087c 100644 --- a/libraries/WiFi/src/WiFiGeneric.cpp +++ b/libraries/WiFi/src/WiFiGeneric.cpp @@ -108,7 +108,7 @@ void tcpipInit(){ } } -static bool wifiLowLevelInit(){ +static bool wifiLowLevelInit(bool persistent){ static bool lowLevelInitDone = false; if(!lowLevelInitDone){ tcpipInit(); @@ -118,7 +118,9 @@ static bool wifiLowLevelInit(){ log_e("esp_wifi_init %d", err); return false; } - esp_wifi_set_storage(WIFI_STORAGE_FLASH); + if(!persistent){ + esp_wifi_set_storage(WIFI_STORAGE_RAM); + } esp_wifi_set_mode(WIFI_MODE_NULL); lowLevelInitDone = true; } @@ -133,11 +135,11 @@ static bool wifiLowLevelDeinit(){ static bool _esp_wifi_started = false; -static bool espWiFiStart(){ +static bool espWiFiStart(bool persistent){ if(_esp_wifi_started){ return true; } - if(!wifiLowLevelInit()){ + if(!wifiLowLevelInit(persistent)){ return false; } esp_err_t err = esp_wifi_start(); @@ -383,7 +385,7 @@ bool WiFiGenericClass::mode(wifi_mode_t m) return false; } if(m){ - return espWiFiStart(); + return espWiFiStart(_persistent); } return espWiFiStop(); } @@ -394,7 +396,7 @@ bool WiFiGenericClass::mode(wifi_mode_t m) */ wifi_mode_t WiFiGenericClass::getMode() { - if(!wifiLowLevelInit()){ + if(!wifiLowLevelInit(_persistent)){ return WIFI_MODE_MAX; } uint8_t mode;