我正在寻找获取wifi原始信号(iPhone X手机上的dBm)的方法,但只能找到如何从Answer
获取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
}
}
答案 0 :(得分:0)
您可以按照此处所述使用NEHotspotNetwork的signalStrength https://developer.apple.com/documentation/networkextension/nehotspotnetwork/1618923-signalstrength
当要求Hotspot Helper应用评估网络或 筛选Wi-Fi扫描列表,它注释NEHotspotNetwork对象 通过setConfidence:方法。
以下是将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)?
答案 1 :(得分:0)
您需要征得Apple的许可并创建权利。