Skip to content

Commit

Permalink
Merge pull request #579 from jmdietrich-gcx/unsubscribe_characteristi…
Browse files Browse the repository at this point in the history
…c_in_gatt_client

Remove characteristic in GATT Client unsubscribe() if it's the last subscriber
  • Loading branch information
barbibulle authored Oct 31, 2024
2 parents c4e9726 + 73fe564 commit b78f895
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions bumble/gatt_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -898,6 +898,12 @@ async def unsubscribe(
) and subscriber in subscribers:
subscribers.remove(subscriber)

# The characteristic itself is added as subscriber. If it is the
# last remaining subscriber, we remove it, such that the clean up
# works correctly. Otherwise the CCCD never is set back to 0.
if len(subscribers) == 1 and characteristic in subscribers:
subscribers.remove(characteristic)

# Cleanup if we removed the last one
if not subscribers:
del subscriber_set[characteristic.handle]
Expand Down

0 comments on commit b78f895

Please sign in to comment.