wifi: allow 5 GHz channels in Monitor - #11375
Open
mikeysklar wants to merge 1 commit into
Open
Conversation
The channel was clamped to 1..13, so dual-band radios could not monitor 5 GHz. Accept 1..165, matching start_scanning_networks(), and check the esp_wifi_set_channel() result: an invalid channel raises ValueError. The setter reuses the constructor's range check, dropping one message. While the station is associated the IDF refuses to move the radio. The monitor then stays on the station's channel and reports it, which is what the old code did without saying so. Fixes adafruit#11339 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Member
|
This looks great. I should be able to do some testing tomorrow. You're right about the channel and RSSI, I had grabbed and modified some simpler old code from when we were developing monitor (rather than my current "production" code), and it wasn't right for the frame structure coming back in RAW. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
wifi.Monitor(channel=)andMonitor.channelaccept 1 to 165. The espressif port raisesValueErrorfor a channel the radio rejects.Why
Fixes #11339. Sibling of #11374 for
start_ap. The 1 to 13 clamp made 5 GHz capture impossible on the ESP32-C5.%q out of boundsleaves the potesp_wifi_set_channel;ESP_ERR_INVALID_ARG->ValueError: Invalid channel, construct undoes promiscuous mode and the queue firstchannelreports it (what the old code did silently)Only espressif implements Monitor; raspberrypi and zephyr-cp are untouched.
Hardware tested
Not tested: other ESP32 variants.
How I tested it
REPL lines below are condensed from scripted runs; outputs are verbatim.
C5, no station, 20 s on channel 149. Home AP beacons carry the right channel and RSSI in the packet dict:
Hop across 1-13, 36-64 and 100-165 at 0.5 s each: no channel rejected in promiscuous mode, no frame tagged with a channel other than the one tuned, 0 lost.
C5 with the station associated on 149:
Metro ESP32-S2, 2.4 GHz only:
Try it
code.pyfor an ESP32-C5, based on the hop script in #11339. Runs as code.py because Monitor state is reset when a REPL session ends.Scope
On #11339 the frame channel and RSSI looked wrong; those values were read from the 802.11 header bytes.
Packet.CHandPacket.RSSIcome from the IDF'srx_ctrland are correct on the C5, whoserx_ctrl.channelis 8 bits.AI assistance
Claude drafted the change and the test scripts. I reviewed the diff, ran every test on the boards above, and checked the IDF headers for the
rx_ctrllayout and theesp_wifi_set_channelcontract.🤖 Generated with Claude Code