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:
7 files changed
+33
-7
No files matched your search
@@ -42,7 +42,10 @@ try:
|
||||
print("\n── 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:
|
||||
print("\nInterrupted.")
|
||||
|
||||
@@ -99,6 +99,7 @@ def encode_command(cmd: str, **kwargs) -> bytes:
|
||||
tags = {
|
||||
"Ping": 0, "GetConfig": 1, "SetConfig": 2, "StartRx": 3,
|
||||
"StopRx": 4, "Transmit": 5, "DisplayOn": 6, "DisplayOff": 7,
|
||||
"GetMac": 8,
|
||||
}
|
||||
out = bytes([tags[cmd]])
|
||||
if cmd == "SetConfig":
|
||||
@@ -144,6 +145,11 @@ def decode_response(data: bytes) -> dict:
|
||||
elif tag == 5:
|
||||
code = rest[0] if rest else -1
|
||||
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:
|
||||
return {"type": f"Unknown({tag})"}
|
||||
|
||||
|
||||
Reference in new issue
Block a user