From f3336beaa196e75214c86f65faf3e8fd0cd22b34 Mon Sep 17 00:00:00 2001 From: Matthias Hagmann <16444067+MattHag@users.noreply.github.com> Date: Sun, 3 Mar 2024 22:03:43 +0100 Subject: [PATCH] receiver: Refactor pairing of a Bolt device Related #2350 --- lib/logitech_receiver/receiver.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/logitech_receiver/receiver.py b/lib/logitech_receiver/receiver.py index 06226d2da..834833887 100644 --- a/lib/logitech_receiver/receiver.py +++ b/lib/logitech_receiver/receiver.py @@ -287,14 +287,8 @@ def set_lock(self, lock_closed=True, device=0, timeout=0): def discover(self, cancel=False, timeout=30): pass - def pair_device(self, pair=True, slot=0, address=b"\0\0\0\0\0\0", authentication=0x00, entropy=20): # Bolt pairing - assert self.receiver_kind == "bolt" - if self.handle: - action = 0x01 if pair is True else 0x03 if pair is False else 0x02 - reply = self.write_register(_R.bolt_pairing, action, slot, address, authentication, entropy) - if reply: - return True - logger.warning("%s: failed to %s device %s", self, "pair" if pair else "unpair", address) + def pair_device(self, pair=True, slot=0, address=b"\0\0\0\0\0\0", authentication=0x00, entropy=20): + pass def count(self): count = self.read_register(_R.receiver_connection) @@ -417,6 +411,15 @@ def discover(self, cancel=False, timeout=30): return True logger.warning("%s: failed to %s device discovery", self, "cancel" if cancel else "start") + def pair_device(self, pair=True, slot=0, address=b"\0\0\0\0\0\0", authentication=0x00, entropy=20): + """Pair a Bolt device.""" + if self.handle: + action = 0x01 if pair is True else 0x03 if pair is False else 0x02 + reply = self.write_register(_R.bolt_pairing, action, slot, address, authentication, entropy) + if reply: + return True + logger.warning("%s: failed to %s device %s", self, "pair" if pair else "unpair", address) + class UnifyingReceiver(Receiver): def __init__(self, product_info, handle, path, product_id, setting_callback=None):