From 41248a2f2bbb80f8583a565d7c9dd01a077d29b3 Mon Sep 17 00:00:00 2001 From: Marcus Brown Date: Sun, 20 Oct 2024 18:15:08 +1100 Subject: [PATCH] Fix MQTT client configuration and callback to resolve breaking issues - Reverted MQTT client to MQTTv311 to avoid compatibility issues. - Updated on_connect method to match expected arguments for MQTTv5. - Fixed deprecation and runtime errors for proper operation. --- dayglo_detector/dayglo_detector.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dayglo_detector/dayglo_detector.py b/dayglo_detector/dayglo_detector.py index 92e7233..f6727a6 100644 --- a/dayglo_detector/dayglo_detector.py +++ b/dayglo_detector/dayglo_detector.py @@ -28,7 +28,7 @@ UPPER_COLOR = np.array([35, 255, 255]) # Track if the initial snapshot has been processed initial_snapshot_processed = False -def on_connect(client, userdata, flags, rc): +def on_connect(client, userdata, flags, reasonCode, properties=None): if rc == 0: print("Connected successfully to MQTT broker") client.subscribe(MQTT_SNAPSHOT_TOPIC, qos=1) @@ -131,7 +131,7 @@ if len(sys.argv) > 1: print(f"File not found: {image_file}") # Set up MQTT client for normal operation -client = mqtt.Client(protocol=mqtt.MQTTv5) +client = mqtt.Client(protocol=mqtt.MQTTv311) client.username_pw_set(MQTT_USERNAME, MQTT_PASSWORD) client.on_connect = on_connect client.on_message = on_message