简体   繁体   English

IOS : 背景蓝牙低功耗 (BLE) 扫描规则

[英]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.在网上花了几个小时后,我找不到任何关于 IOS 使用的后台 BLE 扫描规则的文档。

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.由于无法在 IOS 上设置扫描窗口,因此我正在寻找 IOS 在后台扫描时 Apple 定义的规则。

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.目标是在外围设备离手机足够近时快速(少于 5 秒)重新连接。 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.外围设备有电池限制,所以我不能永远每 20 毫秒做一次广告,所以我正在寻找一种巧妙的方法将我的外围设备重新连接到手机。

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?如果我的外设每 1285 毫秒进行一次广告,那么我的 IOS 应用程序在后台模式下 10 分钟需要多长时间才能发现?

Not sure exactly what your question is.不确定你的问题是什么。

I suppose you have read Apple's "Bluetooth Accessory Design Guidelines for Apple Products"?我想您已经阅读了 Apple 的“Apple 产品蓝牙配件设计指南”?

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

In it, they state:在其中,他们指出:

3.5 Advertising Interval 3.5 广告间隔

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.要被 Apple 产品发现,配件应首先使用建议的 20 毫秒广告间隔至少 30 秒。 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:如果在最初的 30 秒内没有被发现,Apple 建议使用以下较长时间间隔之一来增加 Apple 产品发现的机会:

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

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.发现 BLE 设备后,iOS 将通知正在寻找它的应用程序(基于广告服务 UUID),然后应用程序将能够连接到它。

Apple recommend a 100 ms interval for iBeacons. Apple 建议 iBeacons 间隔为 100 毫秒。

This (pretty old, from 2012) discussion states that:这个(很老,从 2012 年开始) 讨论指出:

the median discovery time when the phone is in standby is about 60 times the advertising interval.手机待机时的中位发现时间约为广告间隔的 60 倍。 The 95-percentile discovery time when the phone is in standby mode is about 300 times the advertising interval手机待机时的95%发现时间约为广告间隔的300倍

This (slightly more recent, but from Dec 2013) answer states that:这个(稍晚一些,但从 2013 年 12 月开始)答案指出:

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.虽然在前台扫描可能会立即发现旁边有广告的设备,但在后台发现可能需要长达 60 倍的时间。

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 (, ie scanner will never see the advertising, as ADV always occurs outside the scan window).当(平均)广告间隔接近扫描间隔的整数倍时会出现问题,那么发现时间可能会无限增加(即扫描仪永远不会看到广告,因为 ADV 总是发生在扫描窗口之外)。 Probably the ADV-interval list from Apple's design guideline shows optimum values, but it does not tell how to determine discovery-times.可能来自 Apple 设计指南的 ADV-interval 列表显示了最佳值,但它没有说明如何确定发现时间。 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.我什至更进一步说:如果智能手机(Apple 或任何其他)制造商没有准确指定每种电源模式的扫描参数(间隔、窗口和最终的过滤器设置),那么您就迷失了并且无法正确估计发现性能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM