UDKOX
UDKOX

Reputation: 737

Should I get BluetoothGatt.GATT_SUCCESS also when disconnecting from a device?

I am working with custom devices and I am struggling to manage the Bluetooth LE correctly.

My only concern is not getting 0 (BluetoothGatt.GATT_SUCCESS) when I read the status value along with value 2 on newState variable (what means BluetoothProfile.STATE_DISCONNECTED) at method onConnectionStateChange. Instead, I get an 8, what can't be tracked in the BluetoothGatt nor BluetoothProfile classes.

All connection works fine, I read and write values perfectly.

(1) Is this supposed to be like that? Why do I read an eight?

I have seen many status values at my onConnectionStateChange method: 8, 19, 133 etc.

(2) Where can I check this values?

Thanks in advance


EDIT: There are many values in the api.h file, we were looking in the wrong place.

8: 0x08 = GATT CONN TIMEOUT 19: 0x13 = GATT CONN TERMINATE PEER USER 133: 0x85 = GATT_ERROR

Upvotes: 0

Views: 1407

Answers (2)

UDKOX
UDKOX

Reputation: 737

Answer is no.

I wasn't getting BluetoothGatt.GATT_SUCCESS because the connection was closed by the other end. If gatt.disconnect() is executed I read status = BluetoothGatt.GATT_SUCCESS.

Upvotes: 0

David Lev
David Lev

Reputation: 813

The int error codes need to be converted to HEX and mapped to the values in the following file:

https://android.googlesource.com/platform/external/bluetooth/bluedroid/+/android-5.1.1_r13/stack/include/gatt_api.h

In the cases you mentioned:

8 = GATT_INSUF_AUTHORIZATION
19 = GATT_RSP_WRITE 
133 = GATT_ERROR

Upvotes: 1

Related Questions