wifi: let connect() take a scan result - #11309
Conversation
|
The reason for a I didn't suggest a property necessarily, it could also be an optional arg to EDIT: |
983ad10 to
2bfc75e
Compare
a21a7f8 to
9cdd2d2
Compare
tannewt
left a comment
There was a problem hiding this comment.
Yup, I agree with Dan. This should only impact wifi auto-connect. I think connect can be specific by BSSID or channel already. Channel is especially good because it reduces scan time a ton.
We also considered having connect take a scan result to encapsulate this info. Or maybe ScanResult could have connect() itself.
Passing a Network from start_scanning_networks() uses its bssid and channel, so reaching a specific AP needs no second scan. Replaces the CIRCUITPY_WIFI_BAND settings key, which set the radio band globally.
9cdd2d2 to
e514194
Compare
|
As tannewt suggested
10 trials each (connection time measured in seconds):
Scanning to get the |
Stacked on #11308. Base is
esp32c5-wifi-5ghz, so only the top commit is new here.What
CIRCUITPY_WIFI_BANDinsettings.tomlpins a dual-band radio to one band.2.4WIFI_BAND_MODE_2G_ONLY5WIFI_BAND_MODE_5G_ONLYWIFI_BAND_MODE_AUTONo new public API. Follows the
CIRCUITPY_WIFI_HOSTNAMEprecedent, read viasettings_get_str()and guarded byCIRCUITPY_SETTINGS_TOML.Why
AUTO sorts candidate APs by RSSI, and 2.4 GHz usually wins indoors. One room
from my AP, the same SSID connects on channel 5 rather than 149.
5So on a same-SSID dual-band network there is otherwise no way to reach 5 GHz.
Design question
@dhalbert suggested a runtime property with an enum value such as
BAND_2_4instead, defaulting to 2.4. That is one IDF call here, but it is public API
needing stubs in the raspberrypi and zephyr-cp wifi ports. Happy to do that
instead if it is preferred.
Hardware tested
ESP32-C5-DevKitC-1-N8R8. Scanned channels per setting:
CIRCUITPY_WIFI_BAND2.45zzzTODO: attach the raw REPL transcript for the table above.
AI assistance
Claude wrote the settings lookup and the docs entry. I ran every band trial
and the connect timings on hardware and checked the channel numbers myself.