Fix keyboard always shown as asleep
Replies carry the target as an index (0x08 -> 0x00, 0x09 -> 0x01), not the target byte itself, so every reply was discarded. Also put the receiver into software mode before reading its pairing list and read firmware and serial independently. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
a483d6226d
commit
d0fd799aeb
1 file changed
+10
-6
+10
-6
@@ -62,7 +62,8 @@ class Transport:
|
||||
deadline = time.monotonic() + timeout
|
||||
while (left := deadline - time.monotonic()) > 0:
|
||||
resp = self.dev.read(left)
|
||||
if resp and resp[0] == pkt[0] and resp[1] == pkt[1]:
|
||||
# Replies carry the target as an index (0x08 -> 0, 0x09 -> 1) and echo the command.
|
||||
if resp and resp[0] == pkt[0] & 0x07 and resp[1] == pkt[1]:
|
||||
return resp
|
||||
raise DeviceError(f"no response to {pkt[:4].hex(' ')}")
|
||||
|
||||
@@ -256,11 +257,14 @@ class DeviceService:
|
||||
self._h = _Handles(transport, notify, Keyboard(transport, target), receiver)
|
||||
self._set(receiver=True, wireless=wireless, error="")
|
||||
if receiver:
|
||||
try:
|
||||
self._set(receiver_firmware=receiver.firmware(), serial=self._paired_serial())
|
||||
receiver.set_mode(bragi.MODE_SOFTWARE)
|
||||
except DeviceError as e:
|
||||
log.warning("receiver init: %s", e)
|
||||
# Software mode first: the receiver refuses the pairing list in hardware mode.
|
||||
for step in (lambda: receiver.set_mode(bragi.MODE_SOFTWARE),
|
||||
lambda: self._set(receiver_firmware=receiver.firmware()),
|
||||
lambda: self._set(serial=self._paired_serial())):
|
||||
try:
|
||||
step()
|
||||
except DeviceError as e:
|
||||
log.warning("receiver init: %s", e)
|
||||
self._init_keyboard()
|
||||
return True
|
||||
|
||||
|
||||
Reference in new issue
Block a user