Android: BLE how to read multiple Characteristics? Android: BLE how to read multiple Characteristics? android android

Android: BLE how to read multiple Characteristics?


Pseudocode:

  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 requests one more.. be sure to peek() from here

  5. now on your requestCharacteristics method do the poll() and request BLE GATT for characteristics.


You might have discovered it yourself already, but it might be useful for others.

I didn't understand if that so why they made methods Async.

They probably did it because sending a read-request to another device in synchronous execution would mean you cannot do anything with your app until an answer is received. By making it Async you can do other stuff, but no other bluetooth requests.