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

Fix queue becomes null on disconnect #707

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ttongsul
Copy link
Contributor

@ttongsul ttongsul commented Aug 1, 2021

Attempt to fix #705, although I can't test it because reconnect() fails on my side.

@ttongsul ttongsul changed the title Fix queue becomes null on disconnect 3f9419c Fix queue becomes null on disconnect Aug 1, 2021
@phatpaul
Copy link
Contributor

phatpaul commented Aug 4, 2021

FYI i tested this branch by doing this:

npm install VinardoZzZ2000/cordova-plugin-bluetoothle#fix/per-peripheral-queues --save
cordova plugin remove cordova-plugin-bluetoothle
cordova plugin add cordova-plugin-bluetoothle
cordova prepare android

I'm still having reconnect problems. If my BLE peripheral device disappears (out of range, or reboots), this plugin should try to reconnect to it. It does reconnect, but my JS code never gets a callback that it reconnected.

I suspect it is due to

connection = new HashMap<Object, Object>();

which clears the connection object when a disconnect happens.
Why do you clear it here? That means that a (automatic) reconnect will not trigger a callback to the JS code.
Instead, the callbacks should only be cleared after the close().

@ttongsul
Copy link
Contributor Author

ttongsul commented Aug 5, 2021

Hmmm, I didn't notice that, though that was already there before I made the changes. Does the working version not have that line?

@phatpaul
Copy link
Contributor

phatpaul commented Aug 5, 2021

Ok, I can't say that your additions broke the reconnect() functionality in this library. But they definitely seem broken.
This PR does not fix the reconnect after an explicit disconnect(). It also doesn't fix the automatic reconnect after the BLE device disappears/reappears.
So I'm not sure if this PR is useful.
I'll try to fix it in a separate PR.
Thanks for your help.

@ttongsul
Copy link
Contributor Author

ttongsul commented Aug 6, 2021

Sorry about that. I'll leave this PR here unless my PR that may have broke the functionality is reverted, or you made a working PR. Thanks.

Seungwoo-Yu added a commit to Seungwoo-Yu-Projects-2022/cordova-plugin-bluetoothle that referenced this pull request Nov 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

plugin crash after reconnect() on Android
2 participants