Skip to content

Use WIFI_FAST_SCAN if a specific channel was used #5975

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions libraries/WiFi/src/WiFiSTA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<char*>(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<char*>(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, &current_conf) != ESP_OK){
log_e("get current config failed!");
return WL_CONNECT_FAILED;
Expand Down