feat: GetMac command + MacAddress response
New protocol command (tag 8): GetMac returns the board's 6-byte hardware address. Useful when multiple dongles are connected to one host. Response (tag 6): MacAddress containing 6 raw bytes. Updated: PROTOCOL.md, CHANGELOG, donglora.py decoder, all_commands.py.
This commit is contained in:
1 parent
d6087f278e
commit
ff43d72cfc
2 files changed
+10
-1
No files matched your search
+4
-1
@@ -42,7 +42,10 @@ try:
|
|||||||
print("\n── DisplayOn ──")
|
print("\n── DisplayOn ──")
|
||||||
print(dl.send(ser, "DisplayOn"))
|
print(dl.send(ser, "DisplayOn"))
|
||||||
|
|
||||||
print("\nAll 8 commands exercised successfully.")
|
print("\n── GetMac ──")
|
||||||
|
print(dl.send(ser, "GetMac"))
|
||||||
|
|
||||||
|
print("\nAll 9 commands exercised successfully.")
|
||||||
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print("\nInterrupted.")
|
print("\nInterrupted.")
|
||||||
|
|||||||
@@ -99,6 +99,7 @@ def encode_command(cmd: str, **kwargs) -> bytes:
|
|||||||
tags = {
|
tags = {
|
||||||
"Ping": 0, "GetConfig": 1, "SetConfig": 2, "StartRx": 3,
|
"Ping": 0, "GetConfig": 1, "SetConfig": 2, "StartRx": 3,
|
||||||
"StopRx": 4, "Transmit": 5, "DisplayOn": 6, "DisplayOff": 7,
|
"StopRx": 4, "Transmit": 5, "DisplayOn": 6, "DisplayOff": 7,
|
||||||
|
"GetMac": 8,
|
||||||
}
|
}
|
||||||
out = bytes([tags[cmd]])
|
out = bytes([tags[cmd]])
|
||||||
if cmd == "SetConfig":
|
if cmd == "SetConfig":
|
||||||
@@ -144,6 +145,11 @@ def decode_response(data: bytes) -> dict:
|
|||||||
elif tag == 5:
|
elif tag == 5:
|
||||||
code = rest[0] if rest else -1
|
code = rest[0] if rest else -1
|
||||||
return {"type": "Error", "code": code}
|
return {"type": "Error", "code": code}
|
||||||
|
elif tag == 6:
|
||||||
|
if len(rest) >= 6:
|
||||||
|
mac = ":".join(f"{b:02X}" for b in rest[:6])
|
||||||
|
return {"type": "MacAddress", "mac": mac}
|
||||||
|
return {"type": "MacAddress", "raw": rest.hex()}
|
||||||
else:
|
else:
|
||||||
return {"type": f"Unknown({tag})"}
|
return {"type": f"Unknown({tag})"}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user