Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IOS : Background Bluetooth Low Energy (BLE) scanning rules

After spending hours around the web, I cannot find any documentation about the background BLE scanning rules used by IOS.

As it is not possible to set the scan window on IOS, I am looking for the rules defined by Apple when IOS is scanning in background.

Context

I am working on a wearable peripheral which can be disconnected sometimes when it is out of reach with the phone. The goal is to reconnect quickly (less than 5s) when the peripheral is close enough to the phone. The peripheral has battery constraints so I cannot advertise every 20ms forever, so I am looking for a clever way to reconnect my peripheral to the phone.

If I know how the background scanning mode is working, I would be able to define a smart advertising interval in order to save battery.

Use case

If my peripheral advertises every 1285ms, how long does it will take to be discovered by my IOS application in background mode for 10 minutes?

like image 584
sdespont Avatar asked Dec 08 '15 14:12

sdespont


2 Answers

Not sure exactly what your question is.

I suppose you have read Apple's "Bluetooth Accessory Design Guidelines for Apple Products"?

https://developer.apple.com/hardwaredrivers/BluetoothDesignGuidelines.pdf

In it, they state:

3.5 Advertising Interval

The advertising interval of the accessory should be carefully considered, because it affects the time to discovery and connect performance. For a battery-powered accessory, its battery resources should also be considered.

To be discovered by the Apple product, the accessory should first use the recommended advertising interval of 20 ms for at least 30 seconds. If it is not discovered within the initial 30 seconds, Apple recommends using one of the following longer intervals to increase chances of discovery by the Apple product:

  • 152.5 ms
  • 211.25 ms
  • 318.75 ms
  • 417.5 ms
  • 546.25 ms
  • 760 ms
  • 852.5 ms
  • 1022.5 ms
  • 1285 ms

Note: Longer advertising intervals usually result in longer discovery and connect times.

Upon discovering the BLE device, iOS will notify apps that are looking for it (based on the advertised service UUID), which will then be able to connect to it.

Apple recommend a 100 ms interval for iBeacons.

This (pretty old, from 2012) discussion states that:

the median discovery time when the phone is in standby is about 60 times the advertising interval. The 95-percentile discovery time when the phone is in standby mode is about 300 times the advertising interval

This (slightly more recent, but from Dec 2013) answer states that:

While scanning in the foreground will likely immediately discover a device advertising next to it, discovery in the background can take up to ~60 times longer.

like image 168
jcaron Avatar answered Sep 22 '22 00:09

jcaron


There's a problem when (average) advertising interval is near to an integer multiple of the scan interval, then chances are that discovery-time can rise infinitely (, i.e. scanner will never see the advertising, as ADV always occurs outside the scan window). Probably the ADV-interval list from Apple's design guideline shows optimum values, but it does not tell how to determine discovery-times. That's a mess! I'd even go further and say: If the Smartphone (Apple or any other) manufacturer does not exactly specify the scan parameters (interval, window, and eventually filter settings) for each power mode, then you're lost and cannot correctly estimate discovery performance.

like image 44
Wurl Avatar answered Sep 23 '22 00:09

Wurl