Reputation: 3247
I'm using RxAndroidBle library for connecting bluetotooth device. I'm getting GATT 137 exception when I read characteristic of bluetooth device. Why I can't read characteristic ? Code snippet:
if (device.connectionState == RxBleConnection.RxBleConnectionState.CONNECTED) {
rxConnection.readCharacteristic(ConstantsBle.deviceUUIDCharacteristic).subscribe({
Log.e(TAG, "read characteristic task is success")
}, {
it.printStackTrace()
})
}
Exception details :
W/System.err: com.polidea.rxandroidble.exceptions.BleGattCharacteristicException: GATT exception from MAC address 0C:F3:EE:2A:ED:49, status 137, type BleGattOperation{description='CHARACTERISTIC_READ'}. (Look up status 0x89 here https://android.googlesource.com/platform/external/bluetooth/bluedroid/+/android-5.1.0_r1/stack/include/gatt_api.h) W/System.err: at com.polidea.rxandroidble.internal.connection.RxBleGattCallback.propagateErrorIfOccurred(RxBleGattCallback.java:227) W/System.err: at com.polidea.rxandroidble.internal.connection.RxBleGattCallback.access$800(RxBleGattCallback.java:32) W/System.err: at com.polidea.rxandroidble.internal.connection.RxBleGattCallback$2.onCharacteristicRead(RxBleGattCallback.java:108) at android.bluetooth.BluetoothGatt$1.onCharacteristicRead(BluetoothGatt.java:286) W/System.err: at android.bluetooth.IBluetoothGattCallback$Stub.onTransact(IBluetoothGattCallback.java:117) W/System.err: at android.os.Binder.execTransact(Binder.java:565)
Upvotes: 0
Views: 2809
Reputation: 3222
You cannot read the characteristic because the authentication with your peripheral has failed.
The status code: 137
(0x89
hex) is described in the Android sources. You even have the link in logs you have pasted.
There can be several reasons for this situation:
Note that pairing and bonding are two different things in BLE although are often used interchangeably.
Pairing is a short term process that is scoped for a particular connection whereas bonding is pairing with subsequent exchange of encryption keys (these can be then reused for next pairings).
Upvotes: 1