diff --git a/docker-compose.yml b/docker-compose.yml index c74e2a6..cd2f5e5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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" diff --git a/udp2mqtt.py b/udp2mqtt.py index bc3b2a5..005bb84 100644 --- a/udp2mqtt.py +++ b/udp2mqtt.py @@ -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() @@ -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()