Skip to content

Commit

Permalink
Bugfix/persistentchecks (esp8266#3798)
Browse files Browse the repository at this point in the history
* persistent check fixes

fixes assumtions that persistent matches current configs, and prevents changes when such conditions exist

* oops

* fix code compliance block scoping

(cherry picked from commit 0643d6e)
  • Loading branch information
tablatronix authored and bryceschober committed Apr 5, 2018
1 parent bcac411 commit b4e415b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
12 changes: 9 additions & 3 deletions libraries/ESP8266WiFi/src/ESP8266WiFiAP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,15 @@ bool ESP8266WiFiAPClass::softAP(const char* ssid, const char* passphrase, int ch
strcpy(reinterpret_cast<char*>(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) {
Expand Down
6 changes: 5 additions & 1 deletion libraries/ESP8266WiFi/src/ESP8266WiFiGeneric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,11 @@ bool ESP8266WiFiGenericClass::getPersistent(){
* @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;
}

Expand Down
12 changes: 9 additions & 3 deletions libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,15 @@ wl_status_t ESP8266WiFiSTAClass::begin(const char* ssid, const char *passphrase,
conf.bssid_set = 0;
}

struct station_config current_conf;
wifi_station_get_config(&current_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 {
Expand Down

0 comments on commit b4e415b

Please sign in to comment.