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})"}