BleGattCoroutines
BleGattCoroutines copied to clipboard
isConnected not working when i get gatt 133 error
When my ble device disconnects me i get the gatt status 133. BleGattCoroutine throws an exception
com.beepiz.bluetooth.gattcoroutines.OperationFailedException
as expected, and then i want to check BLE status with isConnected()
method. In this situatuion i expect 'false' but i get 'true'. Is it a bug?
I am sorry but I can't provide you a minimal sketch right now i do something like:
try{
gatt.connect()
// ...Do all preparations
//turn off ble device for example
gatt.readCharacteristic(characteristic)
} catch (e: Exception){
if (!gatt.isConnected()) doSomethingWithError() // i expect that doSomethingWithError() will happend
}
The 133 error is quite obscure (it's named GATT_ERROR
in AOSP, but undocumented, and when it happens, your best bet is to close the connection and retry from a new one. You should get the OperationFailedException
or the other errors BleGattCoroutines can throw, and from the status present in the exception, handle the 133 to retry after closing the connection.