-
Notifications
You must be signed in to change notification settings - Fork 306
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
disconnect() doesn't disconnect from device #133
Comments
Bleak uses, via pythonnet, the C# UWP libraries for connecting to Bluetooth devices. The Dispose method will eventually close the connection. There is a What is the real problem of the device not being freed immediately? |
The peripheral device is intended to drop to a low-power mode after the disconnection, but this issue is causing the connection to persist even though the bleak client says it has disconnected. We set up a BLE sniffer while we reproduced the issue, and there doesn't seem to be any TERMINATE signals sent over the air. What kind of timeframe would you expect the connection to be closed after the Dispose() method is called? We're seeing the connection remain for several minutes after, our peripheral has its own internal timer to force a disconnect as a redundancy for now. |
@mitchmccarthy This SO issue descibes the problems Bleak faces as well: https://stackoverflow.com/questions/39599252/windows-ble-uwp-disconnect I would like to be able to close it, but something seems to be left in the If the process in which Bleak was run is killed, is the connection severed then? Or is it still present? If you insert specific handling in your device due to Bleak's problems, then maybe this project isn't for you. There are other BLE projects which are production ready; I do not guarantee any functionality in Bleak; it is a spare time exploration project of mine. |
If the process (python shell) is killed then yeah the disconnect occurs pretty much immediately, so I think you're right about some hanging reference. We've already looked at other options, your project was very simple to drop into our application and aside from this issue it worked great so we were hoping to continue with it. I totally understand that this is a work-in-progress project, and thanks for taking the time to investigate the issue. |
This is probably solved in version 0.8.0. Will close for now. |
Related info: I'm currently having trouble getting a device to disconnect on Windows 10 with Bleak 0.11.0. |
And rebooting the computer seems to have fixed the problem. |
I'll second that. |
Description
I am currently writing an application to connect to a BLE device, write to some characteristics and then disconnect from the device. From our tests, bleak's disconnect API doesn't always send the disconnect command to the device (seen using a snifer). There are cases that the devices remain connected after calling disconnect but bleak returns that they are already disconnected. Not sure where the problem might be, is there any patch for this problem?
What I Did
I tried to disconnect, the return is True but looking at the BLE snifer the devices still transmit empty PDUs to maintain the connection. Calling self.client.is_connected() returns False. The connection has not been terminated.
The text was updated successfully, but these errors were encountered: