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

Cannot cancel connection with using autoConnect #251

Closed
VincentMasselis opened this issue Sep 24, 2020 · 9 comments
Closed

Cannot cancel connection with using autoConnect #251

VincentMasselis opened this issue Sep 24, 2020 · 9 comments

Comments

@VincentMasselis
Copy link

VincentMasselis commented Sep 24, 2020

I was connecting with autoConnect (but not yet connected) and, at some point, I decide to cancel the pending connection, the disconnection request is correctly enqueued but nothing appends, internalDisconnect is never called.

I'm using the last commit on develop (the one this morning), the cause of the bug seems to be the bool operationInProgress set to true here ->
https://github.com/NordicSemiconductor/Android-BLE-Library/blob/develop/ble/src/main/java/no/nordicsemi/android/ble/BleManagerHandler.java#L2828 causing the disconnection request to be enqueued and but never launched.

@philips77
Copy link
Member

Yes... this use case may not be supported.

@VincentMasselis
Copy link
Author

😢 Do you have any workaround that I could use for the moment ?

@philips77
Copy link
Member

The initial connection, even with autoConnect = true is done with this param set to false (although see #250). It should timeout in 30 seconds, or when you set .timeout(...) parameter to the ConnectRequest. You may try calling close() and connect(...).enqueue() again, but I can't guarantee it will work as expected.

@VincentMasselis
Copy link
Author

VincentMasselis commented Sep 24, 2020

By close() you mean the one from BleManager or BleManagerHandler ?

If you're talking about BleManagerHandler, it's not going to work since this comment :
https://github.com/NordicSemiconductor/Android-BLE-Library/blob/develop/ble/src/main/java/no/nordicsemi/android/ble/BleManagerHandler.java#L431

@philips77
Copy link
Member

True... How about using a different BleManager instance then?

@VincentMasselis
Copy link
Author

VincentMasselis commented Sep 24, 2020

Firstly, i'm injecting my manager instance at some places in my code, it's not gonna be easy to swap from one instance to another because of this IOC.
Secondly, forgetting my previous BleManager instance doesn't stops the running autoConnect that I want to cancel, which leads, i think, to memory leaks.

@philips77
Copy link
Member

You're right. Cancellation would really be a nice to have feature. I can look at it next week, but it's my last week before 3-month leave, so I can't promise much.

@VincentMasselis
Copy link
Author

I'm sending all the virtual encouragements I could behind my computer 💪

@philips77
Copy link
Member

I've started working on this feature now.

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

No branches or pull requests

2 participants