receiver: receiver c52e does not unpair

This commit is contained in:
Peter F. Patel-Schneider 2021-01-31 21:12:56 -05:00
parent d3a18bb85f
commit 1d18e4d8f7
2 changed files with 17 additions and 2 deletions

View File

@ -33,6 +33,7 @@ from .descriptors import DEVICES as _DEVICES
# max_devices is only used for receivers that do not support reading from _R.receiver_info offset 0x03, default to 1
# may_unpair is only used for receivers that do not support reading from _R.receiver_info offset 0x03, default to False
# unpair is for receivers that do support reading from _R.receiver_info offset 0x03, no default
## should this last be changed so that may_unpair is used for all receivers? writing to _R.receiver_pairing doesn't seem right
# re_pairs determines whether a receiver pairs by replacing existing pairings, default to False
## currently only one receiver is so marked - should there be more?
@ -58,6 +59,17 @@ _nano_receiver = lambda product_id: {
're_pairs': True
}
_nano_receiver_no_unpair = lambda product_id: {
'vendor_id': 0x046d,
'product_id': product_id,
'usb_interface': 1,
'hid_driver': _DRIVER, # noqa: F821
'name': 'Nano Receiver',
'may_unpair': False,
'unpair': False,
're_pairs': True
}
_nano_receiver_max2 = lambda product_id: {
'vendor_id': 0x046d,
'product_id': product_id,
@ -125,7 +137,7 @@ NANO_RECEIVER_C51B = _nano_receiver(0xc51b)
NANO_RECEIVER_C521 = _nano_receiver(0xc521)
NANO_RECEIVER_C525 = _nano_receiver(0xc525)
NANO_RECEIVER_C526 = _nano_receiver(0xc526)
NANO_RECEIVER_C52e = _nano_receiver(0xc52e)
NANO_RECEIVER_C52e = _nano_receiver_no_unpair(0xc52e)
NANO_RECEIVER_C531 = _nano_receiver(0xc531)
NANO_RECEIVER_C534 = _nano_receiver_max2(0xc534)
NANO_RECEIVER_C537 = _nano_receiver(0xc537)

View File

@ -69,7 +69,10 @@ class Receiver(object):
self.max_devices = product_info.get('max_devices', 1)
# TODO _properly_ figure out which receivers do and which don't support unpairing
# This code supposes that receivers that don't unpair support a pairing request for device index 0
self.may_unpair = self.write_register(_R.receiver_pairing) is None
if 'unpair' in product_info:
self.may_unpair = product_info['unpair']
else:
self.may_unpair = self.write_register(_R.receiver_pairing) is None
else: # handle receivers that don't have a serial number specially (i.e., c534)
self.serial = None
self.max_devices = product_info.get('max_devices', 1)