cli: reduce chance of connect notifications clashing when pairing
This commit is contained in:
parent
ad57db4a39
commit
714f8782b3
|
@ -51,15 +51,18 @@ def run(receivers, args, find_receiver, _ignore):
|
|||
|
||||
class _HandleWithNotificationHook(int):
|
||||
def notifications_hook(self, n):
|
||||
nonlocal known_devices
|
||||
assert n
|
||||
if n.devnumber == 0xFF:
|
||||
_notifications.process(receiver, n)
|
||||
elif n.sub_id == 0x41: # allow for other protocols! (was and n.address == 0x04)
|
||||
if n.devnumber not in known_devices:
|
||||
receiver.status.new_device = receiver[n.devnumber]
|
||||
elif receiver.re_pairs:
|
||||
del receiver[n.devnumber] # get rid of information on device re-paired away
|
||||
receiver.status.new_device = receiver[n.devnumber]
|
||||
kd, known_devices = known_devices, None # only process one connection notification
|
||||
if kd is not None:
|
||||
if n.devnumber not in kd:
|
||||
receiver.status.new_device = receiver.register_new_device(n.devnumber, n)
|
||||
elif receiver.re_pairs:
|
||||
del receiver[n.devnumber] # get rid of information on device re-paired away
|
||||
receiver.status.new_device = receiver.register_new_device(n.devnumber, n)
|
||||
|
||||
timeout = 20 # seconds
|
||||
receiver.handle = _HandleWithNotificationHook(receiver.handle)
|
||||
|
|
Loading…
Reference in New Issue