0
我想写入BLE设备的特性。根据文档,该特性可以读写,具有不同的用途。我已经成功地阅读了它,但我在写作方面遇到了一些问题。每次我尝试写入它时,onWriteCharacterstic函数都会以状态码6到达,这应该是GATT_REQUEST_NOT_SUPPORTED。bluetoothgatt onCharacteristicWrite返回状态代码6与ble设备
我不太确定是什么原因造成的。我将所有必要的蓝牙许可添加到了我的应用程序,并且文档声明它具有写入功能。
我的代码看起来有点像这样(简化):
@Override
public void onServicesDiscovered(BluetoothGatt gatt, int status){
if(status == BluetoothGatt.GATT_SUCCESS){
mGatt = gatt;
mService= gatt.getService(UUID_SERVICE);
mChar = mService.getCharacteristic(UUID_CHAR);
byte[] value = {...}
mChar.setValue(value);
boolean retval = mGatt.writeCharacteristic(mChar); //retval is true
}
}
@Override
public void onCharacteristicWrite (BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status)
{
... //status here is 6
}
我也做了一些检查与功能的GetProperties()和getPermissions()的特点。 getPermissions()函数返回0,我无法与android文档中的任何内容匹配,并且getProperties()返回10,这也很奇怪。使用属性意味着它支持通知,而不支持。