javaandroidmacoswifibssid

Android's getBSSID() method bug?


I'm using Android Studio trying to get the gateway's MAC using the getBSSID method. However, it never shows it correctly. My gateway is xx:xx:xx:xx:xx:f0, but this method returns xx:xx:xx:xx:xx:f2. I tried with another router (xx:xx:xx:xx:xx:xb), and I got it wrong too (xx:xx:xx:xx:xx:xc).

WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
return wifiInfo.getBSSID();

Why is that? Am I doing something wrong?


Solution

  • This is actually not programming related question.

    Most of the access points use multiple mac addresses for different wireless interfaces. For instance the mac address of 5 GHZ or 2.4 GHZ are different then each other and also they are different then the mac address used for announcing that network.

    For your example xx:xx:xx:xx:xx:f0 is probably for 2.4 GHZ, xx:xx:xx:xx:xx:f1 is probably for 5GHZ network, and xx:xx:xx:xx:xx:f2 is for announcing that network. Perhaps there is a xx:xx:xx:xx:xx:f3 for connecting mesh links.

    So the mac address you are getting is correct. Its just that your access point have many mac addresses for different purposes.