Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f5b04b9

Browse filesBrowse files
authored
Use WIFI_FAST_SCAN if a specific channel was used (espressif#5975)
1.0.6 changed scanning method to always scan all available channels during connect. This results in results in connect taking about ~3 seconds instead of ~1. This patch changes the behavior to use WIFI_FAST_SCAN if client used a specific channel.
1 parent 8c5d18d commit f5b04b9
Copy full SHA for f5b04b9

File tree

Expand file treeCollapse file tree

1 file changed

+7
-3
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-3
lines changed

‎libraries/WiFi/src/WiFiSTA.cpp

Copy file name to clipboardExpand all lines: libraries/WiFi/src/WiFiSTA.cpp
+7-3Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,15 +176,19 @@ wl_status_t WiFiSTAClass::begin(const char* ssid, const char *passphrase, int32_
176176
wifi_config_t conf;
177177
memset(&conf, 0, sizeof(wifi_config_t));
178178
_wifi_strncpy(reinterpret_cast<char*>(conf.sta.ssid), ssid, 32);
179-
conf.sta.scan_method = WIFI_ALL_CHANNEL_SCAN; //force full scan to be able to choose the nearest / strongest AP
180179

181180
if(passphrase) {
182181
_wifi_strncpy(reinterpret_cast<char*>(conf.sta.password), passphrase, 64);
183182
}
184183

185-
wifi_config_t current_conf;
186-
wifi_sta_config(&conf, ssid, passphrase, bssid, channel);
184+
if(channel == 0) {
185+
// If no specific channel specified, then do an slower WIFI_ALL_CHANNEL_SCAN
186+
wifi_sta_config(&conf, ssid, passphrase, bssid, channel, WIFI_ALL_CHANNEL_SCAN);
187+
}
188+
else
189+
wifi_sta_config(&conf, ssid, passphrase, bssid, channel, WIFI_FAST_SCAN);
187190

191+
wifi_config_t current_conf;
188192
if(esp_wifi_get_config((wifi_interface_t)ESP_IF_WIFI_STA, &current_conf) != ESP_OK){
189193
log_e("get current config failed!");
190194
return WL_CONNECT_FAILED;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.