I need to get BSSID(MAC) of all AP's. Please find below code block.
List<WifiConfiguration> test = wifiManager.getConfiguredNetworks();
for(int k=0;k<test.size();k++){
Log.d("acheck", "test BSSID = "+test.get(k).BSSID);
Log.d("acheck", "test BSSID = "+test.get(k).BSSID);
}
But above code block returns SSID properly but null for BSSID. I want to connect to strongest access point with user defined SSID. Is there any API method available to get best signal strength's AP with user defined SSID.(In my case there are many SSID's with single SSID with multiple AP's available.)
The SSID (Service Set Identifier) is the name of your wireless network, also known as Network ID. This is viewable to anyone with a wireless device within reachable distance of your network. It's recommended you set up a password so not just anybody can connect to your network.
The BSSID is a 48bit identity used to identify a particular BSS (Basic Service Set) within an area. In Infrastructure BSS networks, the BSSID is the MAC (Medium Access Control) address of the AP (Access Point) and in Independent BSS or ad hoc networks, the BSSID is generated randomly.
In Multi-SSID mode, the access point creates multiple wireless networks to provide different security and VLAN groups. This mode is suitable when you want your devices connected to different wireless networks and become isolated by VLANs.
aircrack-ng can do this. sudo airmon-ng start eth1 6 to use eth1 to monitor channel 6 (the channel is optional) and then you can use sudo airodump-ng eth1 to make it show you the BSSID.
Adapted the answer by @ToonSuperLove, mainly to avoid NPEs.
public class WifiTest extends Activity {
public void loadWifiAvailableList(EditText etWifiList) {
WifiManager wifiManager = (WifiManager)
getSystemService(Context.WIFI_SERVICE);
List<ScanResult> results = wifiManager.getScanResults();
String message = "No results. Check wireless is on";
if (results != null) {
final int size = results.size();
if (size == 0) message = "No access points in range";
else {
ScanResult bestSignal = results.get(0);
etWifiList.setText(""); // etWifiList is EditText
int count = 1;
for (ScanResult result : results) {
etWifiList.append(count++ + ". " + result.SSID + " : "
+ result.level + "\n" + result.BSSID + "\n"
+ result.capabilities + "\n"
+ "\n=======================\n");
if (WifiManager.compareSignalLevel(bestSignal.level,
result.level) < 0) {
bestSignal = result;
}
}
message = String.format(
"%s networks found. %s is the strongest.", size,
bestSignal.SSID + " : " + bestSignal.level);
}
}
Toast.makeText(this, message, Toast.LENGTH_LONG).show();
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With