Skip to content

Commit

Permalink
receiver: Refactor pairing of a Bolt device
Browse files Browse the repository at this point in the history
  • Loading branch information
MattHag committed Mar 3, 2024
1 parent 1f7ab9d commit f3336be
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions lib/logitech_receiver/receiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit f3336be

Please sign in to comment.