7

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?

sdespont
  • 13,915
  • 9
  • 56
  • 97

2 Answers2

5

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.

Community
  • 1
  • 1
jcaron
  • 17,302
  • 6
  • 32
  • 46
  • Yes, I know this guidelines. I could rephrase my question like this : "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?" – sdespont Dec 08 '15 at 14:26
  • This is an internal implementation detail of iOS, and likely to change from one iOS version to the next, possibly from one device to another, and probably based on other parameters (which radios are on or not, etc.). Other than some testing using actual devices, I don't think there's much you can rely on. Let me know if you need any help with the software side of things for testing. – jcaron Dec 08 '15 at 14:32
  • @jcaon Yeah, I am afraid that your comment is right. When you are developing peripherals with small buttons cells (2016) and you need quick automatic reconnection, it is a nightmare to find a good advertising interval. – sdespont Dec 08 '15 at 14:38
  • The only tidbit of information they provide is "If all apps that are scanning for peripherals are in the background, the interval at which your central device scans for advertising packets increases. As a result, it may take longer to discover an advertising peripheral"... – jcaron Dec 08 '15 at 14:45
  • In the iBeacon specs, they recommend a 100 ms advertising interval. – jcaron Dec 08 '15 at 14:47
  • This discussion http://lists.apple.com/archives/bluetooth-dev/2012/Apr/msg00049.html (quite old, though) says 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" – jcaron Dec 08 '15 at 14:48
  • This answer http://stackoverflow.com/a/20459346/3527940 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." – jcaron Dec 08 '15 at 14:53
  • Thanks for your comments. It is a shame that there is no documentation about this. – sdespont Dec 09 '15 at 08:02
1

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.

Wurl
  • 11
  • 1
  • 1
    As noted in https://electronics.stackexchange.com/questions/82098/ble-scan-interval-and-window/359158?noredirect=1# , for Apple iOS the scanInterval and scanWindow were determined empirically by a user who jailbroke the phone. Android parameters are in defined constants in available sources/headers. For Apple, if the peripheral device follows their guidelines, then for a 1022.5 ms advertising interval, foreground mode discovers 75% of devices in 1 second and 100% in 2 seconds (assuming no lost packets from interference). In background mode, ... (see next comment) – user4028 Jul 11 '19 at 17:04
  • 1
    the median time is 5 seconds and the longest time is 19 seconds though could be longer if unlucky with the random offsets to the advertising interval. For Android, using low latency scans constantly with an interval of 4 seconds so will discover quickly unless an advertising channel has a lot of interference since it will take 4 seconds to move to scan the next advertising channel. – user4028 Jul 11 '19 at 17:06