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.
9cdd2d2 to
e514194
Compare
|
As tannewt suggested
10 trials each (connection time measured in seconds):
Scanning to get the |
e514194 to
e3bffa9
Compare
2bfc75e to
acb9559
Compare
e3bffa9 to
44362cf
Compare
Passing a Network from start_scanning_networks() uses its bssid and channel, so reaching a specific AP needs no second scan. Gated behind CIRCUITPY_WIFI_CONNECT_NETWORK, on by default. The nRF7002 DK runs from 1MB of internal flash with under 800 bytes free and overflowed by 32, so it opts out in its circuitpython.toml the way it already does for ulab and radio.ping(). Costs 64 bytes, measured on the ESP32-C5.
acb9559 to
117fa80
Compare
44362cf to
8f8697e
Compare
tannewt
left a comment
There was a problem hiding this comment.
Thanks for these changes. I'd rather have a new network kwarg with it's own comment about what it does.
Is there any way to shrink the 7002 instead? I'd rather not have this not on every board.
connect() takes a network= keyword instead of accepting a Network in the ssid slot. ssid is now optional, network is keyword only, and passing both raises TypeError. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Passing both Tested on the ESP32-C5-DevKitC-1-N8R8,
Yes on the 7002. It reserves a 32 KB |
adafruit#11335 gave the nRF7002 DK the flash it needed, so every board gets connect(network=). Removes CIRCUITPY_WIFI_CONNECT_NETWORK. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Stacked on #11308. Base is
esp32c5-wifi-5ghz, so only the top commit is new here.Body updated: this replaces an earlier
CIRCUITPY_WIFI_BANDdesign, discussed above.What
connect()accepts aNetworkfromstart_scanning_networks()and uses itsbssid and channel, so reaching a specific AP needs no second scan.
Why
On a same-SSID dual-band network an unqualified
connect()lands on 2.4 GHz.Passing the scan result reaches the 5 GHz AP without scanning twice.
Hardware tested
ESP32-C5-DevKitC-1-N8R8,
10.3.0-45-ge3bffa92b4. Connect timings, 10 trialseach, are in the comment below.
AI assistance
Claude wrote the overload and the docstring. I ran the connect timings on
hardware and checked the channel numbers myself.