fix crash on bytes
All checks were successful
Meshtastic Map - See local Meshtastic Nodes / deploy (push) Successful in 1s
All checks were successful
Meshtastic Map - See local Meshtastic Nodes / deploy (push) Successful in 1s
This commit is contained in:
parent
c5fc8d521a
commit
30f8a3bc64
12
app.py
12
app.py
@ -12,6 +12,16 @@ MY_NODE_ID = "!934f4430"
|
|||||||
iface = meshtastic.serial_interface.SerialInterface()
|
iface = meshtastic.serial_interface.SerialInterface()
|
||||||
# iface.nodes.clear()
|
# iface.nodes.clear()
|
||||||
|
|
||||||
|
def safe_dict(obj):
|
||||||
|
if isinstance(obj, dict):
|
||||||
|
return {k: safe_dict(v) for k, v in obj.items()}
|
||||||
|
elif isinstance(obj, list):
|
||||||
|
return [safe_dict(i) for i in obj]
|
||||||
|
elif isinstance(obj, bytes):
|
||||||
|
return obj.decode(errors="replace")
|
||||||
|
else:
|
||||||
|
return obj
|
||||||
|
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
def index():
|
def index():
|
||||||
return render_template("map.html")
|
return render_template("map.html")
|
||||||
@ -29,7 +39,7 @@ def nodes():
|
|||||||
return jsonify({
|
return jsonify({
|
||||||
# "myNodeNum": MY_NODE_NUM,
|
# "myNodeNum": MY_NODE_NUM,
|
||||||
"myNodeId": MY_NODE_ID,
|
"myNodeId": MY_NODE_ID,
|
||||||
"nodes": dict(nodes)
|
"nodes": safe_dict(nodes)
|
||||||
})
|
})
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
Reference in New Issue
Block a user