uint8 wifi_softap_get_station_num(void)
Alternatively you could register a callback and get notified every time a station connects and disconnects using:
void wifi_set_event_handler_cb(wifi_event_handler_cb_t cb)
The SDK has a good example of using this latter function, and how to retrieve info about the station when it connects/disconnects.
I can't see an obvious way to ban a client from connecting if you've hit a max number. You could disable the DHCP server when a max has been reached - but this would also prevent existing stations from renewing their leases.
Edit: maximum number of stations is configurable in softap_config (max_connection). So use:
bool wifi_softap_set_config(_current)(struct softap_config *config)
esp8266 otb-iot documentation - https://otb-iot.readthedocs.io/
esp8266 related blog - http://www.packom.net/
However, I have some questions about all of them:
1) the wifi_softap_get_station_num() displays the number of devices connected, but sometimes when I disconnect the device the ESP counts it still as connected and after plenty of minutes(around 10) stops counting it. How this can be fixed?
2) for the restriction of max_connections, I changed the parameter in my library to 1:
struct softap_config conf;
wifi_softap_get_config(&conf);
strcpy(reinterpret_cast<char*>(conf.ssid), ssid);
conf.channel = channel;
conf.ssid_len = strlen(ssid);
conf.ssid_hidden = ssid_hidden;
conf.max_connection = 1;
conf.beacon_interval = 100;
However, it still does not work because I can connect from 2 devices. What am I doing wrong?
3) for the event listener can you give me an example how to use it because in the SDK in Github I did not find any
Thank you very much for your help!!!
So, instead, I've use to count it myself using wifi_softap_get_station_info(); enumeration.