Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to maximize throughput for BLE on iOS by sending more than 1 packet per connection interval?

How is it possible to send more than 1 packet per connection interval on iOS to a Bluetooth LE (BLE) device?

I am connecting from iOS [iPhone 6 with iOS 10.3] to Microchip BM70 BLE. I have read articles like https://punchthrough.com/blog/posts/maximizing-ble-throughput-on-ios-and-android as well threads like https://lists.apple.com/archives/bluetooth-dev/2015/Apr/msg00026.html and have implemented code such that it:

  1. Connects to the device
  2. Gets the appropriate Write Characteristic.
  3. Gets the Peripheral's Max Write Length for WithoutResponse (157)
  4. Creates packets of 157 bytes.
  5. And then send the packets via Peripheral's WriteValue method using Write WithoutResponse.

If I just write full blast, iOS stops sending data after about 20 packets. If I sleep 150ms after every 4 packets, it sends correctly. If I sleep 35ms after each packet, then it sends correctly, too. If I send 18 packets and then send 19th packet as Write WithResponse + call back handler, then it sends the packets correctly, too.

However, when I look at the logic analyzer, the data is being sent correctly but only 1 packet is being sent per connection interval [30ms]:

logic analyzer snippet of BLE packets

Is there some other setup I need to do in my CBPeripheral or CBCentralManager to be able to send more than 1 packet per connection interval?

Thanks!

like image 870
DannyAtFTECU Avatar asked Nov 29 '25 07:11

DannyAtFTECU


1 Answers

If you are facing issues on disconnecting central and peripheral, I would recommend to use write with response, and send the second set of data on successful callback received from Peripheral after writing data. This is better rather than waiting for 150 ms after 4 packets, if you are focusing on increasing the throughput.

Also, iOS will adjust MTU size with the peripheral to send maximum possible packets in one connection. [This is from the experiment that i did using iPhone (Central application) and Linux/Android (Peripheral Application)]. On connecting with Xiomi Mi A1, the MTU got adjusted to 185 as per the request from iPhone application to peripheral. However you cannot programatically give custom value to MTU size, as API s for editing MTU is private and hidden from public APIs.

With iPhone 8 as central and Android with BLE 4.2 as Peripheral, the throughput that we could achieve is 2.5 KiloBytes per sec.

like image 153
Sudhin Philip Avatar answered Dec 01 '25 21:12

Sudhin Philip