dav*_*d72 1 android ios bluetooth-lowenergy
从文档中我看到如何编写没有这样的响应:
BluetoothGattCharacteristic characteristic = ...
characteristic.setValue(bytes);
mBluetoothGatt.writeCharacteristic(characteristic);
Run Code Online (Sandbox Code Playgroud)
如何使用响应执行写请求操作?
(在iOS中,可以选择写入类型CBCharacteristicWriteWithResponse和CBCharacteristicWriteWithoutResponse)
检查特征是否可写:
(characteristic.getProperties() & (BluetoothGattCharacteristic.PROPERTY_WRITE | BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE))) != 0
Run Code Online (Sandbox Code Playgroud)
从文档:
public void setWriteType (int writeType)
在 API 级别 18 中添加 设置此特性的写入类型
设置特性的写入类型决定了 writeCharacteristic(BluetoothGattCharacteristic) 函数如何写入该特性。
参数 writeType 此特性的写入类型。可以是以下之一:WRITE_TYPE_DEFAULT、WRITE_TYPE_NO_RESPONSE 或 WRITE_TYPE_SIGNED。
| 归档时间: |
|
| 查看次数: |
3908 次 |
| 最近记录: |