-->
Page 1 of 1

How to limit the number of connected clients

PostPosted: Thu Jun 30, 2016 4:32 pm
by SO_yeah
Hello!

I'm using my ESP in WiFi.mode(WIFI_AP).
Is there any way to limit the number of allowed connections?
To be specific I'd like not to have more than one client connected at the same time.
Thanks!

Re: How to limit the number of connected clients

PostPosted: Fri Jul 01, 2016 3:08 am
by Cicero
There is, but in the Arduino lib it is hardcoded as max_connections = 4 (this is default on the esp anyway)
See line 111 of https://github.com/esp8266/Arduino/blob ... WiFiAP.cpp

You'll either have to change the lib file, or easier, just write your own set ap config function, along the lines of:
Code: Select allstruct softap_config conf;
wifi_softap_get_config(&conf);
conf.max_connection = 1; 
ETS_UART_INTR_DISABLE();
ret = wifi_softap_set_config(&conf);
ETS_UART_INTR_ENABLE();   

So read the current config set through the usual method, and merely change the max_connection parameter.

Re: How to limit the number of connected clients

PostPosted: Fri Jul 01, 2016 3:42 pm
by SO_yeah
It totally looked like my cup of tea but its not working.
I can still connect more than one client, should I report this on github!?
thanks anyways!

Re: How to limit the number of connected clients

PostPosted: Fri Jul 01, 2016 4:07 pm
by SO_yeah
I made the usual mistake "password too short -> configuration not updated" :roll:
your solution works like a charm!!
thank you very much!!!!