# Simulates the SDK heartbeat: connects to the virtual camera's TCP 6679, # sends UpdateAck(203) heartbeats periodically, and verifies each response. # If the connection drops or a response is wrong, the SDK would mark the # device offline after 3 consecutive failures. import socket import struct import time import sys HOST = "127.0.0.1" PORT = 6679 def pack_frame(op, cmd, seq, payload=b""): total = 24 + len(payload) return (b"VZEB" + struct.pack("= 4 else -1 if err == 0: ok += 1 print(f" OK heartbeat #{seq} err=0 ({time.time()-t0:.1f}s)") else: print(f"[FAIL] heartbeat #{seq} errCode={err}") fail += 1 else: print(f"[FAIL] heartbeat #{seq} unexpected resp op={op} cmd={cmd} seq={rseq}") fail += 1 time.sleep(2.0) sock.close() print(f"\nresult: ok={ok} fail={fail}") print("PASS" if fail == 0 else "FAIL") if __name__ == "__main__": main()