如何在 iPhone X iOS Swift 上测量 WiFi dBm 强度

How to measure WiFi dBm strength on iPhone X iOS Swift

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

尝试@Mosbash 回答,遇到崩溃。

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

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

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

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

有关详细信息,请参阅此答案: How to convert Wifi signal strength from Quality (percent) to RSSI (dBm)?

您需要征得 Apple 的许可并创建授权。