esp32/network_wlan: Add channel bandwidth configuration parameter.#19260
Open
agatti wants to merge 1 commit into
Open
esp32/network_wlan: Add channel bandwidth configuration parameter.#19260agatti wants to merge 1 commit into
agatti wants to merge 1 commit into
Conversation
This commit adds a configuration parameter to set and retrieve the WiFi channel bandwidth. The configuration only applies when the adapter is in single-band mode (ie. either 2.4 GHz or 5 GHz, not both at the same time), which is not an issue at the moment since there's no provision to put the adapter in multi-band mode. Rather than accepting the bandwidth as a raw MHz value, five new constants are introduced, following the same nomenclature as the ESP-IDF SDK. This is required since there's one constant that indicates a multi-antenna bandwidth setup and therefore not representable as a single integer value. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
|
Code size report: |
Contributor
Author
|
A size increase of 1.5KiB is actually a lot for such a simple change :( Should this be put behind a define, or just scrapped? I wouldn't say it's a critical feature after all. |
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.
Summary
This commit adds a configuration parameter to set and retrieve the WiFi channel bandwidth.
The configuration only applies when the adapter is in single-band mode (ie. either 2.4 GHz or 5 GHz, not both at the same time), which is not an issue at the moment since there's no provision to put the adapter in multi-band mode.
Rather than accepting the bandwidth as a raw MHz value, five new constants are introduced, following the same nomenclature as the ESP-IDF SDK. This is required since there's one constant that indicates a multi-antenna bandwidth setup and therefore not representable as a single integer value.
All constants involved are present in ESP-IDF 5.3 and later.
This addresses #6036.
Testing
Network connectivity tests were performed on ESP32, ESP32C3, and ESP32S3, checking whether changing bandwidth between 20MHz and 40MHz would not impact connection in STA mode, and whether a bandwidth change in AP mode would be reported by a network analyser running on a phone.
On older boards, setting constants above 40MHz may not trigger an error but automatically cap bandwidth to either 20MHz or 40MHz depending on the board.
The firmware was also built for ESP32P4 to make sure this feature should not be gated behind a define in hosted mode.
Trade-offs and Alternatives
There's a small size increase, but that cannot really be avoided. The fact that there's one bandwidth setting for multi-antenna setups also forces usage of constants.
The constant names could probably be more descriptive, like
WLAN.BANDWIDTH_20rather thanWLAN.BW20, but I followed the SDK here and shorter names mean taking up less space. If more descriptive constant names are preferred, changing them is not a problem.Generative AI
I did not use generative AI tools when creating this PR.
I originally planned to also support multi-mode WiFi since a supported target has it (ESP32C5), but then I realised there's no way to set the adapter into multi-mode to begin with. That requires some minor changes to protocol, channel, and bandwidth retrieval/setting procedures.
I can add multi-mode support and apply the necessary changes in another PR but somebody else has to test it as I do not have the suitable hardware (although I can make sure it builds :)) and put that behind a define if multi-mode is not available on the target.