Android – WiFi manager.calculatesignallevel (RSSI, 5)

I'm trying to use WiFi manager to calculate the signal level of the access point found during the scan

I use the following methods:

WifiManager.calculateSignalLevel(int, int)

But regardless of the RSSI level, it always seems to return the same int

This is my code:

public int calculateQoS(int aRSSI){

    signalLevel = WifiManager.calculateSignalLevel(RSSI, 5);

    return signalLevel;

}

public void testCalculateQoS(){

            Log.d("signal", "signal = : "
                    + connMonitor.calculateQoS(-44)
                    + " " + connMonitor.calculateQoS(-80)
                    + " " + connMonitor.calculateQoS(-120)
                    + " " + connMonitor.calculateQoS(-20));

        }

For all test cases of calculateqos (int), the log output is 1

Did I miss something simple? Why is signallevel always 1?

resolvent:

It seems that calculatesignallevel is implemented in this way:

public static int calculateSignalLevel(int RSSi, int numLevels) {
  if (RSSi <= MIN_RSSI) {
      return 0;
  } else if (RSSi >= MAX_RSSI) {
      return numLevels - 1;
  } else {
      int partitionSize = (MAX_RSSI - MIN_RSSI) / (numLevels - 1);
      return (RSSi - MIN_RSSI) / partitionSize;
  }
}

Maybe this code can explain your problem. Please also note:

http://code.google.com/p/android/issues/detail?id=2555

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>