Skip to content

Commit

Permalink
wip json version
Browse files Browse the repository at this point in the history
  • Loading branch information
8cH9azbsFifZ committed Nov 17, 2023
1 parent d8576ac commit 62bc220
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
0.0.9 - add versioned json output
0.0.8 - move json duration string to mopp module (pip)
0.0.7 - topic for durations array
0.0.6 - topic changed
Expand Down
4 changes: 3 additions & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@
MQTT_PORT = 1883

TOPIC = "/moip/udp2mqtt/mopp"
TOPICDURATIONS = "/moip/udp2mqtt/durations"
TOPICDURATIONS = "/moip/udp2mqtt/durations"

MORSE_JSON_VERSION = 1
6 changes: 5 additions & 1 deletion udp2mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,14 @@ def on_log(mqttc, obj, level, string):

# 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)

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


Expand Down

0 comments on commit 62bc220

Please sign in to comment.