#include <WiFi.h>
//SSID of your network
char ssid[] = "yourNetwork";
//password of your WPA Network
char pass[] = "secretPassword";
int status = WL_IDLE_STATUS; // the Wifi radio's status
void setup()
{
WiFi.begin(ssid, pass);
if ( status != WL_CONNECTED) {
Serial.println("Couldn't get a wifi connection");
while(true);
}
// if you are connected, print out info about the connection:
else {
// print the MAC address of the router you're attached to:
byte bssid[6];
WiFi.BSSID(bssid);
Serial.print("BSSID: ");
Serial.print(bssid[5],HEX);
Serial.print(":");
Serial.print(bssid[4],HEX);
Serial.print(":");
Serial.print(bssid[3],HEX);
Serial.print(":");
Serial.print(bssid[2],HEX);
Serial.print(":");
Serial.print(bssid[1],HEX);
Serial.print(":");
Serial.println(bssid[0],HEX);
}
}
void loop () {}
It won't compiled, error in WiFi.BSSID(bssid).
The error message: invalid conversion from 'byte* {aka unsigned char*}' to 'uint8_t {aka unsigned char}' [-fpermissive]
The method BSSID takes an uint8_t parameter (networkItem) that is the zero based index of networks discovered during the scan, and return a uint8_t (aka byte) pointer to the BSSID
So, for example, if your network has index 0, you can read the BSSID this way
uint8_t *ptrBSSID = Wifi.BSSID(0);
uint8_t bssid[6];
if (ptrBSSID == NULL)
{
// error, no network with this index
}
else
{
// copy the BSSID to your local array
memcpy(bssid,ptrBSSID,6);
// do something with the bssid
....
}