1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-19 23:22:16 +03:00

set max_connection from code (when less than 4 is needed) (#2326)

* Update ESP8266WiFiAP.cpp

It is not very common but some might require to set the maximum number of clients, from code, to smaller than 4.
in my case i must allow only one client at a time (TESTED WORKING)

* Update ESP8266WiFiAP.h

as discussed in the .cpp (set max connections)

* Update ESP8266WiFiAP.cpp

corrected indentation @70 
add param comment @86

* Update ESP8266WiFiAP.cpp
This commit is contained in:
Stefano-Orsolini 2016-08-01 05:45:34 +02:00 committed by Ivan Grokhotkov
parent be3727c71f
commit c52088c774
2 changed files with 11 additions and 7 deletions

View File

@ -66,6 +66,9 @@ static bool softap_config_equal(const softap_config& lhs, const softap_config& r
if(lhs.ssid_hidden != rhs.ssid_hidden) { if(lhs.ssid_hidden != rhs.ssid_hidden) {
return false; return false;
} }
if(lhs.max_connection != rhs.max_connection) {
return false;
}
return true; return true;
} }
@ -76,12 +79,13 @@ static bool softap_config_equal(const softap_config& lhs, const softap_config& r
/** /**
* Set up an access point * Set up an access point
* @param ssid Pointer to the SSID (max 63 char). * @param ssid Pointer to the SSID (max 63 char).
* @param passphrase (for WPA2 min 8 char, for open use NULL) * @param passphrase (for WPA2 min 8 char, for open use NULL)
* @param channel WiFi channel number, 1 - 13. * @param channel WiFi channel number, 1 - 13.
* @param ssid_hidden Network cloaking (0 = broadcast SSID, 1 = hide SSID) * @param ssid_hidden Network cloaking (0 = broadcast SSID, 1 = hide SSID)
* @param max_connection Max simultaneous connected clients, 1 - 4.
*/ */
bool ESP8266WiFiAPClass::softAP(const char* ssid, const char* passphrase, int channel, int ssid_hidden) { bool ESP8266WiFiAPClass::softAP(const char* ssid, const char* passphrase, int channel, int ssid_hidden, int max_connection) {
if(!WiFi.enableAP(true)) { if(!WiFi.enableAP(true)) {
// enable AP failed // enable AP failed
@ -108,7 +112,7 @@ bool ESP8266WiFiAPClass::softAP(const char* ssid, const char* passphrase, int ch
conf.channel = channel; conf.channel = channel;
conf.ssid_len = strlen(ssid); conf.ssid_len = strlen(ssid);
conf.ssid_hidden = ssid_hidden; conf.ssid_hidden = ssid_hidden;
conf.max_connection = 4; conf.max_connection = max_connection;
conf.beacon_interval = 100; conf.beacon_interval = 100;
if(!passphrase || strlen(passphrase) == 0) { if(!passphrase || strlen(passphrase) == 0) {

View File

@ -36,7 +36,7 @@ class ESP8266WiFiAPClass {
public: 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 softAPConfig(IPAddress local_ip, IPAddress gateway, IPAddress subnet);
bool softAPdisconnect(bool wifioff = false); bool softAPdisconnect(bool wifioff = false);