forked from auracaster/bumble_mirror
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a1414c2b5b | |||
| b78f895143 | |||
| c4e9726828 | |||
| d4b8e8348a | |||
| 19debaa52e | |||
| 73fe564321 |
@@ -898,6 +898,12 @@ class Client:
|
||||
) 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]
|
||||
|
||||
@@ -102,6 +102,7 @@ class ContextType(enum.IntFlag):
|
||||
|
||||
# fmt: off
|
||||
PROHIBITED = 0x0000
|
||||
UNSPECIFIED = 0x0001
|
||||
CONVERSATIONAL = 0x0002
|
||||
MEDIA = 0x0004
|
||||
GAME = 0x0008
|
||||
|
||||
+13
-2
@@ -851,7 +851,12 @@ async def test_unsubscribe():
|
||||
await async_barrier()
|
||||
mock1.assert_called_once_with(ANY, True, False)
|
||||
|
||||
await c2.subscribe()
|
||||
assert len(server.gatt_server.subscribers) == 1
|
||||
|
||||
def callback(_):
|
||||
pass
|
||||
|
||||
await c2.subscribe(callback)
|
||||
await async_barrier()
|
||||
mock2.assert_called_once_with(ANY, True, False)
|
||||
|
||||
@@ -861,10 +866,16 @@ async def test_unsubscribe():
|
||||
mock1.assert_called_once_with(ANY, False, False)
|
||||
|
||||
mock2.reset_mock()
|
||||
await c2.unsubscribe()
|
||||
await c2.unsubscribe(callback)
|
||||
await async_barrier()
|
||||
mock2.assert_called_once_with(ANY, False, False)
|
||||
|
||||
# All CCCDs should be zeros now
|
||||
assert list(server.gatt_server.subscribers.values())[0] == {
|
||||
c1.handle: bytes([0, 0]),
|
||||
c2.handle: bytes([0, 0]),
|
||||
}
|
||||
|
||||
mock1.reset_mock()
|
||||
await c1.unsubscribe()
|
||||
await async_barrier()
|
||||
|
||||
Reference in New Issue
Block a user