Skip to content

Commit

Permalink
telemetry values as seperate keys in mqtt
Browse files Browse the repository at this point in the history
  • Loading branch information
EricAndrechek committed Apr 10, 2024
1 parent d23c434 commit 003c59f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion tracking-dashboard/backend/mqtt-syncer.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,9 @@ def on_message(client, userdata, message):
print("No change in lat, lon, or alt")
# send telemetry data to mqtt
if 'telemetry' in src['data']:
client.publish("TELEMETRY/" + message_building[id]['name'] + "-" + str(message_building[id]['ssid']), json.dumps(src['data']['telemetry']), retain=True, qos=0)
topic = "TELEMETRY/" + message_building[id]['name'] + "-" + str(message_building[id]['ssid'])
for key in src['data']['telemetry']:
client.publish(topic + "/" + key, json.dumps(src['data']['telemetry'][key]), retain=True, qos=0)
print("Telemetry sent")
else:
print("No telemetry data")
Expand Down
3 changes: 2 additions & 1 deletion tracking-dashboard/backend/tasks/mqttadder.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ def add_data_task(data_type, data):
if data_type == "position":
client.publish("POSITION/" + data["name"], json.dumps(data), retain=True, qos=0, properties=properties)
elif data_type == "telemetry":
client.publish("TELEMETRY/" + data["name"], json.dumps(data), retain=True, qos=0, properties=properties)
for key in data:
client.publish("TELEMETRY/" + key, json.dumps(data[key]), retain=True, qos=0, properties=properties)

client.disconnect()

Expand Down

0 comments on commit 003c59f

Please sign in to comment.