Skip to content

Commit

Permalink
fix dict
Browse files Browse the repository at this point in the history
  • Loading branch information
8cH9azbsFifZ committed Nov 17, 2023
1 parent 1f8d168 commit 9840a7c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
6 changes: 4 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
version: '3'
services:
udp2mqtt:
image: ghcr.io/morse-code-over-ip/udp2mqtt:latest
#image: ghcr.io/morse-code-over-ip/udp2mqtt:latest
build: .
restart: always
environment:
# Configuration for UDP connections
SERVER_IP: "mopp_chat_server" #"10.101.101.14" #"127.0.0.1"
SERVER_IP: "mopp_chat_server"
#SERVER_IP: "10.101.101.14" #"127.0.0.1"
UDP_PORT: "7373"
# Configuration for Chat Server
CLIENT_TIMEOUT: "300"
Expand Down
15 changes: 7 additions & 8 deletions udp2mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,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(config.TOPIC, 0)
mqttc.subscribe(config.MQTT_TOPIC, 0)
# FIXME: Listen to durations
mqttc.loop_start()

Expand All @@ -83,15 +83,14 @@ def on_log(mqttc, obj, level, string):
last_r = r

# decode the mopp message to a json string containing the durations
mydecoded = b.return_duration_json(r["Message"])
payload = {
"version": config.MORSE_JSON_VERSION,
}
payload.update(mydecoded)
mydecoded = json.loads(b.return_duration_json(r["Message"]))

mydecoded.update({ "version": config.MORSE_JSON_VERSION, })
print (mydecoded)
sys.stdout.flush() # TODO: use logging

# And send mqtt
#infot = mqttc.publish(config.TOPIC, data_bytes, qos=2) // publish raw mopp data to another topic?
infot = mqttc.publish(config.TOPICDURATIONS, payload, qos=2)
infot = mqttc.publish(config.MQTT_TOPIC, json.dumps(mydecoded), qos=2)
infot.wait_for_publish()


Expand Down

0 comments on commit 9840a7c

Please sign in to comment.