5

I am having performances issues when doing several consecutive GATT read using the Android BLE API.

I can read about 10 packets per second just for about 5 or 6 seconds. After I read the ~65's packet the throughput decreases to about 1 packet each 1.5 second.

I did several tests and it seems that the internal BLE is getting really slow. On that case it takes about 750ms from the Java GATT read call to the peripheral (there is no bottleneck in the peripheral) and about the same, 750ms, back to the Java API callback.

It seems to me to be poor BLE stack implementation, because when I disconnect from the device (probably some resources are cleaned up) and then reconnect back I can reproduce the same issue: It reads about 10 packets/s for the first 5 or 6 seconds (~65 packet reads) only, then it becomes slow.

I tested it with Galaxy S4 and Nexus 4 devices. Same with both.

Any suggestions on how to improve it?

Felipe Tonello
  • 290
  • 3
  • 11
  • It may be that the BLE device is requesting to slow down its connection interval so save power. On a device where I know the connection interval is fast I can keep reading and writing at that high speed indefinitely (All the way down to about 7.5ms, but there ends up being a lot of retries at that speed). – Douglas Jones Dec 05 '14 at 15:05
  • It is not my case here, because I use BlueZ and iOS to request the same thing at high speed no problem. What version of Android are you using? – Felipe Tonello Dec 08 '14 at 19:45
  • I'm using versions from 4.3 up through 5.0 on a variety of devices and I regularly do large data transfers that run at about the same time as it takes on iOS. Can you post the code? – Douglas Jones Dec 08 '14 at 23:41
  • I used 4.4, didn't try 5.0 yet. And I unfortunately can't share the code, but I can assure you that I followed the same pattern of the Google's BLE example project, which I hope is the best practice. Perhaps you know a better way to implement then Google presented? – Felipe Tonello Dec 09 '14 at 01:29
  • I understand not being able to share code. I went and had a look at the sample demo here: http://developer.android.com/guide/topics/connectivity/bluetooth-le.html If that is what you are doing then right off the bat I'd say sending an intent for everything that comes in will slow things down somewhat. I use onCharacteristicChanged and read the value directly out of that. Aside from that I didn't see anything out of the ordinary. – Douglas Jones Dec 09 '14 at 13:53

1 Answers1

4

I hope since the Jun 5 2014, you find a solution to your problem. I also have the same issue. The first 2 ~ 3 seconds, I receive data in ~100ms. After, I receive data each ~2000ms. I test on 4.3 and above device.

I found for Lollipop version and above the requestConnectionPriority on BluetoothGatt. I have't find solution for 4.* version. If any one have suggestion.

Hope this help someone with bluetooth trouble on data transfer !