How to measure WiFi dBm strength on iPhone X iOS Swift

倾然丶 夕夏残阳落幕 提交于 2019-12-25 01:49:33

问题


I am looking for ways to get the raw signal of the wifi, the dBm on iPhone X phones, but can only find how to get the numberOfActiveBars from: Answer

Trying @Mosbash answer, getting a crash.

Thread 1: EXC_BAD_ACCESS (code=1, address=0x18) Code:

class ViewController: UIViewController {

  var hotspot: NEHotspotNetwork!

  func viewDidLoad() {
   ....
   hotspot = NEHotspotNetwork()
  }

  func record() {
    hotspot.setConfidence(.high) /// <- Crash
    print(hotspot.signalStrength) /// <- Crash if above line is commented out
  }
}

回答1:


You can use signalStrength from NEHotspotNetwork as described here https://developer.apple.com/documentation/networkextension/nehotspotnetwork/1618923-signalstrength

When the Hotspot Helper app is asked to evaluate the a network or filter the Wi-Fi scan list, it annotates the NEHotspotNetwork object via the setConfidence: method.

Here is the formula to convert Wifi Signal Strength Percentage to RSSI dBm:

quality = 2 * (dBm + 100)  where dBm: [-100 to -50]

dBm = (quality / 2) - 100  where quality: [0 to 100]

See this answer for more details: How to convert Wifi signal strength from Quality (percent) to RSSI (dBm)?



来源:https://stackoverflow.com/questions/54172387/how-to-measure-wifi-dbm-strength-on-iphone-x-ios-swift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!