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 disconnect when using the winrt backend. #329

Merged
merged 1 commit into from
Aug 24, 2023

Conversation

TristonJ
Copy link
Contributor

Fixes #300

You must explicitly disconnect from each service before disconnecting from the device. Otherwise, Windows does not seem to fully disconnect the device internally.

See https://stackoverflow.com/questions/39599252/windows-ble-uwp-disconnect for similar issues.

I did this by simply adding a list of services to the BLEDevice when discover_services is called, allowing us to Close them when the device is dropped. This appears to work in my use-case, but I'd be interested to see if it's a robust enough solution for other folks.

You must explicitly disconnect from each service before disconnecting from the device. Otherwise, Windows does not seem to fully disconnect the device internally.

See https://stackoverflow.com/questions/39599252/windows-ble-uwp-disconnect for similar issues.
@qwandor qwandor requested a review from qdot July 28, 2023 08:10
@thewh1teagle
Copy link

Thank you very much!
I can confirm this worked for me in windows 11
in cargo.toml:

btleplug = { git = "https://github.com/TristonJ/btleplug.git", rev = "d90009d0509eb58677b4f106b48b650dd4e13347" }

@qdot
Copy link
Contributor

qdot commented Aug 24, 2023

Yeah, I think this is fair. Weird that we have to do it, but better than basically leaking live connections.

@qdot qdot merged commit 1ae52f4 into deviceplug:dev Aug 24, 2023
4 checks passed
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.

3 participants