Android BLE - 如何分块读取大特征值(使用偏移量)?

标签 android bluetooth-lowenergy

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

我想实现一个应用程序(发挥核心作用,并连接到 BLE 外设以读取特征值和描述符)。

应用需要读取的特征值较大,因此需要分块连续读取。我对如何实现这一点的理解是,应用程序应该在读取请求中包含一个偏移量,该偏移量向外围设备指示要在响应中返回的总数据的子部分。

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

有谁知道我如何实现这些分块特征读取?

注意:我知道有一个类似的堆栈溢出问题 here 。它没有为我正在处理的 Android 方面提供答案。

最佳答案

只需调用 readCharacteristic,它就会在后台读取所有 block 。当所有 block 被读取时,onCharacteristicRead将被调用。

关于Android BLE - 如何分块读取大特征值(使用偏移量)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38640908/

相关文章:

android - 由于@NotNull 参数 'aFileName' 为空,Gradle 无法同步

android - 通过模拟器发送电话号码

android - 从浏览器填写 http 表单和在 Android 中使用 httppost 之间的区别

java - 以编程方式与计算机建立无服务器蓝牙连接

linux - BlueZ:移除与 BLE 设备的绑定(bind)不起作用

java - "cannot find symbol method setOnDismissListener(<anonymous OnDismissListener>)"

android - 多次打开应用程序后字体不可读

android - 获取蓝牙适配器时出现 Lint 错误

ios - Ellisys蓝牙嗅探Apple Airpods

android - onCharacteristicWrite 如何知道 Android 中的状态是成功的?