CoreBluetooth广告检测时间 [英] CoreBluetooth advertising detection time

查看:127
本文介绍了CoreBluetooth广告检测时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题已在10月份讨论过了这里。这是一个新问题,因为CoreBluetooth相当新,自那时起可能会发生一些变化。

This issue has been discussed back in October here. This is a new question as CoreBluetooth is fairly new and some changes might have occurred since then.

我每2秒就有一个BLE设备广告。扫描是使用以下方式启动的:

I have a BLE device advertising every 2 seconds. Scanning is initiated using:

[self.CM scanForPeripheralsWithServices:nil options:0]

最常返回(通过centralManager didDiscoverPeripheral回调)大约2s到4s之后。 (CM是我的CentralManger)

Which returns most often (via the centralManager didDiscoverPeripheral callback) around 2s to 4s later. (CM is my CentralManger)

然而,大约30%的时间,扫描需要10到18秒。
附近设备中的WiFi和BT已被禁用以尽可能清除频谱。
扫描时间似乎与RSSI无关。在iPAd3旁边是-40dB,在另一个房间约5米处是-70dB。

However, about 30% of the time, the scan takes 10 to 18 seconds. WiFi and BT in nearby devices has been disabled to clear the spectrum as much as possible. The time to scan seems unrelated to RSSI. Which is -40dB when next to the iPAd3, -70dB when about 5 metres away in another room.

[self.CM stopScan]; 

在scanWithPeripherals之前被调用,因为它减少了真正长时间等待的发生。

is called before the scanWithPeripherals as it reduces the occurrence of really long waits.

没有连接。没有要求提供任何特征或服务数据。广告数据就足够了。

No connection is being made. No characteristic or services data is being requested. Advertising data is sufficient.

有一个有用的TI 示范应用
这给出了类似的结果(实际上稍微差一点,因为它没有进行任何stopScan调用)

There is a useful TI demonstrator app. This gives similar results (actually slightly worse as it doesn't make any stopScan calls)

CBCentralManagerScanOptionAllowDuplicatesKey选项,如此 Stackoverflow回答,如果有什么似乎延长了发现时间。

The CBCentralManagerScanOptionAllowDuplicatesKey option as seen in this Stackoverflow answer if anything seems to lengthen discovery times.

显然,下一步是使用一些更高级的BT嗅探器/广告生成工具来进一步表征这个CoreBluetooth响应。

Obviously, the next step is to use some more advanced BT sniffer / advert generation tools to further characterise this CoreBluetooth response.

这是另一个有用的问题,但没有详细说明响应时间。

This is another useful SO question, but does not elaborate enough on response times.

推荐答案

CoreBluetooth没有连续收听。它与蓝牙经典和Wifi共享硬件资源。

The CoreBluetooth isn't listening continuously. It is sharing HW resources with bluetooth classic and Wifi.

基本上你必须幸运才能收到广告包。
幸运,因为2个非同步系统的2个滑动窗口必须相互碰撞。
如果CoreBluetooth在10%的时间打开它的BLE窗口并且您已设置广告间隔而不知道确切的时间,则它将/可能需要10倍的广告间隔。

Basically you must be "Lucky" to receive the advertisement package. "Lucky" as in that the 2 sliding windows of the 2 unsynchronised systems must hit each other. If CoreBluetooth opens it's BLE window 10% of the time and you have set the advertisement interval without knowledge about the exact timing then it will/can take 10 times the advertisement interval.

一个建议是做广告>快速<对于前30秒(比如20ms,您应该在第一个活动的CoreBluetooth窗口中发现它),然后减慢到Apple指定的间隔。 2,00秒不是一个好的数字。

One recommendation is to advertise >fast< for the first 30 seconds (say 20ms and you should discover it in the first active CoreBluetooth window) and then slow down to intervals specified by Apple. 2,00 seconds is NOT a good number.

请参阅此处的指南:
https://developer.apple.com/hardwaredrivers/BluetoothDesignGuidelines.pdf

Page 18

广告时段
应仔细考虑蓝牙配件的广告时段,因为它会影响发现和连接性能的时间
。对于电池供电的配件,其电池资源也应考虑为

要由Apple产品发现,蓝牙配件应首先使用建议的广告
间隔20 ms至少30秒。如果在最初的30秒内未发现,则附件可能会选择节省电池电量并增加其广告间隔。 Apple建议使用以下
更长间隔之一来增加Apple产品发现的机会:

Advertising Interval The advertising interval of the Bluetooth 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 Bluetooth 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, the accessory may choose to save battery power and increase its advertising interval. Apple recommends using one of the following longer intervals to increase chances of discovery by the Apple product:

645 ms
768 ms
961 ms
1065 ms
1294 ms

645 ms 768 ms 961 ms 1065 ms 1294 ms

如果必须节省电池,请尝试1294 ms。

So try 1294 ms if you must save battery.

这篇关于CoreBluetooth广告检测时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆