Android Bluetooth status 133 in onCharacteristicwrite
Here the error/success status code and meaning
GATT_ILLEGAL_PARAMETER
0x0087
(135)GATT_NO_RESOURCES
0x0080
(128)GATT_INTERNAL_ERROR
0x0081
(129)GATT_WRONG_STATE
0x0082
(130)GATT_DB_FULL
0x0083
(131)GATT_BUSY
0x0084
(132)GATT_ERROR
0x0085
(133)GATT_CMD_STARTED
0x0086
(134)GATT_PENDING
0x0088
(136)GATT_AUTH_FAIL
0x0089
(137)GATT_MORE
0x008a
(138)GATT_INVALID_CFG
0x008b
(139)GATT_SERVICE_STARTED
0x008c
(140)GATT_ENCRYPED_MITM
GATT_SUCCESS
GATT_ENCRYPED_NO_MITM
0x008d
(141)GATT_NOT_ENCRYPTED
0x008e
(142)
For those who may find this post as a result of a status 133 onCharacteristicWrite, I found that we get this 133 result in because the remote device disconnected. I lost a lot of time looking for a problem on the Android side, only to discover later that the problem was on the other side.
From this I gather that status = 133 seems to be some sort of undocumented generic cause for error.
I had a similar issue when I tried to write to some characteristic I can't remember though if i got the same error code or not. (And it worked on some devices while it didn't on others).
What turned out to be the problem is the property
of the characteristics
and the writeType
.
Because characteristics can have values set:
write without response
ORwrite with response
In reference to this property you have to set the writeType
before writing the actual data to the characteristic.
You can set the type once you get the Characteristic but before writing to it.
BluetoothGattCharacteristic tChar = syncService.getCharacteristic(SYNC_HEIGHT_INPUT_CHAR);
if (tChar == null) throw new AssertionError("characteristic null when sync time!");
// use one of them in regards of the Characteristic's property
tChar.setWriteType(BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE);
//tChar.setWriteType(BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT);
tChar.setValue(/*another int*/, BluetoothGattCharacteristic.FORMAT_SINT32, 0);
gatt.writeCharacteristic(tChar);