iosswiftwifiiphone-xdbm

How to measure WiFi dBm strength on iPhone X iOS Swift


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

Solution

  • 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)?