"""Exercises mqtt_bridge.py against a running broker (+ esp32_sim.py or the
real ESP32) to confirm the drive/stop/sensor link actually works.
"""
import time

import mqtt_bridge as bridge

bridge.connect()
time.sleep(0.5)  # let heartbeat establish before the simulator's watchdog checks

print("-- drive forward --")
bridge.drive("forward", speed=200, duration_ms=1000)
time.sleep(1.5)

print("-- sensors --")
print(bridge.read_sensors())

print("-- invalid direction should raise --")
try:
    bridge.drive("sideways")
    print("FAIL: no exception raised")
except ValueError as e:
    print(f"OK: {e}")

print("-- explicit stop --")
bridge.stop()
