Skip to content

Commit a80bf22

Browse files
authored
Merge pull request #3727 from BennyE/wifi-full-scan
esp32s2: Do a full scan when channel/BSSID are not given
2 parents f8dcb25 + 2773f53 commit a80bf22

File tree

1 file changed

+7
-0
lines changed
  • ports/esp32s2/common-hal/wifi

1 file changed

+7
-0
lines changed

ports/esp32s2/common-hal/wifi/Radio.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,13 @@ wifi_radio_error_t common_hal_wifi_radio_connect(wifi_radio_obj_t *self, uint8_t
142142
} else {
143143
config->sta.bssid_set = 0;
144144
}
145+
// If channel is 0 (default/unset) and BSSID is not given, do a full scan instead of fast scan
146+
// This will ensure that the best AP in range is chosen automatically
147+
if ((config->sta.bssid_set == 0) && (config->sta.channel == 0)) {
148+
config->sta.scan_method = WIFI_ALL_CHANNEL_SCAN;
149+
} else {
150+
config->sta.scan_method = WIFI_FAST_SCAN;
151+
}
145152
esp_wifi_set_config(ESP_IF_WIFI_STA, config);
146153
self->starting_retries = 5;
147154
self->retries_left = 5;

0 commit comments

Comments
 (0)