15
votes

I remember reading in the "Guide and Hint"-doc to the Samsung BLE API (archived page):

One of the most important concepts of the Samsung F/W and stack is its synchronous nature. That is, if we call for example, writeCharacteristic for a particular characteristic, if it returns true, the next call to any BluetoothGatt or BluetoothGattServer method should be done after the onCharacteristicRead callback is received. This is because the stack is designed to support and process only one GATT call at a time, and if, for example, you call writeCharacteristic or readCharacteristic on any characteristic soon after the first one, it is ignored.

  1. Does that also apply to the native implementation of BLE introduced in Android 4.3?
  2. Samsung API also supports only one connected GATT device at a time. Has this changed in the native API?
2
There's an ongoing thread related to the synchronous nature of the API on Google's issue tracker: code.google.com/p/android/issues/detail?id=58381Ash Eldritch
I've just implemented a queue for all writes and this seems to be working well so far.Ash Eldritch
@Ash According to the docs provided by SAMSUNG, the behavoir isn't limited to write operations. Yes, using a queue is a common way to solve that problem. 'working well so far': It's hard to test and reproduce the cancelling of a command by another. Often times you will encounter problems once your BLE code gets more complex, because you do more stuff based on previous calls. I only do the next BLE operation after the one before finished (received answer) or after the one before failed to finished in an appropriate time. By the way, your comments would suit better as an answer to this question.OneWorld
@Ash can you share your implementation ?Ewoks

2 Answers

18
votes

Samsung recently published a "migration"-document on the same page I linked in my question. They exactly answer my question while comparing the new native BLE API with the Samsung BLE API:

The synchronous nature of the stack and F/W hasn’t been affected. That is, if we call for example, writeCharacteristic for a particular characteristic, if it returns true, the next call to any BluetoothGatt or BluetoothGattServer method should be done after the onCharacteristicRead callback is received. This is because the stack is designed to support and process only one GATT call at a time, and if, for example, you call writeCharacteristic or readCharacteristic of any characteristic soon after the first one, it is ignored.

-2
votes
  1. No. most of the function calls are asynchronous.
  2. I don't know. Official docs doesn't mention it but it doesn't say that it supports only one device either. I believe it's possible to do it. Check this article: http://blog.lemberg.co.uk/getting-bottom-android-bluetooth-low-energy-api#.UfvK6ZK-1cY

It says (I don't know what its source is) that multiple peripheral devices can connect to one Android Central device