WIFI Scan: Get Level of specific BSSID?

Post your questions and help other users.

Moderator: Martin

Post Reply
ddffnn
Posts: 1
Joined: 14 Apr 2017 05:06

WIFI Scan: Get Level of specific BSSID?

Post by ddffnn » 15 Apr 2017 20:13

I would like to be able to get the wifi signal strength for one specific BSSID even though several BSSIDs are available with the same SSID.

Background:
At work I spend about half my time in a quiet cubicle environment, and the other half in a noisy lab. My goal is to make my phone change volume levels based on my location within the building. My company has dozens of access points with the same SSID. I think I should be able to look at the signal strength of one or two specific access points to know if I'm in the lab.

In Autogamic I can get the signal strength of the strongest BSSID, but I've checked and it's not always the same one even when I'm stationary in the lab.

Finally, I've tried just looking to see if the lab BSSIDs are available, but they do reach outside the lab. I'm hoping I can use signal strength to filter them out. That being said, I'm open to suggestions.

Edit: I don't actually connect to the wifi using my phone at any point. I just run scans to get the network topology.

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: WIFI Scan: Get Level of specific BSSID?

Post by Martin » 17 Apr 2017 20:04

Hi,

This information is not directly made available by Automagic. You could try to use the Java features available in action Script to access the scan results and extract the information yourself.

Following snippet should get you started:

Code: Select all

wifiManager=callJavaMethod(getContext(), "android.content.Context", "getSystemService(java.lang.String)", "wifi");
scanResults=callJavaMethod(wifiManager, "android.net.wifi.WifiManager", "getScanResults()");

for(sr in scanResults)
{
  ssid=getJavaField(sr, "android.net.wifi.ScanResult", "SSID");
  bssid=getJavaField(sr, "android.net.wifi.ScanResult", "BSSID");
  level=getJavaField(sr, "android.net.wifi.ScanResult", "level");

  log(ssid+", "+bssid+" -->"+level);
}
Regards,
Martin

User avatar
Uli
Posts: 14
Joined: 30 Mar 2019 21:10

Re: WIFI Scan: Get Level of specific BSSID?

Post by Uli » 29 Sep 2019 11:21

Hi Martin,

I do not have exactly the same problem, but a similar one. I need a flow that continuously checks the signal strength of the available (and allowed) WLan access points to automatically switch after finding a stronger one.

I know that's exactly what I get when I break the connection to an AccessPoint and then rebuild it, as it takes then the strongest. But I want to avoid that WLan constantly has to rebuild.

I wanted to try first to get your flow to work, and then switch with the results obtained to the strongest wireless. Unfortunately, I'm just a "normal" human and not a programmer. I can program for home use, but then it will be hard.

If I run the code in a script, and then print SSID, BSSID, and level, I get "null, null, -96" ... but no other results, even though multiple access points exist.

Do you have a tip for me, what am I doing wrong?

For a short note, I would be very grateful.

Best regards
Uli

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: WIFI Scan: Get Level of specific BSSID?

Post by Desmanto » 29 Sep 2019 17:17

I got the result of the scan just like the other wifi manager app will show me. Try this a bit modified script. I store the list of the scanned wifi in the {ws}

Code: Select all

wifiManager=callJavaMethod(getContext(), "android.content.Context", "getSystemService(java.lang.String)", "wifi");
scanResults=callJavaMethod(wifiManager, "android.net.wifi.WifiManager", "getScanResults()");

ws = newList();

for(sr in scanResults)
{ 
  ssid=getJavaField(sr, "android.net.wifi.ScanResult", "SSID");
  bssid=getJavaField(sr, "android.net.wifi.ScanResult", "BSSID");
  level=getJavaField(sr, "android.net.wifi.ScanResult", "level");
  addElement(ws, newList(ssid, bssid, level)); 
}
Add condition debug dialog after it to see the {ws} content. It should give all the wifi available with its signal strength.

But remember, strongest signal doesn't mean the best wifi. My archer C7 capable of wifi n and ac. The wifi n ssid always stronger than ac, but the link speed is higher in the ac.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

Post Reply