Skip to content

Commit 73cd8d7

Browse files
Stefano-Orsolinime-no-dev
authored andcommitted
set max clients from code (espressif#432)
* Update WiFiAP.cpp set from code the maximum number of clients to smaller than 4 (in my case i must allow only one client at a time) * Update WiFiAP.h * Update WiFiAP.cpp * Update WiFiAP.cpp * Create WiFiAP.cpp
1 parent 4d47dea commit 73cd8d7

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

libraries/WiFi/src/WiFiAP.cpp

+11-7
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ static bool softap_config_equal(const wifi_config_t& lhs, const wifi_config_t& r
6969
if(lhs.ap.ssid_hidden != rhs.ap.ssid_hidden) {
7070
return false;
7171
}
72+
if(lhs.ap.max_connection != rhs.ap.max_connection) {
73+
return false;
74+
}
7275
return true;
7376
}
7477

@@ -79,12 +82,13 @@ static bool softap_config_equal(const wifi_config_t& lhs, const wifi_config_t& r
7982

8083
/**
8184
* Set up an access point
82-
* @param ssid Pointer to the SSID (max 63 char).
83-
* @param passphrase (for WPA2 min 8 char, for open use NULL)
84-
* @param channel WiFi channel number, 1 - 13.
85-
* @param ssid_hidden Network cloaking (0 = broadcast SSID, 1 = hide SSID)
86-
*/
87-
bool WiFiAPClass::softAP(const char* ssid, const char* passphrase, int channel, int ssid_hidden)
85+
* @param ssid Pointer to the SSID (max 63 char).
86+
* @param passphrase (for WPA2 min 8 char, for open use NULL)
87+
* @param channel WiFi channel number, 1 - 13.
88+
* @param ssid_hidden Network cloaking (0 = broadcast SSID, 1 = hide SSID)
89+
* @param max_connection Max simultaneous connected clients, 1 - 4.
90+
*/
91+
bool WiFiAPClass::softAP(const char* ssid, const char* passphrase, int channel, int ssid_hidden, int max_connection)
8892
{
8993

9094
if(!WiFi.enableAP(true)) {
@@ -109,7 +113,7 @@ bool WiFiAPClass::softAP(const char* ssid, const char* passphrase, int channel,
109113
conf.ap.channel = channel;
110114
conf.ap.ssid_len = strlen(ssid);
111115
conf.ap.ssid_hidden = ssid_hidden;
112-
conf.ap.max_connection = 4;
116+
conf.ap.max_connection = max_connection;
113117
conf.ap.beacon_interval = 100;
114118

115119
if(!passphrase || strlen(passphrase) == 0) {

libraries/WiFi/src/WiFiAP.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class WiFiAPClass
3737

3838
public:
3939

40-
bool softAP(const char* ssid, const char* passphrase = NULL, int channel = 1, int ssid_hidden = 0);
40+
bool softAP(const char* ssid, const char* passphrase = NULL, int channel = 1, int ssid_hidden = 0, int max_connection = 4);
4141
bool softAPConfig(IPAddress local_ip, IPAddress gateway, IPAddress subnet);
4242
bool softAPdisconnect(bool wifioff = false);
4343

0 commit comments

Comments
 (0)