Android BLE - How is large characteristic value re

2019-07-12 00:54发布

问题:

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.