Skip to content

Commit b4490cd

Browse files
committed
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
1 parent a14ac2c commit b4490cd

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp

+13-11
Original file line numberDiff line numberDiff line change
@@ -134,26 +134,28 @@ wl_status_t ESP8266WiFiSTAClass::begin(const char* ssid, const char *passphrase,
134134
wifi_station_get_config(&current_conf);
135135
if(sta_config_equal(current_conf, conf)) {
136136
DEBUGV("sta config unchanged");
137-
return status();
138137
}
138+
else {
139+
ETS_UART_INTR_DISABLE();
139140

140-
ETS_UART_INTR_DISABLE();
141+
if(WiFi._persistent) {
142+
// workaround for #1997: make sure the value of ap_number is updated and written to flash
143+
// to be removed after SDK update
144+
wifi_station_ap_number_set(2);
145+
wifi_station_ap_number_set(1);
141146

142-
if(WiFi._persistent) {
143-
// workaround for #1997: make sure the value of ap_number is updated and written to flash
144-
// to be removed after SDK update
145-
wifi_station_ap_number_set(2);
146-
wifi_station_ap_number_set(1);
147+
wifi_station_set_config(&conf);
148+
} else {
149+
wifi_station_set_config_current(&conf);
150+
}
147151

148-
wifi_station_set_config(&conf);
149-
} else {
150-
wifi_station_set_config_current(&conf);
152+
ETS_UART_INTR_ENABLE();
151153
}
152154

155+
ETS_UART_INTR_DISABLE();
153156
if(connect) {
154157
wifi_station_connect();
155158
}
156-
157159
ETS_UART_INTR_ENABLE();
158160

159161
if(channel > 0 && channel <= 13) {

0 commit comments

Comments
 (0)