From ff43d72cfc801e0bee0277392b9967560ef47cf8 Mon Sep 17 00:00:00 2001 From: Stephen Waits Date: Mon, 30 Mar 2026 09:08:59 -0600 Subject: [PATCH] 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. --- all_commands.py | 5 ++++- donglora.py | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/all_commands.py b/all_commands.py index 74e9cc3..533ee70 100755 --- a/all_commands.py +++ b/all_commands.py @@ -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.") diff --git a/donglora.py b/donglora.py index 5645eee..0c0cfb1 100644 --- a/donglora.py +++ b/donglora.py @@ -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})"}