Merge pull request #3727 from BennyE/wifi-full-scan

esp32s2: Do a full scan when channel/BSSID are not given
This commit is contained in:
Scott Shawcroft 2020-11-23 15:19:57 -08:00 committed by GitHub
commit a80bf22211
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 0 deletions

View File

@ -142,6 +142,13 @@ wifi_radio_error_t common_hal_wifi_radio_connect(wifi_radio_obj_t *self, uint8_t
} else {
config->sta.bssid_set = 0;
}
// If channel is 0 (default/unset) and BSSID is not given, do a full scan instead of fast scan
// This will ensure that the best AP in range is chosen automatically
if ((config->sta.bssid_set == 0) && (config->sta.channel == 0)) {
config->sta.scan_method = WIFI_ALL_CHANNEL_SCAN;
} else {
config->sta.scan_method = WIFI_FAST_SCAN;
}
esp_wifi_set_config(ESP_IF_WIFI_STA, config);
self->starting_retries = 5;
self->retries_left = 5;