0

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
  }
}
Tal Zion
  • 6,308
  • 3
  • 50
  • 73

2 Answers2

2

You need to ask permission from Apple and create entitlement.

Ohmy
  • 2,201
  • 21
  • 24
  • Anyone who is wondering about "Apple Permission", please refer to Apple documentation: https://developer.apple.com/documentation/networkextension/hotspot_helper#overview – Ozan Aydın Apr 19 '21 at 18:54
1

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

Mosbah
  • 1,347
  • 1
  • 14
  • 28
  • this gives you the value that lies within the range 0.0 (weak/no signal) to 1.0 (strong signal). This is not dBm, which ranges between around -20 to -90 – Tal Zion Jan 13 '19 at 23:45
  • Perfect, thanks. I tried to set the HotSpot helper but getting a crash that the phone is not using Metal. Any idea? – Tal Zion Jan 14 '19 at 08:37
  • can you share your code and the crash stack trace please ? – Mosbah Jan 14 '19 at 09:11