-
Couldn't load subscription status.
- Fork 330
Register a disconnected callback and clean up subscriptions on disconnect #86
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks very good! Could you change these parts and then I will merge it into develop, pending release of v0.5.0
bleak/backends/client.py
Outdated
| # Connectivity methods | ||
|
|
||
| @abc.abstractmethod | ||
| async def set_disconnect_callback( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like some documentation of an example of a disconnect_callback that shows how it is used. Place it here, in the docstring of the interface class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. I'll add it tomorrow.
bleak/backends/bluezdbus/client.py
Outdated
| self._rules = {} | ||
| self._subscriptions = list() | ||
|
|
||
| self.disconnect_callback = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you change this to an internal attribute, please?
The callback will be called only on unsolicited disconnect event from peer. An initiated disconnect from the host will not call it. Other implementations (Core Bluetooth and .NET) will fail with a NotImplementedError exception.
If a client subscribed to characteristics, disconnected and reconnected, the old subscriptions stayed registered. If a new subscription to notifications were added, the data was received twice on every callback. This patch makes sure that the BleakClient keeps track of the active subscriptions and explicitly removes them when a disconnect is called as part of its cleanup.
8190755 to
7e39ca4
Compare
|
@hbldh I implemented the changes and rebased on the develop branch. I was not aware of this branch before... |
Implemented new method stumps (due to abstract methods) from #86 in macOS and Windows backends as well. Modified example files to show how Core Bluetooth backend handles addresses. Removed corebleak.py, since I do not think it is needed any more either.
macOS support added (thanks to @kevincar) Merged #80: macOS development Merged #90 which fixed #89: Leaking callbacks in BlueZ Merged #92 which fixed #91, Prevent leaking of DBus connections on discovery Merged #96: Regex patterns Merged #86 which fixed #83 and #82 Recovered old .NET discovery method to try for #95
This patch contains two changes:
Replaces #85
Fixes #83
Closes #82