从文档中,我看到了如何在没有响应的情况下这样写:
BluetoothGattCharacteristic characteristic = ...
characteristic.setValue(bytes);
mBluetoothGatt.writeCharacteristic(characteristic);
如何执行带有响应的写请求操作?
(在iOS中,可以选择写入类型CBCharacteristicWriteWithResponse和CBCharacteristicWriteWithoutResponse)
最佳答案
检查特征是否可写:
(characteristic.getProperties() & (BluetoothGattCharacteristic.PROPERTY_WRITE | BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE))) != 0