Digi Connect EZ Mini User Manual page 404

Firmware version 22.2
Hide thumbs Also See for Connect EZ Mini:
Table of Contents

Advertisement

Applications
ret = cli.execute("system firmware update file " + fname, 60)
except:
print("Failed to run firmware update command")
return HTTPStatus.INTERNAL_SERVER_ERROR
if not "Firmware update completed" in ret:
print("Failed to update firmware")
return HTTPStatus.INTERNAL_SERVER_ERROR
finally:
os.remove(fname)
print("Firmware update finished")
return HTTPStatus.OK
CMD_HANDLERS = {
"reboot": cmd_reboot,
"fw-update": cmd_fwupdate
}
def send_cmd_reply(client, cmd_path, cid, cmd, status):
if not status or not cid:
return
if cmd_path.startswith(PREFIX_CMD):
path = cmd_path[len(PREFIX_CMD):]
else:
print("Invalid command path ({}), cannot send reply".format(cmd_path))
return
reply = {
"cmd": cmd,
"status": status
}
client.publish(PREFIX_RSP + path + "/" + cid, json.dumps(reply, separators=
(',',':')))
def on_connect(client, userdata, flags, rc):
print("Connected to MQTT server")
client.subscribe(PREFIX_CMD + "/system")
def on_message(client, userdata, msg):
""" Supporting only a single topic for now, no need for filters
Expects the following message format:
{
"cid": "<client-id>",
"cmd": "<command>",
"params": {
<optional_parameters>
}
}
Supported commands:
- "fw-update"
params:
- "uri": "<firmware_file_URL>"
- "reboot"
params:
Digi Connect EZ Mini User Guide
Use the Paho MQTT python library
404

Advertisement

Table of Contents
loading

Table of Contents