2013-03-14 77 views
3

有没有办法通过核心蓝牙来改变连接间隔? 我正在将大块数据传输到Peripheral,并且它正在谈论很多时间来传输数据。我想减少这个时间。连接间隔核心蓝牙

请让我知道,如果有可能使用核心蓝牙从iOS写入或更新连接间隔。

谢谢

回答

5

只有从您的外设发送的连接参数更新到iOS。 Min:20ms(参数= 16)最大:40(参数= 32)是CoreBluetooth的最佳合法参数。 其实你会得到更好的性能与最小= 10最大= 20或30从哪个CoreBluetooth将选择大约20ms而不是30ms 恼人的,我们不能设置它。

+1

是的,我已经从Peripheral设置相同。但我想知道,iOS应用程序可以使用Core Bluetooth读取或更新连接间隔吗? – spaleja 2013-03-15 09:54:01

-4

我相信这样做的方法是使用计时器。

参考:How Do I write a Timer in Objective-C?

现在,这就是我代表连接间隔。你可以在你的回调函数中使用这个函数: - (void)peripheral:(CBPeripheral *)peripheral didUpdateValueForCharacteristic :(CBCharacteristic *)characteristic error:(NSError *)error

另外,从Corebluetooth框架来看,没有办法从中央端更新连接间隔。

但是,我感兴趣的是您的信息如何用于连接间隔henrik。

+0

嗨,我已经通过在单个连接间隔发送多个数据包找出解决方案。 – spaleja 2013-04-23 07:06:06

1
[_manager setDesiredConnectionLatency:CBPeripheralManagerConnectionLatencyLow forCentral:_central]; 

我在创建的iOS外设应用程序中使用了此方法。尽管如此,你仍然不能低于20ms。非常令人沮丧,因为我需要低于16ms。除非它是HID配置文件(它们允许11.25ms),否则现在看起来不可能 - 但您无法从iOS设备创建HID配置文件。

If you have an iOS device on the other end of your Bluetooth Smart link, Apple imposes its own restrictions on the minimum connection interval. This value is 20ms rather than the official Bluetooth 4.0 specification minimum of 7.5ms. Apple does this to ensure that a single app doesn't take over all available bandwidth on the Bluetooth hardware, and/or kill the battery too quickly. For details on this restriction, see the Connection Parameters section on page 18 of the Apple Bluetooth Design Guidelines (PDF).

Note that iOS does not allow you to set or request connection parameters from the iOS end of things. The CoreBluetooth CBCentralManager object's connectPeripheral method takes an "options" parameter, but this does not include connection parameters. Instead, the slave must request a connection update with new desired parameters after connecting, and then iOS will either accept or reject them based on the criteria in the Design Guidelines document linked above.