Android BLE API methods for reading some characteristics are Asynchronous in nature and when you request some value, your GATT callback method is called.
If you request multiple read characteristics values it just simply discards others until it doesn't entertained the first request.
I didn't understand if that so why they made methods Async. If someone know which design pattern we should adapt to solve this problem please share.
If you want to read some characteristics then you have to request it.
// new value available will be notified in Callback Object
public void onCharacteristicRead(BluetoothGatt gatt, android.bluetooth.BluetoothGattCharacteristic characteristic, int status)
1) Use a FIFO Queue or Priority Queue depends upon your business logic
2) insert all the characteristics you want to read
3) call your requestCharacteristics method so that it can start consuming your Queue
4) from your
onCharacteristicsRead call see if the size of the queue is greater than Zero request one more.. be sure to
peek() from here
5) now on your requestCharacteristics method do the
poll() and request BLE GATT for characteristic.