Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By Ghassan Yusuf
#47951 Dear Friends

I am trying to build an application, in which we have an (esp8266 as a server and as accesspoint) and we have another (esp8266 as a client) that connects to the first esp8266 accesspoint. the server within should only accept specific clients with a certain mac address. any other clients trying to connect with an unknown mac address should be rejected or stoped.

so is there a way in which we can read the mac address of the client at the moment of connection attempt ?

or if there is a better way please guide me.
thanks in advance
Ghassan Yusuf
User avatar
By Cicero
#47994 Dunno about arduino, but you can access the sdk directly if you extern C it.

In the SDK there's wifi_softap_get_station_info() that'll give you the IP and MAC's.

A different way would be to use the wifi_set_event_handler_cb, which will be called when the station connects, and you can list the MAC right then (see SDK doc):
Code: Select allcase EVENT_SOFTAPMODE_STACONNECTED:
os_printf("station: " MACSTR "join, AID = %d\n",
MAC2STR(evt->event_info.sta_connected.mac),
evt->event_info.sta_connected.aid);


Maybe you can look for those functions in the arduino libs as a starting point. How you'd kick the station off and ignore them after that though is a different problem. I'd be interested in that as well.
Last edited by Cicero on Thu May 26, 2016 8:05 am, edited 1 time in total.
User avatar
By pgScorpio
#48023 Work-around for Arduino esp8266: (Arduino 1.6.9)

Code: Select all#include <ESP8266WiFi.h>

String WiFi_macAddressOf(IPAddress aIp)
{
    if (aIp == WiFi.localIP())
        return WiFi.macAddress();

    if (aIp == WiFi.softAPIP())
        return WiFi.softAPmacAddress();

    return String("00-00-00-00-00-00");
}

void some_client_func()
{

  //get STA MAC if client on STA,  AP MAC if client on AP
    String clientMAC = WiFi_macAddressOf(WiFiClient::localIP());   
 
}