gpt4 book ai didi

Android BluetoothGatt writeCharacteristic 与响应

转载 作者:行者123 更新时间:2023-11-29 14:21:34 26 4
gpt4 key购买 nike

从文档中我看到如何在没有响应的情况下这样写:

BluetoothGattCharacteristic characteristic = ...
characteristic.setValue(bytes);
mBluetoothGatt.writeCharacteristic(characteristic);

如何执行带有响应的写入请求操作?

(在 iOS 中有选择写入类型 CBCharacteristicWriteWithResponse 和 CBCharacteristicWriteWithoutResponse 的选项)

最佳答案

  1. 您的特征应该是可写的。

检查特征是否可写:

(characteristic.getProperties() & (BluetoothGattCharacteristic.PROPERTY_WRITE | BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE))) != 0
  1. > BluetoothGatt.writeCharacteristic()返回指示写入是否成功的 bool 标志(如果成功则为真)。
  2. 一旦 BluetoothGatt.writeCharacteristic 成功 BluetoothGattCallback.onCharacteristicWrite()使用具有您指定值的特征执行回调。

关于Android BluetoothGatt writeCharacteristic 与响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30200871/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com