set max clients from code (#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
This commit is contained in:
SO_yeah 2017-06-14 10:14:14 +02:00 committed by Me No Dev
parent 4d47deab24
commit 73cd8d7f7e
2 changed files with 12 additions and 8 deletions

View File

@ -69,6 +69,9 @@ static bool softap_config_equal(const wifi_config_t& lhs, const wifi_config_t& r
if(lhs.ap.ssid_hidden != rhs.ap.ssid_hidden) {
return false;
}
if(lhs.ap.max_connection != rhs.ap.max_connection) {
return false;
}
return true;
}
@ -83,8 +86,9 @@ static bool softap_config_equal(const wifi_config_t& lhs, const wifi_config_t& r
* @param passphrase (for WPA2 min 8 char, for open use NULL)
* @param channel WiFi channel number, 1 - 13.
* @param ssid_hidden Network cloaking (0 = broadcast SSID, 1 = hide SSID)
* @param max_connection Max simultaneous connected clients, 1 - 4.
*/
bool WiFiAPClass::softAP(const char* ssid, const char* passphrase, int channel, int ssid_hidden)
bool WiFiAPClass::softAP(const char* ssid, const char* passphrase, int channel, int ssid_hidden, int max_connection)
{
if(!WiFi.enableAP(true)) {
@ -109,7 +113,7 @@ bool WiFiAPClass::softAP(const char* ssid, const char* passphrase, int channel,
conf.ap.channel = channel;
conf.ap.ssid_len = strlen(ssid);
conf.ap.ssid_hidden = ssid_hidden;
conf.ap.max_connection = 4;
conf.ap.max_connection = max_connection;
conf.ap.beacon_interval = 100;
if(!passphrase || strlen(passphrase) == 0) {

View File

@ -37,7 +37,7 @@ class WiFiAPClass
public:
bool softAP(const char* ssid, const char* passphrase = NULL, int channel = 1, int ssid_hidden = 0);
bool softAP(const char* ssid, const char* passphrase = NULL, int channel = 1, int ssid_hidden = 0, int max_connection = 4);
bool softAPConfig(IPAddress local_ip, IPAddress gateway, IPAddress subnet);
bool softAPdisconnect(bool wifioff = false);