I'm trying to write BLE Android app. I found that sometimes when I call BluetoothGatt.writeDescriptor() it returns false.
I have not found in documentation any note of limitation to this function. But ppl on stack overflow says that I need to wait for BluetoothGattCallback.onDescriptorWrite() before I try to write another descriptor.
Here is one reply saying that BLE is busy with writeDescriptor() and can not do other write.
Here is another thread saying that you can not call twice writeCharacteristic().
My questions are
- is it really true?
- is there really missing some internal android API buffer for serializing BLE requests and every developer has to do it on it's own?
- Is it true for different functions? For example when I call
writeDescriptor()
I understand I can not call second timewriteDescriptor()
before I receiveonDescriptorWrite()
. But do I have to wait foronDescriptorWrite()
when I want to callwriteCharacteristic()
? - Also if there is inter-function dependency then what else function have this limitation (namely:
readCharacteristic()
,readDescriptor()
,requestMtu()
...)? - And additionally is there interdependency between BluetoothGattServer and BluetoothGatt. So for example when I call
BluetoothGattServer.notifyCharacteristicChanged()
shall I wait forBluetoothGattServerCallback.onNotificationSent
before I can callBluetoothGatt.writeDescriptor()
orBluetoothGatt.writeCharacteristic()
? (BTW praise for google documentationonNotificationSent()
is by luck documented properly. Doc says:
When multiple notifications are to be sent, an application must wait for this callback to be received before sending additional notifications.
- Lastly having all this questions - I feel that Android BLE API is under-documented. Or am I wrong and there is documented somewhere what are allowed methods calling sequences? If yes can you please point me to such documentation? If not is there some channel we can open issue with google and ask them to add to documentation something? I mean it may not be much text - some function like
onNotificationSent()
is arleady properly documented. They just need to copy this sentence to other functions.