Chat freely about anything...

User avatar
By vanjo9800
#41951 Is this a right way to do it:
Code: Select allint clients()
{
  int ans=0;
  struct station_info *stat_info;
  stat_info=wifi_softap_get_station_info();
  while (stat_info != NULL) {
    ans++;
    stat_info = STAILQ_NEXT(stat_info, next);
  }
  return ans;
}
User avatar
By piersfinlayson
#41955 The SDK doc is clear that get_station_info will only return details for clients that used DHCP. If that's an OK restriction, fine, but as I say another alternative is:

Code: Select allwifi_set_event_handler_cb


And to count up and down in your callback.

I've definitely always seen EVENT_SOFTAPMODE_STACONNECTED on connection of a station but I've not checked that you always get the disconnect reliably. (You might, I've not checked.)

@vanjo9800 your code looks OK, but looks like it's going to leak memory. The SDK docs show two ways around this:

- either os_free() each station after you've looked at it
- or at the end of your loop call wifi_softap_free_station_info()
User avatar
By vanjo9800
#41956 Thank you for the help!!!

I made it with the handler of connecting and disconnecting however I experience the same problem I have with both the station_info and the with wifi_station_numbers. The three continue to mark that a device is connected for a while after it has disconnected. I use that ESP8266 in order to see when an another ESP8266 has connected to it. Only with both ESPs there is that problem. With a computer and Android phone everything works perfectly.

Do you know where the problem can be?

Thank you in advance!!!