fixed network crash

This commit is contained in:
DJ2LS 2023-05-28 16:06:07 +02:00
parent 5a5d7ac55d
commit bdfb1658ba
4 changed files with 19 additions and 8 deletions

View file

@ -117,7 +117,7 @@ class MeshRouter():
except Exception as e:
self.log.warning("[MESH] error adding data to routing table", e=e, router=new_router)
def broadcast_routing_table(self, interval=240):
def broadcast_routing_table(self, interval=40):
# enable receiving for datac4 if broadcasting
modem.RECEIVE_DATAC4 = True

View file

@ -775,10 +775,14 @@ class ThreadedTCPRequestHandler(socketserver.StreamRequestHandler):
}
for _, route in enumerate(MeshParam.routing_table):
if MeshParam.routing_table[_][0].hex() == helpers.get_crc_24(b"direct").hex():
router = "direct"
else:
router = MeshParam.routing_table[_][0].hex()
output["routes"].append(
{
"dxcall": MeshParam.routing_table[_][0],
"router": MeshParam.routing_table[_][1],
"dxcall": MeshParam.routing_table[_][0].hex(),
"router": router,
"hops": MeshParam.routing_table[_][2],
"snr": MeshParam.routing_table[_][3],
"score": MeshParam.routing_table[_][4],
@ -1150,17 +1154,21 @@ def send_tnc_state():
)
for _, route in enumerate(MeshParam.routing_table):
if MeshParam.routing_table[_][1].hex() == helpers.get_crc_24(b"direct").hex():
router = "direct"
else:
router = MeshParam.routing_table[_][1].hex()
output["routing_table"].append(
{
"dxcall": MeshParam.routing_table[_][0],
"router": MeshParam.routing_table[_][1],
"dxcall": MeshParam.routing_table[_][0].hex(),
"router": router,
"hops": MeshParam.routing_table[_][2],
"snr": MeshParam.routing_table[_][3],
"score": MeshParam.routing_table[_][4],
"timestamp": MeshParam.routing_table[_][5],
}
)
#print(output)
return json.dumps(output)

View file

@ -128,7 +128,7 @@ class TCIParam:
@dataclass
class TNC:
version = "0.10.0-alpha.1-mesh-exp5"
version = "0.10.0-alpha.1-mesh-exp6"
host: str = "0.0.0.0"
port: int = 3000
SOCKET_TIMEOUT: int = 1 # seconds

View file

@ -89,7 +89,8 @@ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
jsondata = json.loads(command)
if jsondata.get('command') == "tnc_state":
pass
#pass
print(jsondata.get("routing_table"))
if jsondata.get('freedata') == "tnc-message":
log.info(jsondata)
@ -108,6 +109,8 @@ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
if jsondata.get('status') == 'received' and jsondata.get('arq') == 'transmission':
decode_and_save_data(jsondata["data"])
# clear data buffer as soon as data has been read
data = bytes()