如何在iPhone X iOS Swift上测量WiFi dBm强度 [英] How to measure WiFi dBm strength on iPhone X iOS Swift

查看:955
本文介绍了如何在iPhone X iOS Swift上测量WiFi dBm强度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找方法来获取wifi的原始信号(iPhone X手机上的dBm),但是只能找到如何从以下位置获取numberOfActiveBars的方法:

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

尝试@Mosbash答案,崩溃.

Trying @Mosbash answer, getting a crash.

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

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
  }
}

推荐答案

您可以按照此处所述使用NEHotspotNetwork的signalStrength https://developer.apple.com/documentation/networkextension/nehotspotnetwork/1618923-信号强度

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

当要求Hotspot Helper应用评估网络或 过滤Wi-Fi扫描列表,它注释NEHotspotNetwork对象 通过setConfidence:方法.

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.

以下是将Wifi信号强度百分比转换为RSSI dBm的公式:

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]

有关更多详细信息,请参见以下答案: 如何从质量转换Wifi信号强度(百分比)到RSSI(dBm)?

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

这篇关于如何在iPhone X iOS Swift上测量WiFi dBm强度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆