iOS Bluetooth Low Energy and Custom Hardware — Part 3: Optimizing Data Throughput


Bluetooth Low Energy (BLE) offers great battery life, but the tradeoff is lower data throughput or transfer rate. Although the data throughput is lower, it should be enough to meet the needs of many of your projects.

 

There might be times that you wished; you can get a higher data throughput with BLE. You can achieve higher data throughput by optimizing for how BLE communication works. Therefore, the focus of this post is to go over how you can optimize BLE data throughput.


 

Classic Bluetooth vs. Low Energy Bluetooth

There are major differences with how BLE and classic BT works, but that is not the point of this post. The one difference between classic BT and BLE that does matter here is the data throughput. Classic BT can transfer data at megabits per second, while BLE is at kilobits per second. If your hardware requires transferring a large amount of data, then BLE might fail to meet your demand.

 

If you are considering classic BT over BLE, there is something important you have to consider and that is accessibility. The Core Bluetooth Framework only supports BLE, classic BT is in the External Accessory Framework. There is a catch to using the external accessory framework and that is your hardware must be MFI (made for iPhone, iPod, or iPad) certified.

 

Factors That Influence Data Throughput

There are many factors that can affect BLE data throughput. Some are restrictions that you as a developer cannot control, while others you can. Four main factors that influence data throughput the most. They are Operating System (OS), Connection Interval, Number of Packets per Interval, and BLE version.

 

OS

The operating system directly influences the data throughput possible by enforcing the upper bound of data throughput. For example, with iOS, the system defaults to 30 milliseconds connection interval and allows up to four data packets per connection interval.

 

Connection Interval

Connection interval is the period when the Central and Peripheral communicates with each other. For iOS, the connection interval is set to 30 milliseconds. There are exceptions, but that is going into MFI territory.

 

Number of Packets per Interval

The number of packets per interval is the number of data packets allowed to be sent or received every connection interval. The data packet size varies depending on which version of BLE you are using.

 

Version of BLE

The version of BLE you are using will dramatically affect your data throughput. For example, with BLE v4.0 and v4.1, the maximum size of a data packet payload is 20 bytes excluding headers. With BLE v4.2, the maximum payload is 251 bytes excluding headers.

Comparison between the data packet structure of BLE v4.0 and v4.2.

 

Maximizing Throughput

There are many limitations enforced by iOS, but it is still possible to optimize the data throughput. The simplest way is to use at least BLE v4.2 for your custom hardware. Another way is to max out how much data you can send per interval connection.

 

To take full advantage of each connection interval, you must understand the relationship between the number of packets and connection interval. The best way to explain this concept is by examples.

Single packet per connection interval

 

Multiple packets communication per connection interval

Optimizing Throughput Example

Suppose the payload is 90 bytes, the number of packets per connection interval is four, and you are using BLE v4.0. Within one interval connection, the max payload is 80 bytes split into 4 packets of 20 bytes. This leaves 10 bytes leftover, which is sent on the next connection interval. Now change the payload to 160 bytes and you get 8 data packets to send over two connection intervals. Notice that in both scenarios, it takes two connection intervals (60 milliseconds) to transfer the data, except in one case more data got through.


 

I hope you found this post helpful. If you found this post helpful, share it with others so they can benefit too.

 

What are your experiences working with iOS and BLE? Do you find the throughput of BLE on iOS to be enough?

 

To stay in touch, follow me on Twitter, leave a comment, or send me an email at steven@brightdevelopers.com.

 

Additional Resources


About Steven To

Steven To is a software developer that specializes in mobile development with a background in computer engineering. Beyond his passion for software development, he also has an interest in Virtual Reality, Augmented Reality, Artificial Intelligence, Personal Development, and Personal Finance. If he is not writing software, then he is out learning something new.