Skip to content

Fix WiFi.persistent(false); having no effect. #1406

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 14, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions libraries/WiFi/src/WiFiGeneric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void tcpipInit(){
}
}

static bool wifiLowLevelInit(){
static bool wifiLowLevelInit(bool persistent){
static bool lowLevelInitDone = false;
if(!lowLevelInitDone){
tcpipInit();
Expand All @@ -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;
}
Expand All @@ -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();
Expand Down Expand Up @@ -383,7 +385,7 @@ bool WiFiGenericClass::mode(wifi_mode_t m)
return false;
}
if(m){
return espWiFiStart();
return espWiFiStart(_persistent);
}
return espWiFiStop();
}
Expand All @@ -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;
Expand Down