CoreBluetooth连接建立时间相差很大 [英] CoreBluetooth connection setup time varies quite a bit

查看:262
本文介绍了CoreBluetooth连接建立时间相差很大的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将我的应用程序连接到Bluetooth 4.0设备所需的时间似乎相差很大。相同的应用程序,相同的设备。有时它会立即连接-不到一秒钟。有时大约需要10到12秒。而且有时它根本无法连接-我需要重新启动扫描,等等。我想知道是否还有其他人看到了此问题。

The time taken to connect my app to a Bluetooth 4.0 device seems to vary quite a bit. Same app, same device. Sometimes it connects immediately - like less than a second. Sometimes it takes about 10-12 seconds. And once in while it doesn't connect at all - I need to restart the scan, etc. I was wondering if anyone else has seen this issue. What could be causing this?

推荐答案

我也发现了同样的问题。我有一个BLE设备每2秒发布一次广告。

I am also finding the same issue. I have a BLE device advertising every 2 seconds.

[self.CM scanForPeripheralsWithServices:nil options:0]

在0.2s至30s后返回。 (CM是我的CentralManger)

returns after 0.2s to ~30s. (CM is my CentralManger)

我的下一步是将时间收集到CSV文件中,并绘制各种连接时间的频率分布以及连接时间与时间的关系,

My next step is to collect the times in a CSV file and plot the frequency distribution of the various connect times and connect times versus time, to see if I can discern a pattern.

有一个有用的TI 演示程序应用。但是令人讨厌的是,它们使它变得通用并且没有实现iPad故事板(它在那里空白),并且当我尝试在调试模式下运行时,将其设置为仅iPhone版本会导致错误。而且我没有另一台带有BLE的Apple设备。

There is a useful TI demonstrator app. But annoyingly they have made it universal and not implemented the iPad storyboard (it is there and blank), and setting it to iPhone only version is causing an error when I try to run in debug mode. And I don't have another Apple device with BLE to hand.

打电话

[self.CM stopScan]; 

在scanWithPeripherals看来可以减少真正长时间的等待。

before the scanWithPeripherals seems to reduce the occurrence of really long waits.

我尝试了CBCentralManagerScanOptionAllowDuplicatesKey选项,如该 Stackoverflow答案,但如果有什么事情似乎会延长发现时间。

I tried the CBCentralManagerScanOptionAllowDuplicatesKey option as seen in this Stackoverflow answer but if anything that seemed to lengthen discovery times.

我想我会掌握一些蓝牙数据包嗅探器工具,以帮助了解实际情况。

I think I will get hold of some Bluetooth packet sniffer tools to help with seeing what is actually in the air.

这篇关于CoreBluetooth连接建立时间相差很大的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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