Skip to content

Commit

Permalink
fix topic
Browse files Browse the repository at this point in the history
  • Loading branch information
8cH9azbsFifZ committed Nov 14, 2023
1 parent 8b2cd7e commit c1ba58f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- one echo too much?
2 changes: 2 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@
# MQTT configuration
MQTT_HOST = "broker.hivemq.com"
MQTT_PORT = 1883

TOPIC = "/moip/udp2mqtt/mopp"
6 changes: 2 additions & 4 deletions udp2mqtt.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/local/bin/python3
# Simple transmitter

import paho.mqtt.client as paho
import logging
Expand Down Expand Up @@ -30,7 +29,6 @@ def on_message(mqttc, obj, msg):

client_socket.send(msg.payload)


def on_publish(mqttc, obj, mid):
print("mid: " + str(mid))
pass
Expand All @@ -52,7 +50,7 @@ def on_log(mqttc, obj, level, string):
mqttc.on_publish = on_publish
mqttc.on_subscribe = on_subscribe
mqttc.connect(config.MQTT_HOST, config.MQTT_PORT, 60)
mqttc.subscribe("m32_test", 0)
mqttc.subscribe(config.TOPIC, 0)
mqttc.loop_start()

last_r = {} # keep track of duplicate messages...
Expand All @@ -75,7 +73,7 @@ def on_log(mqttc, obj, level, string):
last_r = r

# And send mqtt
infot = mqttc.publish("m32_test", data_bytes, qos=2)
infot = mqttc.publish(config.TOPIC, data_bytes, qos=2)
infot.wait_for_publish()


Expand Down

0 comments on commit c1ba58f

Please sign in to comment.