Compare commits
6 Commits
0651fe8490
...
d7a031ff77
Author | SHA1 | Date |
---|---|---|
|
d7a031ff77 | |
|
783bd5e4da | |
|
b2b032d8bf | |
|
985e1fe889 | |
|
dd63ffef16 | |
|
534d8125ea |
|
@ -156,6 +156,10 @@ class PairingError(IntEnum):
|
|||
TOO_MANY_DEVICES = 0x03
|
||||
SEQUENCE_TIMEOUT = 0x06
|
||||
|
||||
@property
|
||||
def label(self) -> str:
|
||||
return self.name.lower().replace("_", " ")
|
||||
|
||||
|
||||
class BoltPairingError(IntEnum):
|
||||
DEVICE_TIMEOUT = 0x01
|
||||
|
|
|
@ -296,7 +296,10 @@ class ReprogrammableKeyV4(ReprogrammableKey):
|
|||
if self._mapped_to is None:
|
||||
self._getCidReporting()
|
||||
self._device.keys._ensure_all_keys_queried()
|
||||
task = str(special_keys.Task(self._device.keys.cid_to_tid[self._mapped_to]))
|
||||
try:
|
||||
task = str(special_keys.Task(self._device.keys.cid_to_tid[self._mapped_to]))
|
||||
except ValueError:
|
||||
task = f"Unknown_{self._mapped_to:x}"
|
||||
return NamedInt(self._mapped_to, task)
|
||||
|
||||
@property
|
||||
|
|
|
@ -433,7 +433,8 @@ def handle_pairing_lock(receiver: Receiver, notification: HIDPPNotification) ->
|
|||
receiver.pairing.new_device = None
|
||||
pair_error = ord(notification.data[:1])
|
||||
if pair_error:
|
||||
receiver.pairing.error = error_string = hidpp10_constants.PairingError(pair_error).name
|
||||
error_string = hidpp10_constants.PairingError(pair_error).label
|
||||
receiver.pairing.error = error_string
|
||||
receiver.pairing.new_device = None
|
||||
logger.warning("pairing error %d: %s", pair_error, error_string)
|
||||
receiver.changed(reason=reason)
|
||||
|
|
|
@ -9,6 +9,7 @@ import pytest
|
|||
from logitech_receiver import common
|
||||
from logitech_receiver import hidpp10
|
||||
from logitech_receiver import hidpp10_constants
|
||||
from logitech_receiver.hidpp10_constants import PairingError
|
||||
from logitech_receiver.hidpp10_constants import Registers
|
||||
|
||||
_hidpp10 = hidpp10.Hidpp10()
|
||||
|
@ -338,3 +339,11 @@ def test_set_configuration_pending_flags(device, expected_result):
|
|||
result = hidpp10.set_configuration_pending_flags(device, 0x00)
|
||||
|
||||
assert result == expected_result
|
||||
|
||||
|
||||
def test_pairing_error():
|
||||
expected_label = "device not supported"
|
||||
|
||||
res = PairingError.DEVICE_NOT_SUPPORTED.label
|
||||
|
||||
assert res == expected_label
|
||||
|
|
Loading…
Reference in New Issue