Android BLE-如何以块(使用偏移量)读取大特征值? [英] Android BLE - How is large characteristic value read in chunks (using an offset)?

查看:140
本文介绍了Android BLE-如何以块(使用偏移量)读取大特征值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Android SDK的 android.bluetooth android.bluetooth.le API.

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

我想实现一个应用程序(担当中心角色,并连接到BLE外设以读取特征值和描述符).

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.

但是,API仅提供 BluetoothGatt.readCharacteristic(BluetoothGattCharacteristic)方法.我找不到包含偏移量参数的读取特征API调用,以进行上一段中所述的部分读取特征请求的类型.

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?

注意:我知道存在类似的堆栈溢出问题这里.它没有提供我正在处理的Android方面的答案.

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.

推荐答案

只需调用readCharacteristic,它将在后台读取所有块.读取所有块后,将调用onCharacteristicRead.

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

这篇关于Android BLE-如何以块(使用偏移量)读取大特征值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆