feat(espnow): add espnow-sender utility

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-03 14:56:35 +12:00
parent 7d821b9c1c
commit 49383c0003
4 changed files with 163 additions and 0 deletions

12
espnow-sender/util.py Normal file
View File

@@ -0,0 +1,12 @@
def parse_mac(value):
raw = value.strip().lower().replace(":", "").replace("-", "")
if len(raw) != 12:
raise ValueError("address must be 12 hex chars or aa:bb:cc:dd:ee:ff")
try:
return bytes.fromhex(raw)
except ValueError:
raise ValueError("address contains non-hex characters")
def format_mac(mac_bytes):
return ":".join("{:02x}".format(b) for b in mac_bytes)