diff --git a/libraries/WiFi/src/WiFiSTA.cpp b/libraries/WiFi/src/WiFiSTA.cpp index 00096bde0ee..d91d3d843c2 100644 --- a/libraries/WiFi/src/WiFiSTA.cpp +++ b/libraries/WiFi/src/WiFiSTA.cpp @@ -176,15 +176,19 @@ wl_status_t WiFiSTAClass::begin(const char* ssid, const char *passphrase, int32_ wifi_config_t conf; memset(&conf, 0, sizeof(wifi_config_t)); _wifi_strncpy(reinterpret_cast(conf.sta.ssid), ssid, 32); - conf.sta.scan_method = WIFI_ALL_CHANNEL_SCAN; //force full scan to be able to choose the nearest / strongest AP if(passphrase) { _wifi_strncpy(reinterpret_cast(conf.sta.password), passphrase, 64); } - wifi_config_t current_conf; - wifi_sta_config(&conf, ssid, passphrase, bssid, channel); + if(channel == 0) { + // If no specific channel specified, then do an slower WIFI_ALL_CHANNEL_SCAN + wifi_sta_config(&conf, ssid, passphrase, bssid, channel, WIFI_ALL_CHANNEL_SCAN); + } + else + wifi_sta_config(&conf, ssid, passphrase, bssid, channel, WIFI_FAST_SCAN); + wifi_config_t current_conf; if(esp_wifi_get_config((wifi_interface_t)ESP_IF_WIFI_STA, ¤t_conf) != ESP_OK){ log_e("get current config failed!"); return WL_CONNECT_FAILED;