-->
Page 1 of 1

HOW TO GET MAC ADDRESS OF DEVICES CONNECTED TO ESP8266 ?

PostPosted: Sun Sep 03, 2017 6:08 am
by andre_teprom
I'm aware of the Arduino function macAddress() available at the <ESP8266WiFi.h> library, however I was more interested to get the MAC address of the remote device which were just connected to my Webserver.

Is it possible ?

Re: HOW TO GET MAC ADDRESS OF DEVICES CONNECTED TO ESP8266 ?

PostPosted: Sun Sep 03, 2017 8:02 am
by martinayotte
Code: Select allvoid showClients()
{
  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);
//    stat_info = stat_info->next;
    }
  Serial.println(str);
}

Re: HOW TO GET MAC ADDRESS OF DEVICES CONNECTED TO ESP8266 ?

PostPosted: Sun Sep 17, 2017 4:19 am
by andre_teprom
@philbowles
@Martin


Hi,
Thank you for the replies, both answered exactly the question, which is: Yes, Either client and server are located within the same local subnet ( 192.168.x. ). I apologize for the late reply, but I have not received notification from the forum system.

Back to the code, what library would be required to include?



Thanks in advance,

Re: HOW TO GET MAC ADDRESS OF DEVICES CONNECTED TO ESP8266 ?

PostPosted: Sun Sep 17, 2017 8:32 am
by martinayotte
The function calls done in my previous code snippet require plain SDK :

Code: Select allextern "C" {
#include "user_interface.h"
}