Skip to content

Commit c4f8990

Browse files
authored
Merge pull request #9 from sandeepmistry/faster-connect
Use WIFI_FAST_SCAN for connection instead of WIFI_ALL_CHANNEL_SCAN
2 parents a55c66a + 3e8d790 commit c4f8990

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

arduino/libraries/WiFi/src/WiFi.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ uint8_t WiFiClass::begin(const char* ssid, const char* key)
172172
memset(&wifiConfig, 0x00, sizeof(wifiConfig));
173173
strncpy((char*)wifiConfig.sta.ssid, ssid, sizeof(wifiConfig.sta.ssid));
174174
strncpy((char*)wifiConfig.sta.password, key, sizeof(wifiConfig.sta.password));
175-
wifiConfig.sta.scan_method = WIFI_ALL_CHANNEL_SCAN;
175+
wifiConfig.sta.scan_method = WIFI_FAST_SCAN;
176176
_status = WL_NO_SSID_AVAIL;
177177

178178
_interface = ESP_IF_WIFI_STA;
@@ -644,8 +644,11 @@ void WiFiClass::handleSystemEvent(system_event_t* event)
644644

645645
memset(&_apRecord, 0x00, sizeof(_apRecord));
646646

647-
if (reason == 201/*NO_AP_FOUND*/ || reason == 202/*AUTH_FAIL*/ || reason == 203/*ASSOC_FAIL*/) {
647+
if (reason == 201/*NO_AP_FOUND*/ || reason == 202/*AUTH_FAIL*/) {
648648
_status = WL_CONNECT_FAILED;
649+
} else if (reason == 203/*ASSOC_FAIL*/) {
650+
// try to reconnect
651+
esp_wifi_connect();
649652
} else {
650653
_status = WL_DISCONNECTED;
651654
}

0 commit comments

Comments
 (0)