I need to scan for available Wi-Fi signals and their strengths. I'm using wifiManager.startScan();
and asynchronous wifiManager.getScanResult();
.
On devices without support of 5GHz band it takes about 500ms to get the results, on devices with 5GHz band support it takes about 2s, and that is too much for me. I guess the 1.5s delay is in searching the whole 5GHz band.
Is there any way I could tell the device to scan only in the 2.4GHz band, or any other way I could get the results faster (for example through NDK)? I searched through the entire web and found nothing, so I guess this is the only way.
Thank you.
I think there is not way how to achieve it.
All you can do is only call
startScan()
and wait for results. Then you can filter results due to their frequency especially for 2.4Ghz frequency of each AP (Access Point) should be bellow 2500 Mhz.Supplicant config file provide option to explicitly declare range of channels where you want to scan for available network. If you device uses wpa_supplicant then in config file you can define scan frequency like below.
for more info look for above text in below mention link.
Visit http://hostap.epitest.fi/gitweb/gitweb.cgi?p=hostap.git;a=blob_plain;f=wpa_supplicant/wpa_supplicant.conf .
NOTE: These api's are removed from Android Nogut version. Applicable till Mashmallow
Use above constants part of WifiManager.java, to set the required frequency bands. And we can set frequency with API setFrequencyBand(int mode, boolean persist). These are hidden API's.
code snippet: