mirror of
https://github.com/meshtastic/python.git
synced 2025-12-30 19:37:52 -05:00
Merge pull request #433 from mverch67/master
Output of --info "Nodes in mesh" to JSON Format - YOLO
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
"""Mesh Interface class
|
||||
"""
|
||||
|
||||
import collections
|
||||
import logging
|
||||
import random
|
||||
import sys
|
||||
import threading
|
||||
import time
|
||||
import json
|
||||
from datetime import datetime
|
||||
from typing import AnyStr
|
||||
|
||||
@@ -100,8 +102,8 @@ class MeshInterface:
|
||||
myinfo = ""
|
||||
if self.myInfo:
|
||||
myinfo = f"\nMy info: {stripnl(MessageToJson(self.myInfo))}"
|
||||
mesh = "\nNodes in mesh:"
|
||||
nodes = ""
|
||||
mesh = "\n\nNodes in mesh: "
|
||||
nodes = {}
|
||||
if self.nodes:
|
||||
for n in self.nodes.values():
|
||||
# when the TBeam is first booted, it sometimes shows the raw data
|
||||
@@ -116,8 +118,11 @@ class MeshInterface:
|
||||
addr = convert_mac_addr(val)
|
||||
n2["user"]["macaddr"] = addr
|
||||
|
||||
nodes = nodes + f" {stripnl(n2)}"
|
||||
infos = owner + myinfo + mesh + nodes
|
||||
# use id as dictionary key for correct json format in list of nodes
|
||||
nodeid = n2['user']['id']
|
||||
n2['user'].pop('id')
|
||||
nodes[nodeid] = n2
|
||||
infos = owner + myinfo + mesh + json.dumps(nodes)
|
||||
print(infos)
|
||||
return infos
|
||||
|
||||
|
||||
Reference in New Issue
Block a user