Skip to content

Commit 6945138

Browse files
authored
device: report symbolic names for pairing errors (pwr-Solaar#2886)
* device: report symbolic names for pairing errors * testing: fix testing of notifications
1 parent 1a9725f commit 6945138

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/logitech_receiver/notifications.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ def handle_pairing_lock(receiver: Receiver, notification: HIDPPNotification) ->
433433
receiver.pairing.new_device = None
434434
pair_error = ord(notification.data[:1])
435435
if pair_error:
436-
receiver.pairing.error = error_string = hidpp10_constants.PairingError(pair_error)
436+
receiver.pairing.error = error_string = hidpp10_constants.PairingError(pair_error).name
437437
receiver.pairing.new_device = None
438438
logger.warning("pairing error %d: %s", pair_error, error_string)
439439
receiver.changed(reason=reason)
@@ -453,7 +453,7 @@ def handle_discovery_status(receiver: Receiver, notification: HIDPPNotification)
453453
receiver.pairing.device_passkey = None
454454
discover_error = ord(notification.data[:1])
455455
if discover_error:
456-
receiver.pairing.error = discover_string = hidpp10_constants.BoltPairingError(discover_error)
456+
receiver.pairing.error = discover_string = hidpp10_constants.BoltPairingError(discover_error).name
457457
logger.warning("bolt discovering error %d: %s", discover_error, discover_string)
458458
receiver.changed(reason=reason)
459459
return True
@@ -495,7 +495,7 @@ def handle_pairing_status(receiver: Receiver, notification: HIDPPNotification) -
495495
elif notification.address == 0x02 and not pair_error:
496496
receiver.pairing.new_device = receiver.register_new_device(notification.data[7])
497497
if pair_error:
498-
receiver.pairing.error = error_string = hidpp10_constants.BoltPairingError(pair_error)
498+
receiver.pairing.error = error_string = hidpp10_constants.BoltPairingError(pair_error).name
499499
receiver.pairing.new_device = None
500500
logger.warning("pairing error %d: %s", pair_error, error_string)
501501
receiver.changed(reason=reason)

tests/logitech_receiver/test_notifications.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def test_process_receiver_notification(sub_id, notification_data, expected_error
5858
result = notifications.process_receiver_notification(receiver, notification)
5959

6060
assert result
61-
assert receiver.pairing.error == expected_error
61+
assert receiver.pairing.error == (None if expected_error is None else expected_error.name)
6262
assert receiver.pairing.new_device is expected_new_device
6363

6464

0 commit comments

Comments
 (0)