Reputation: 329
I am trying to write to a characteristic of a BLE device. According to the documentation, the characteristic is capable of read and write, with different usages. I was already successful with reading from it but i am having some problems with write. Every time i try to write to it the onWriteCharacterstic function arrives with a status code 6, which is supposed to be GATT_REQUEST_NOT_SUPPORTED.
I am not really sure what can cause it. I added all the necessary bluetooth permission to my app, and the documentation states that it is capable of write.
My code looks somewhat like this (simplified):
@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
}
I also made some check with the functions getProperties() and getPermissions() for the characteristic. The getPermissions() function returns 0, which i couldn't match to anything in the android documentation, and the getProperties() returns 10, which is also weird. With properties it would mean that it supports notifications, which it doesn't.
Upvotes: 1
Views: 894
Reputation: 329
It seems like it was a problem with the phone. After it had it's bluetooth turned off for a few hours it worked correctly.
Upvotes: 1