BLE (Bluetooth Low Energy) transfer file

Hello fellow developers,

I’m currently working on an app for controlling electric vehicle charging stations, and I’ve encountered some issues related to Bluetooth file transfer that I hope you can help with.

For the OTA (Over-the-Air) update feature in this app, we need to transfer files via Bluetooth. These files are in .bin format and range in size from 1MB to 10MB. I’ve heard that Classic Bluetooth on iOS requires certification to use—is this true? If so, what are the general processes and requirements for this certification?

Additionally, when considering BLE (Bluetooth Low Energy) for this purpose, we face challenges with transfer speed as well as file fragmentation and reassembly. Are there any optimization strategies for transferring large files over BLE that can improve speed while ensuring the integrity and accuracy of file fragmentation and reassembly?

Finally, I’m wondering if there are any Bluetooth file transfer-related demos available for reference, especially sample code for iOS that handles file sizes and formats similar to what I described. This would be extremely helpful for resolving my current issues.

Thank you very much for taking the time to read my questions. I look forward to your valuable advice and experience sharing.

Answered by Engineer in 855096022

Yes, data transfer over Bluetooth Classic requires MFi certification. You can find all the info you need about the MFi Program at https://mfi.apple.com

As for performance over BLE, while the theoretical limit may be less than that of BR/EDR (Classic), there are ways to improve whatever throughput you are getting today by a careful implementation of your transfers on both the app and the Bluetooth device.

First, you will want to implement the data transfer with Write-without-response writes. If your chipset allows it and you fine tune your connection intervals, you may be able to write 4+ packets within one connection interval, and this will give you more than 10x the throughput compared to using write-with-response where you use up 2 connection intervals per packet written.

The next step would be to use Extended Data Length (increase the max packet length from 27 to 251) if you chipset supports it, by making a Data Packet Length Extension request.

Once that's done, your device can then request to use a larger MTU. Although establishing the larger MTU is not guaranteed and depends on the state and resources of the iOS device at the time. If established, these will give you another 2-3x throughput.

For large data transfers, what you should be doing in your app is to use L2CAP. L2CAP reduces the protocol overhead used by GATT. If you were not aware of this, it is documented at https://developer.apple.com/documentation/corebluetooth/cbl2capchannel

Once you have done all this, you then want to fine tune the Connection Interval requested by your device. You can request as fast as 15ms intervals, although it is not guaranteed that iOS will accept this every time (again, depending on state and resources). If you are sending multiple packets per interval, faster is not always better. The interval and the other connection parameters like MTU, timeout, etc. should be fine tuned for your requirements, and the exact abilities of the chipset on your device. In general, more packets on a slower interval might be better than less packets on a faster interval. I would suggest to test, fine tune, test, repeat...

Another factor that will have a high impact on throughput is the use of 2M PHY, again, if your chipset can support it.

With all this, you may find that the BLE throughput you are able to attain could be enough for your use case.


Argun Tekant /  DTS Engineer / Core Technologies

Accepted Answer

Yes, data transfer over Bluetooth Classic requires MFi certification. You can find all the info you need about the MFi Program at https://mfi.apple.com

As for performance over BLE, while the theoretical limit may be less than that of BR/EDR (Classic), there are ways to improve whatever throughput you are getting today by a careful implementation of your transfers on both the app and the Bluetooth device.

First, you will want to implement the data transfer with Write-without-response writes. If your chipset allows it and you fine tune your connection intervals, you may be able to write 4+ packets within one connection interval, and this will give you more than 10x the throughput compared to using write-with-response where you use up 2 connection intervals per packet written.

The next step would be to use Extended Data Length (increase the max packet length from 27 to 251) if you chipset supports it, by making a Data Packet Length Extension request.

Once that's done, your device can then request to use a larger MTU. Although establishing the larger MTU is not guaranteed and depends on the state and resources of the iOS device at the time. If established, these will give you another 2-3x throughput.

For large data transfers, what you should be doing in your app is to use L2CAP. L2CAP reduces the protocol overhead used by GATT. If you were not aware of this, it is documented at https://developer.apple.com/documentation/corebluetooth/cbl2capchannel

Once you have done all this, you then want to fine tune the Connection Interval requested by your device. You can request as fast as 15ms intervals, although it is not guaranteed that iOS will accept this every time (again, depending on state and resources). If you are sending multiple packets per interval, faster is not always better. The interval and the other connection parameters like MTU, timeout, etc. should be fine tuned for your requirements, and the exact abilities of the chipset on your device. In general, more packets on a slower interval might be better than less packets on a faster interval. I would suggest to test, fine tune, test, repeat...

Another factor that will have a high impact on throughput is the use of 2M PHY, again, if your chipset can support it.

With all this, you may find that the BLE throughput you are able to attain could be enough for your use case.


Argun Tekant /  DTS Engineer / Core Technologies

我想问一下您在文件传输过程中是否遇到过任何连接中断问题。如果没有,您能告诉我文件传输的时间间隔吗?

BLE (Bluetooth Low Energy) transfer file
 
 
Q