-->
Page 1 of 1

GETTING A LIST OF CONNECTED CLIENTS

PostPosted: Fri Nov 11, 2016 10:56 am
by sergiom968
How I can get a list of devices connected to my esp8266 in Access Point mode, with MAC address and IP address?

Re: GETTING A LIST OF CONNECTED CLIENTS

PostPosted: Fri Nov 11, 2016 3:00 pm
by martinayotte
Using this piece of code (note : here, it is printing only MAC, but there a member for IP too ...) :
Code: Select allvoid showClient()
{
  struct station_info *stat_info;
  stat_info = wifi_softap_get_station_info();
  uint8_t client_count = wifi_softap_get_station_num();
  String str = "Number of clients = ";
  str += String(client_count);
  str += "\r\nList of clients : \r\n";
  int i = 1;
  while (stat_info != NULL) {
    str += "Station #";
    str += String(i);
    str += " : ";
    str += String(stat_info->bssid[0], HEX);
    str += ":";
    str += String(stat_info->bssid[1], HEX);
    str += ":";
    str += String(stat_info->bssid[2], HEX);
    str += ":";
    str += String(stat_info->bssid[3], HEX);
    str += ":";
    str += String(stat_info->bssid[4], HEX);
    str += ":";
    str += String(stat_info->bssid[5], HEX);
    str += "\r\n";
    i++;
    stat_info = STAILQ_NEXT(stat_info, next);
    }
  Serial.println(str);
}