问题描述
我正在寻找方法来获取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 herehttps://developer.apple.com/documentation/networkextension/nehotspotnetwork/1618923-signalstrength
以下是将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强度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!