Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@JoeHut
Copy link
Contributor

@JoeHut JoeHut commented Jul 12, 2019

This patch contains two changes:

  • Add API and Bluez implementation to set a callback fired when a device disconnects without active intervention from the client
  • Remove all existing subscriptions to characteristic notifications when a device disconnects

Replaces #85
Fixes #83
Closes #82

Copy link
Owner

@hbldh hbldh left a 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

# Connectivity methods

@abc.abstractmethod
async def set_disconnect_callback(
Copy link
Owner

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.

Copy link
Contributor Author

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.

self._rules = {}
self._subscriptions = list()

self.disconnect_callback = None
Copy link
Owner

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?

arthur-proglove and others added 4 commits July 17, 2019 11:54
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.
@JoeHut JoeHut force-pushed the feat/disconnect_callback branch from 8190755 to 7e39ca4 Compare July 17, 2019 10:51
@JoeHut JoeHut changed the base branch from master to develop July 17, 2019 10:52
@JoeHut
Copy link
Contributor Author

JoeHut commented Jul 17, 2019

@hbldh I implemented the changes and rebased on the develop branch. I was not aware of this branch before...

@hbldh hbldh merged commit 24923e2 into hbldh:develop Jul 21, 2019
hbldh added a commit that referenced this pull request Aug 2, 2019
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.
hbldh added a commit that referenced this pull request Aug 2, 2019
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
hbldh added a commit that referenced this pull request Sep 7, 2019
Added example for set_disconnect_callback
hbldh added a commit that referenced this pull request Oct 9, 2019
Bugfixes and improvements of client behaviour.

Merged #117
Merged #99
Merged #100
Fixes #101
Fixes #98
Fixes #104
Further fixes for #69, #83 and #86
@JoeHut JoeHut deleted the feat/disconnect_callback branch November 12, 2019 12:11
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