MQTT Publish Client
Implement a Python MQTT client that connects to a broker and publishes sensor data periodically. The client should maintain connection, handle disconnects, and support QoS 1.
Constraints
- Use paho-mqtt library.
- Broker: test.mosquitto.org.
- Topic: device/sensor.
- Publish every 2 seconds.
- Reconnect on disconnect.
- Use QoS level 1.
1import paho.mqtt.client as mqtt2# TODO