-->
Page 1 of 1

How to tell if a client is connect to a SoftAP

PostPosted: Fri Apr 29, 2016 7:21 pm
by funvill
I am looking for a method to tell if a user is connected to the SoftAP access point on the ESP8266.
The following variables change when a user makes a request while connected to the SoftAP but show zeros when the client is connected and not making a request.

WiFiClient client = wifi.client();
Serial.print(", client.status=" + String(client.status()));
Serial.print(", client.available=" + String(client.available()));
Serial.print(", client.connected=" + String(client.connected()));
Serial.println(" client.remoteIP=" + String(client.remoteIP()));

How do you tell if a client is connected to the SoftAP ?

Re: How to tell if a client is connect to a SoftAP

PostPosted: Sat Apr 30, 2016 2:31 am
by Phil colbert
Have a play with these 2 functions :-

wifi_softap_get_station_num();
wifi_softap_get_station_info();

These will tell you if there is a client connected and from the latter you can find details about the client.

The only problem with these is that first tells you if a client has connected to the access point, if you call the second one straight after you wont get the info regarding the client as it hasnt completed its DHCP request.

Also sometimes a client may reconnect and if it uses its last IP it was given, the station_info isnt updated, so the number will be +1 but no info for the client.

Another problem that can occur is that the client can disconnect and wifi_softap_get_station_num(); will still report a client is connected.

Mainly these work, but sometimes they dont, just letting you know they arent very good.

Alternatively if you have time in your code , you can cycle through IP's that the AP gives out, mainly 192.168.4.2 , 192.168.4.3, 192.168.4.100, 192.168.4.101....( with an AP of 192.168.4.1 ) a very poor way of finding the IP, but I havent found 100% reliable method yet.

Re: How to tell if a client is connect to a SoftAP

PostPosted: Mon May 02, 2016 1:21 pm
by funvill
Thank you, this worked for me.