From b4490cd76d75ebcbc582f8fbcac9a83edf0fa84d Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Tue, 14 Jun 2016 13:07:08 +0800 Subject: [PATCH] Fix issue when WiFi.begin(ssid, pass) is called right after WiFi.mode(WIFI_OFF) If ssid and pass matched the values in flash, wifi_station_connect was not called and no connection was attempted --- libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp | 30 +++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp b/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp index 918866727..b526f2043 100644 --- a/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp +++ b/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp @@ -134,26 +134,28 @@ wl_status_t ESP8266WiFiSTAClass::begin(const char* ssid, const char *passphrase, wifi_station_get_config(¤t_conf); if(sta_config_equal(current_conf, conf)) { DEBUGV("sta config unchanged"); - return status(); + } + else { + ETS_UART_INTR_DISABLE(); + + if(WiFi._persistent) { + // workaround for #1997: make sure the value of ap_number is updated and written to flash + // to be removed after SDK update + wifi_station_ap_number_set(2); + wifi_station_ap_number_set(1); + + wifi_station_set_config(&conf); + } else { + wifi_station_set_config_current(&conf); + } + + ETS_UART_INTR_ENABLE(); } ETS_UART_INTR_DISABLE(); - - if(WiFi._persistent) { - // workaround for #1997: make sure the value of ap_number is updated and written to flash - // to be removed after SDK update - wifi_station_ap_number_set(2); - wifi_station_ap_number_set(1); - - wifi_station_set_config(&conf); - } else { - wifi_station_set_config_current(&conf); - } - if(connect) { wifi_station_connect(); } - ETS_UART_INTR_ENABLE(); if(channel > 0 && channel <= 13) {