Android BLE - How is large characteristic value read in chunks (using an offset)?

那年仲夏 提交于 2019-12-11 02:03:37

问题


I am working with the Android SDK's android.bluetooth and android.bluetooth.le APIs.

I want to implement an app (takes central role, and connects to a BLE peripheral to read characteristic values and descriptors).

The characteristic value that the app needs to read is large, and therefore it needs to read it in successive chunks. My understanding of how this is achieved is that the app should include an offset in read requests which indicates to the peripheral the sub-portion of the total data to return in the response.

However, the API only provides a BluetoothGatt.readCharacteristic(BluetoothGattCharacteristic) method. I cannot find a read characteristic API call that includes an offset argument, for making the type of partial read characteristic request I describe in the previous paragraph.

Does anyone know how I achieve these chunked characteristic reads?

Note: I'm aware that there's a similar stack-overflow question here. It didn't provide answer for the Android aspect I'm dealing with.


回答1:


Just call readCharacteristic and it will in the background read all chunks. When all chunks are read, onCharacteristicRead will be called.



来源:https://stackoverflow.com/questions/38640908/android-ble-how-is-large-characteristic-value-read-in-chunks-using-an-offset

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!