Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isConnected not working when i get gatt 133 error #47

Open
MikhailNatalenko opened this issue May 31, 2019 · 1 comment
Open

isConnected not working when i get gatt 133 error #47

MikhailNatalenko opened this issue May 31, 2019 · 1 comment
Labels

Comments

@MikhailNatalenko
Copy link

MikhailNatalenko commented May 31, 2019

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
}
@LouisCAD
Copy link
Collaborator

LouisCAD commented Jun 2, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants