Android: BLE how to read multiple Characteristics?

前端 未结 3 780
予麋鹿
予麋鹿 2020-12-05 01:24

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 requ

3条回答
  •  春和景丽
    2020-12-05 01:33

    Pseudo code:

    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.

提交回复
热议问题