خرید بک لینک

Vote count: 0

I want to write an Android Bluetooth Low Energy app that involves multiple GATT characteristic read and write (e.g., firmware over-the-air update). The timing and sequence of the operations is crucial, meaning that the next read/write should be initiated after the previous read/write is acknowledged in the GATT callback. Something similar to the "async" module in Node.js will do. However, in Android, all GATT callbacks are defined in a single "BluetoothGattCallback" class. My understanding is the GATT callback function needs to know what the content of the previous read/write in order to initiate the next read/write properly. And the code for this state machine can be a mess if the number of operations is big. Is there a better way of doing this?

PS: I check the documentation for functions like "BluetoothGatt.writeCharacteristic", which retus a Boolean indicating the status. However, retuing "true" only means "write operation was initiated successfully" not necessarily completed successfully. I still need the callback [onCharacteristicWrite](https://developer.android.com/reference/android/bluetooth/BluetoothGattCallback.html#onCharacteristicWrite(android.bluetooth.BluetoothGatt, android.bluetooth.BluetoothGattCharacteristic, int)) to confirm the write success.

asked 45 secs ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 12 تير 1395 ساعت: 1:57

صفحه بندی