import socket, json, time

sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
BRIDGE_ADDR = ("127.0.0.1", 5005)

KEYS = {"1": "SIT", "2": "STAND", "3": "WALK_10M", "4": "STOP"}

print("1=SIT  2=STAND  3=WALK_10M  4=STOP  q=quit")
print("(heartbeat sent automatically between commands)\n")

while True:
    k = input("> ").strip()
    if k == "q":
        break
    cmd = KEYS.get(k)
    if not cmd:
        print("unknown key")
        continue
    sock.sendto(json.dumps({"cmd": cmd, "conf": 1.0, "t": time.time()}).encode(),
                BRIDGE_ADDR)
    print("sent", cmd)
