I used two iphones to transfer data via Bluetooth, and the MTU used 512 bytes.I got 56bps in withResponse mode and around 200bps in withoutResponse mode.I wonder how to achieve a faster rate.Let's say LE 1Mbps mode or LE 2Mbps mode.My central device and peripheral device are both iPhone, I don't know if there is a limit between them.My goal is just to know how can I achieve a faster rate
1、Two iphones connected to Bluetooth 2、Test separately with withoutResponse and withResponse 3、Calculate the transmission rate per second 4、In withoutResponse mode, the peripheral receives about 46 packets of 512 bytes per second 5、In withResponse mode, the peripheral receives about 13 packets of 512 bytes per second 6、So I get rates of 56bps and 200bps
While we a have a number of recommendations on how to make Bluetooth connections more efficient, controlling Bluetooth transfer rate when using two iPhones is a bit more difficult, because, unlike when you are communicating with a BLE accessory which you may have access to their firmware, you would not be able to control certain connection parameters on an iPhone, which contribute to the overall transfer rate. Additionally, the connection parameters chosen by a specific iPhone at a specific time will not be the same as another iPhone at another time, because iOS may choose certain parameters that are optimum for various things, like power savings, device state, and also to work without interfering whatever else might be going on on the device at the time. And not necessarily choose the optimum settings for the fastest transfer rate. Also things might change between iPhone models and iOS versions.
Because of all this, even if you were to establish a goal transfer rate in your tests, you cannot guarantee that the conditions your users will be using your app in will be similar.
But in any case, here are some things you can and cannot change for better transfer rates.
- your best action for better rates will be to use Write Without Response. You have already seen the gains of this
- while using a larger MTU would make things faster, you do not have any control over this, and the two iPhones will negotiate the best MTU between each other when connecting
- depending on the device's capabilities, the iPhones may choose to use Extended Data Length, which will increase the rate. Unfortunately this is also not something you can control
- what you can do to optimize your writes is to use the
canSendWriteWithoutResponse
property of theCBPeripheral
object, and/or implement theperipheralIsReady(toSendWriteWithoutResponse:)
callback method to know and time your writes (without response) optimally - another big gains will be by using
L2CAP
connection oriented channel, which bypasses the overhead ofGATT
transfers, and allows for larger blocks of data transfers. Working with L2CAP Channels - then we have the use of a faster connection interval, which unfortunately cannot control with two iPhones
- and also LE 2Mbps mode, which again is not controllable by an app.
So, to summarize: use write without response, and time for optimum write times by using peripheralIsReady(toSendWriteWithoutResponse:)
. And implement L2CAP
for your data transfers. These are the things you can control when using Bluetooth to transfer data between two iOS devices.
Argun Tekant / DTS Engineer / Core Technologies