Connection Interval Core Bluetooth

后端 未结 3 1590
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-21 01:28

Is there any way to change connection interval through Core Bluetooth? I am transferring chunks of data to Peripheral and it\'s talking much time to transfer the data. I want to

相关标签:
3条回答
  • 2021-01-21 01:36

    Only by sending connection parameter update from your Peripheral to iOS. Min:20ms (parameter=16) Max:40 (parameter=32) is best legal parameters according to CoreBluetooth. Actually you will get better performance with Min=10 Max=20 or 30 from which CoreBluetooth will select approximate 20ms instead of 30ms Annoying we cannot set it.

    0 讨论(0)
  • 2021-01-21 01:41

    I believe the way to do this is to use a Timer.

    Refer to: How Do I write a Timer in Objective-C?

    For now, that is how I represent the connection interval. You can use this within your callbacks in the function: - (void)peripheral:(CBPeripheral *)peripheral didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error

    Also, judging from the Corebluetooth framework, currently there is no way of updating the connection interval from the Central side.

    However, I am interested in how your information for the connection interval, henrik.

    0 讨论(0)
  • 2021-01-21 01:53
    [_manager setDesiredConnectionLatency:CBPeripheralManagerConnectionLatencyLow forCentral:_central];
    

    I used this method on the iOS Peripheral app I created. You still can't get below 20ms though. Very frustrating as I need to be below 16ms. Doesn't look possible for now unless it's a HID profile (they allow 11.25ms) — but you can't create a HID profile from an iOS device.

    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.

    0 讨论(0)
提交回复
热议问题