Page 1 of 1

WIFI Scan: Get Level of specific BSSID?

Posted: 15 Apr 2017 20:13
by ddffnn
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.

Re: WIFI Scan: Get Level of specific BSSID?

Posted: 17 Apr 2017 20:04
by Martin
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

Re: WIFI Scan: Get Level of specific BSSID?

Posted: 29 Sep 2019 11:21
by Uli
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

Re: WIFI Scan: Get Level of specific BSSID?

Posted: 29 Sep 2019 17:17
by Desmanto
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.