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,這也很奇怪。使用屬性意味着它支持通知,而不支持。