BLE data throughput
Can anyone offer any general tips for achieving the maxumum data rate over BLE? This page claims it can do 2.1Mbps (http://doc.qt.io/qt-5/qtbluetooth-index.html)
I'm trying to load a flash device over BLE and it's going painfully slow (I haven't measured but I think I'm doing around 2kbps). It goes much faster when I use the CySmart app to do the transfer.
Do you mean Bluetooth or Bluetooth Low Energy ?
I mean bluetooth low energy. This is for an OTA bootloader for the Cypress PSOC4 device. It has a command/response protocol that is implemented over writing a characteristic and receiving the response via notification. It loads pretty fast using their Cysmart app but I'm getting nowhere near that speed with my app running on my phone. I am using the QLowEnergyService C++ class for characteristic writes and signal/socket to receive responses. I started with the heart rate monitor example and built my project from there.
One of the issues is that it allows me to set the attribute MTU size pretty high (I have it at 512 bytes). However, If I try to write a message larger than 128 bytes in my app, I get problems. I don't see anywhere in the QT BLE API to adjust the maximum MTU size.
I doubt that is the only problem with my throughput, though because I'm much more than a factor of four slower than the CySmart app.
AFAIK, BLE is not designed for hight throughput, quiet the contrary. Thus I wonder if their app is not doing something else in parallel.
I'd rather go through the sources of the qtconnectivity module to see if there's something related.
I only have 262kB to send (or less). At 2kbps, that's 17 minutes, which is unreasonable to ask someone to keep their phone awake to flash a software update. If I can get it to 20-40kbps, I'll be in business. I'm not asking for it to scream, i just need it to not be pitifully slow.
Here is an interesting article on the subject, which seems to indicate that this is within reason: https://punchthrough.com/blog/posts/maximizing-ble-throughput-on-ios-and-android.
What is qtconnectivity module?
Isn't that rather a bit more than two minutes ?
You may have to tweak Qt yourself if there's anything doable regarding that speed ?
I had a mix of bits and bytes in that statement. 262 kB (kilo bytes) at 2kbps (kilo bits per second) takes around 17 minutes.
Looking it it another way, the link layer payload is 27 bytes and the connection interval is 7.5 ms (these are the best settings that are supported in my case). If it sends one link layer packet per connection interval, then it would do 3.6kBps or 28.8kbps. I'm falling far short of that mark.
I noticed in the cypress device's settings, that there is a parameter called "Slave latency", which the documentation describes as "Defines the latency of the slave in responding to a connection event in consecutive connection events. This is expressed in terms of multiples of connection intervals, where only one connection event is allowed per interval."
I tried setting this to zero (it was at 25) but that didn't seem to make any difference. Perhaps the QT side has a similar parameter. This would certainly explain the discrepancy between what I'm getting and what I should be able to get without doing anything fancy.
Also, the 128-byte attribute MTU limit that QT seems to be imposing is driving up my packet protocol overhead a bit as well. I could squeeze out a little more throughput that way. I think this will give me about a 10% boost, which won't really get me to a happy place, but it will certainly help.
@kgregory how did you manage to set the MTU using Qt? Or is that set by your device?