wifi.radio.start_ap() new kwarg: max_connections #6022
Merged
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.
This PR is somewhat independent of #5915, though extra internal RAM never hurts. Each Station connection to the Access Point uses an additional ~1.5KB. Even on an ESP32-S2-DevKitC-1-N4R2, A simple AP running with 10 connections should have about 50KB of free espidf memory (a simple AP with no connections has about 65KB free).
This max_connections value was hard-coded to 4 in the released code, which was Espressif's default setting. Now it can go from 0 to 10 (Espressif's full supported range), with default (without the kwarg) remaining at 4. There are use cases for 0; creating an AP to which no connections can be made. An exception is raised for values outside the range.
Although we can't have this many simultaneous sockets (with or without #6021), more Station devices could stay connected to the AP and use UDP or sometimes-connected TCP, assuming they had appropriate exception-handling for when the AP refused the connection.
Tested the 0 case using a phone as Station and got an unable to connect dialog as expected. A CircuitPython device connecting to an AP with
max_connections=0
will get aConnectionError: Unknown failure 205
, which is a general Espressif wifi error code. Progressively tested 8 simultaneous connections on an esp32s3_devkitc_1_n8r2, with 8 separate ESP32-S2 and ESP32-S3 Stations.