-
Notifications
You must be signed in to change notification settings - Fork 27
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 returns true on Android after disconnect #16
Comments
I misspoke a bit above. The connectErrorCallback gets a value of 8 on Android. I get EASYBLE_ERROR_DISCONNECTED on IOS |
Some more details: "if I pull the batteries in my BLE device, I get EASYBLE_ERROR_DISCONNECTED in my Connection Error Callback as suspected, but if I call isConnected() immediately after that, it returns true on Android. iOS correctly returns false." |
Saving this note from Gitter here as a memo to be super clear: "The disconnect on android does NOT return EASYBLE_ERROR_DISCONNECTED. Instead I get an error code of 8. Looks like EASYBLE won't interpret that 8 as a simple disconnect and thus not set __isConnected to false." |
@sjrcgtek Hi, I have made various tests and cannot reproduce the situation of error code 8. I consistently get connectInfo.state == 0 on disconnect. When removing the battery from the BLE device, it takes some time before disconnect occurs however. When resetting the BLE device (tested with TI SensorTag CC2650) the disconnect happens much quicker. Also tested to turn off BLE on the phone, which results is a quick disconnect event. On which BLE device/devices have you seen this? Do you get code 8 in the connectInfo.state variable in the success callback, or in the errorCode in the error callback? Made an update to set __isConnected = false also in the error handler. See this commit: https://github.com/mikaelkindborg/evothings-libraries/commit/b0575975629236c9a9d2526438782e469745915a The commit diff is not very readable, here is the source of the updated function: https://github.com/mikaelkindborg/evothings-libraries/blob/b0575975629236c9a9d2526438782e469745915a/libs/evothings/easyble/easyble.js#L1243 If you wish to test, here is the easyble.dist.js file: https://github.com/mikaelkindborg/evothings-libraries/blob/master/libs/evothings/easyble/easyble.dist.js |
The device is a contact sensor built with BlueGiga's BLE112 i believe. I I was getting the code 8 in the error callback. On Fri, Aug 12, 2016 at 8:47 AM, Mikael Kindborg [email protected]
|
Mikael, I just tested again with your new code. I am still getting that error code // Error callback. The new device.__isConnected = false, solves my problem since the app now Thanks. On Fri, Aug 12, 2016 at 8:47 AM, Mikael Kindborg [email protected]
|
@sjrcgtek Thanks a lot for testing! Merged the update into the main Evothings repository now. The callbacks for connect/disconnect should be designed in a clearer way, will look into this. Let me know if you have any ideas. Perhaps the error callback should cause a "disconnect event" to be sent. Currently the connect success callback has this function. It can be called on error with connectInfo.state disconnect. There could be better ways. Do you have any idea when the error code 8 stands for? I have been searching the Android docs for BLE but not found any error code 8 yet. Best, Mikael |
EASYBLE isConnected() method stills returns true after device is disconnected on android. Works as expected on iOS. I call isConnected() immediately after receiving a connectErrorCallback with "EASYBLE_ERROR_DISCONNECTED" (which i forced by pulling the batteries on my BLE device)
Not sure what other info might be helpful. If there is something else that, please let me know.
The text was updated successfully, but these errors were encountered: