Skip to content
Snippets Groups Projects
Commit 3d87c782 authored by fxk8y's avatar fxk8y :spider:
Browse files

exit on error

parent 6105aa86
No related branches found
No related tags found
1 merge request!1Feature/mqtt ota
......@@ -11,11 +11,16 @@ import paho.mqtt.client as mqtt
def on_connect(client, *ignored):
client.subscribe("device/" + DEVICE + "/ota/progress")
client.subscribe("device/" + DEVICE + "/ota/error")
with open("build/qthing.bin", mode="rb") as f:
client.publish("device/" + DEVICE + "/ota/$firmware", payload=f.read())
def on_message(client, userdata, msg):
if msg.topic.endswith("error"):
print("OTA failed: " + str(msg.payload))
exit(1)
progress = int(msg.payload)
if progress == 0:
......@@ -31,7 +36,7 @@ def on_message(client, userdata, msg):
client.publish("device/" + DEVICE + "/command", "restart")
else:
exit(0)
def on_publish(client, userdata, _ignored):
if userdata.first_pub_done:
exit(0)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment