From d804408f0ee78f9b344581c770c6f7d52335ce3e Mon Sep 17 00:00:00 2001 From: Shawn A Date: Sat, 4 Nov 2017 19:58:25 -0500 Subject: [PATCH 1/3] persistent check fixes fixes assumtions that persistent matches current configs, and prevents changes when such conditions exist --- libraries/ESP8266WiFi/src/ESP8266WiFiAP.cpp | 8 +++++--- libraries/ESP8266WiFi/src/ESP8266WiFiGeneric.cpp | 6 +++++- libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp | 8 +++++--- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/libraries/ESP8266WiFi/src/ESP8266WiFiAP.cpp b/libraries/ESP8266WiFi/src/ESP8266WiFiAP.cpp index a424eece10..84072b668d 100644 --- a/libraries/ESP8266WiFi/src/ESP8266WiFiAP.cpp +++ b/libraries/ESP8266WiFi/src/ESP8266WiFiAP.cpp @@ -123,9 +123,11 @@ bool ESP8266WiFiAPClass::softAP(const char* ssid, const char* passphrase, int ch strcpy(reinterpret_cast(conf.password), passphrase); } - struct softap_config conf_current; - wifi_softap_get_config(&conf_current); - if(!softap_config_equal(conf, conf_current)) { + struct softap_config conf_compare; + if(WiFi.persistent) wifi_softap_get_config_default(&conf_compare); + else wifi_softap_get_config(&conf_compare); + + if(!softap_config_equal(conf, conf_compare)) { ETS_UART_INTR_DISABLE(); if(WiFi._persistent) { diff --git a/libraries/ESP8266WiFi/src/ESP8266WiFiGeneric.cpp b/libraries/ESP8266WiFi/src/ESP8266WiFiGeneric.cpp index 7b90dc310f..4a6741f097 100644 --- a/libraries/ESP8266WiFi/src/ESP8266WiFiGeneric.cpp +++ b/libraries/ESP8266WiFi/src/ESP8266WiFiGeneric.cpp @@ -309,7 +309,11 @@ void ESP8266WiFiGenericClass::persistent(bool persistent) { * @param m WiFiMode_t */ bool ESP8266WiFiGenericClass::mode(WiFiMode_t m) { - if(wifi_get_opmode() == (uint8) m) { + if(_persistent){ + if(wifi_get_opmode() == (uint8) m && wifi_get_opmode_default() == (uint8) m){ + return true; + } + } else if(wifi_get_opmode() == (uint8) m){ return true; } diff --git a/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp b/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp index 136a60300c..828ad35ea9 100644 --- a/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp +++ b/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp @@ -131,9 +131,11 @@ wl_status_t ESP8266WiFiSTAClass::begin(const char* ssid, const char *passphrase, conf.bssid_set = 0; } - struct station_config current_conf; - wifi_station_get_config(¤t_conf); - if(sta_config_equal(current_conf, conf)) { + struct station_config conf_compare; + if(WiFi.persistent) wifi_station_get_config_default(&conf_compare); + else wifi_station_get_config(&conf_compare); + + if(sta_config_equal(conf_compare, conf)) { DEBUGV("sta config unchanged"); } else { From cb5d5140a8e3bcb8af4c88d4a75911f1ea0dad32 Mon Sep 17 00:00:00 2001 From: Shawn A Date: Sat, 4 Nov 2017 20:02:58 -0500 Subject: [PATCH 2/3] oops --- libraries/ESP8266WiFi/src/ESP8266WiFiAP.cpp | 2 +- libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/ESP8266WiFi/src/ESP8266WiFiAP.cpp b/libraries/ESP8266WiFi/src/ESP8266WiFiAP.cpp index 84072b668d..46e1193f37 100644 --- a/libraries/ESP8266WiFi/src/ESP8266WiFiAP.cpp +++ b/libraries/ESP8266WiFi/src/ESP8266WiFiAP.cpp @@ -124,7 +124,7 @@ bool ESP8266WiFiAPClass::softAP(const char* ssid, const char* passphrase, int ch } struct softap_config conf_compare; - if(WiFi.persistent) wifi_softap_get_config_default(&conf_compare); + if(WiFi._persistent) wifi_softap_get_config_default(&conf_compare); else wifi_softap_get_config(&conf_compare); if(!softap_config_equal(conf, conf_compare)) { diff --git a/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp b/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp index 828ad35ea9..4b1c5f29ce 100644 --- a/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp +++ b/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp @@ -132,7 +132,7 @@ wl_status_t ESP8266WiFiSTAClass::begin(const char* ssid, const char *passphrase, } struct station_config conf_compare; - if(WiFi.persistent) wifi_station_get_config_default(&conf_compare); + if(WiFi._persistent) wifi_station_get_config_default(&conf_compare); else wifi_station_get_config(&conf_compare); if(sta_config_equal(conf_compare, conf)) { From c2048d8f0e875177f8f12e0c30ee15750db2c142 Mon Sep 17 00:00:00 2001 From: Shawn A Date: Tue, 27 Feb 2018 10:19:29 -0600 Subject: [PATCH 3/3] fix code compliance block scoping --- libraries/ESP8266WiFi/src/ESP8266WiFiAP.cpp | 8 ++++++-- libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/libraries/ESP8266WiFi/src/ESP8266WiFiAP.cpp b/libraries/ESP8266WiFi/src/ESP8266WiFiAP.cpp index c5bab377b9..42d951cb8f 100644 --- a/libraries/ESP8266WiFi/src/ESP8266WiFiAP.cpp +++ b/libraries/ESP8266WiFi/src/ESP8266WiFiAP.cpp @@ -130,8 +130,12 @@ bool ESP8266WiFiAPClass::softAP(const char* ssid, const char* passphrase, int ch } struct softap_config conf_compare; - if(WiFi._persistent) wifi_softap_get_config_default(&conf_compare); - else wifi_softap_get_config(&conf_compare); + if(WiFi._persistent){ + wifi_softap_get_config_default(&conf_compare); + } + else { + wifi_softap_get_config(&conf_compare); + } if(!softap_config_equal(conf, conf_compare)) { diff --git a/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp b/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp index 9c14961298..35892e2d96 100644 --- a/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp +++ b/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp @@ -132,8 +132,12 @@ wl_status_t ESP8266WiFiSTAClass::begin(const char* ssid, const char *passphrase, } struct station_config conf_compare; - if(WiFi._persistent) wifi_station_get_config_default(&conf_compare); - else wifi_station_get_config(&conf_compare); + if(WiFi._persistent){ + wifi_station_get_config_default(&conf_compare); + } + else { + wifi_station_get_config(&conf_compare); + } if(sta_config_equal(conf_compare, conf)) { DEBUGV("sta config unchanged");