How to get Access Point MAC adress

GEOLOCWIFI
Posts: 1
Joined: Wed Nov 16, 2016 6:59 pm

How to get Access Point MAC adress

Postby GEOLOCWIFI » Thu Nov 17, 2016 6:23 pm

Hi Everyone !

My ESP is in station mode, I can get the RSSI of few APs in my school but I can't get the MAC adress of this APs.
Is there anyone who knows how to get theses informations ?

Thank you!

pratik

Re: How to get Access Point MAC adress

Postby pratik » Sat Nov 19, 2016 1:12 pm

Are you using the SDK? If yes, here is how you do this:

You can access the MAC address of any AP the moment the ESP8266 connects to it by registering a WiFi event callback:
void wifi_set_event_handler_cb(wifi_event_handler_cb_t cb);

The function could be of the form:

Code: Select all

void wifi_handle_event_cb(System_Event_t *evt) {
os_printf("event %x\n", evt->event);
switch (evt->event)
{
case EVENT_STAMODE_CONNECTED:
os_printf("connect to ssid %s, channel %d\n", evt->event_info.connected.ssid, evt->event_info.connected.channel);
os_printf("AP MAC address is  %s\n", evt->event_info.connected.bssid);
break;

case ....
....
}


The line
os_printf("AP MAC address is %s\n", evt->event_info.connected.bssid);
will get you the MAC of the currently connected AP in station mode.

Who is online

Users browsing this forum: No registered users and 1 guest