17

It seems that AirPods and iPhone can communicate on a very sensitive level. Moving AirPods physically close to the device (1 foot away) will trigger the iPhone to react.

Can the iPhone really detect bluetooth signals with such accuracy? I'm using bluetooth right now, but I can't seem to reach this level of signal sensitivity.

TIMEX
  • 259,804
  • 351
  • 777
  • 1,080
  • 1
    Sure using RSSI. See : https://stackoverflow.com/questions/13705647/finding-distance-from-rssi-value-of-bluetooth-low-energy-enabled-device – ESD Jul 18 '17 at 17:32
  • 4
    Also, remember that AirPods contain a unique Apple bluetooth chip that allows pairing to "just work". –  Jul 18 '17 at 17:41
  • 1
    I'm not familiar with airpods but Apple might be using nfc(or something similar) also with Bluetooth. – ESD Jul 18 '17 at 17:54
  • 2
    It's probably done, not at the level of the Core Bluetooth framework, but down closer to the physical layer communicating with the W1 chip. Thus using RF signalling information that an app does not have access to. Not just framework processed RSSI. – hotpaw2 Jul 18 '17 at 18:51

1 Answers1

34

They used to have some additional measures to find out the distance. As noticed by hotpaw2 in comments


Quick Answer - Swift 4.2

func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) {
if let power = advertisementData[CBAdvertisementDataTxPowerLevelKey] as? Double{
   print("Distance is ", pow(10, ((power - Double(truncating: RSSI))/20)))
   }
}

TL:DR;

Factors Affecting RSSI

RSSI readings are not very stable and highly depend on environment

It may also vary due to a number of factors, including both the power and sensitivity of the sensing / transmitting radios, as well as the environmental stuff (are you inside, outside? are there many people nearby? noisy wireless environment or not, and so on).

The problem, however, is that beacon signals are actually radio waves, and can be absorbed by metals, walls, water etc. Since they transmit radio signals in the commonly used 2.4GHz band, the signal strength received from a beacon varies widely because of interference.

One of the mostly used formula to find out distance is

d = 10 ^ ((TxPower - RSSI) / 20)

TxPower is typically known as transmit power


How to get TxPower From BLE advertisement Data

The txPower value will be available in BLE advertisement data (available only if the broadcaster (peripheral) provides its Tx power level).

As per apple documentation the value of CBAdvertisementDataTxPowerLevelKey in CBAdvertisementDataTx

Delegate method to access the raw advertisement data

optional func centralManager(_ central: CBCentralManager, 
                 didDiscover peripheral: CBPeripheral, 
           advertisementData: [String : Any], 
                        rssi RSSI: NSNumber)

Can be also accessed by using BlueCap API

To know more advantages of AirPlay than Classical Bluetooth

https://www.cambridgeaudio.com/blog/airplay


RSSI and Distance

According to the image below from Link

enter image description here

RSSI will go down if you cover the beacon (e.g., a person comes in between you and the beacon). That is, you're still in the same distance, but RSSI goes down—so where you to base the distance estimate on the RSSI, the distance would go up, without you moving an inch.

Many of the above explanations are taken from other sites.

I Hope it sum up to your need!

Saranjith
  • 11,242
  • 5
  • 69
  • 122
  • So...we can simply use that formula in our own apps? And we will be able to determine the distance similar to AirPods? How do we get the TXPower on iOS? – TIMEX Aug 02 '17 at 23:02
  • 1
    @Saranjith i'm using the above formula but i doesn't get the valid response. Lock is quite close to my device but it still give me value around 7000. do we need to convert this value? – Sourav Mishra Aug 30 '19 at 10:21