Accessing GATT Error codes instead of int

Viewed 252

How via android I can access to GATT error codes

Instead of doing this:

override fun onConnectionStateChange(gatt: BluetoothGatt?, status: Int, newState: Int) {
            super.onConnectionStateChange(gatt, status, newState)

             if (status == 133) {
               //Do something
            }
        }

I wish to do simething like this:

override fun onConnectionStateChange(gatt: BluetoothGatt?, status: Int, newState: Int) {
            super.onConnectionStateChange(gatt, status, newState)

             if (status == <WhatGoesHere?>.GATT_ERROR) {
               //Do something
            }
        }
1 Answers

A few of them you can get from android.bluetooth.BluetoothGatt, but not a lot of the interesting ones you want. I recommend making a GattStatus class that just has integer constants with the codes you linked to, or at least the ones you care about. It's what we ended up doing for our project and it's easily re-usable in the future

Related