From 48ffb49e0913dc7a94c3bdfb0c0cf69e4b8f0235 Mon Sep 17 00:00:00 2001 From: Matheus Date: Tue, 4 Nov 2025 20:28:52 -0300 Subject: enviando mensagens --- mqtt_client/main.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'mqtt_client/main.py') diff --git a/mqtt_client/main.py b/mqtt_client/main.py index 0ba9f10..6df96c7 100644 --- a/mqtt_client/main.py +++ b/mqtt_client/main.py @@ -40,6 +40,8 @@ def on_connect(client, userdata, flags, reason_code, properties): def on_message(client, userdata, msg): payload = json.loads(msg.payload) topic = msg.topic.split('/')[-1] + print(f"GOT MESSAGE {payload}") + if topic.isnumeric(): stationId = int(topic) else: @@ -80,7 +82,7 @@ except KeyError: mqttc = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2, protocol=MQTTProtocolVersion.MQTTv5) mqttc.on_connect = on_connect mqttc.on_message = on_message -mqttc.username_pw_set(user_name, user_pass) +#mqttc.username_pw_set(user_name, user_pass) connected = False -- cgit v1.2.3