Skip to content

Commit

Permalink
Disconnect notify callback from PropertiesChanged signal (#349)
Browse files Browse the repository at this point in the history
  • Loading branch information
ukBaz authored Oct 11, 2021
1 parent 392a115 commit 6f46b6c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions bluezero/GATT.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def __init__(self, adapter_addr, device_addr, srv_uuid, chrc_uuid):
self.chrc_uuid = chrc_uuid
self.characteristic_methods = None
self.characteristic_props = None
self._prop_chngd_sig = None

def resolve_gatt(self):
"""
Expand Down Expand Up @@ -245,10 +246,10 @@ def add_characteristic_cb(self, callback=None):
:param callback: callback function to be added.
"""
if callback is None:
callback = self.props_changed_cb

self.characteristic_props.connect_to_signal('PropertiesChanged',
callback)
self._prop_chngd_sig.remove()
else:
self._prop_chngd_sig = self.characteristic_props.connect_to_signal(
'PropertiesChanged', callback)

def props_changed_cb(self, iface, changed_props, invalidated_props):
"""
Expand Down

0 comments on commit 6f46b6c

Please sign in to comment.