mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
initial work on mesh prototype
This commit is contained in:
parent
55a28c79ed
commit
c174a543fd
3 changed files with 74 additions and 3 deletions
|
@ -8,10 +8,11 @@ import time
|
|||
from datetime import datetime,timezone
|
||||
import crcengine
|
||||
import static
|
||||
from static import ARQ, AudioParam, Beacon, Channel, Daemon, HamlibParam, ModemParam, Station, Statistics, TCIParam, TNC
|
||||
from static import ARQ, AudioParam, Beacon, Channel, Daemon, HamlibParam, ModemParam, Station, Statistics, TCIParam, TNC, MeshParam
|
||||
import structlog
|
||||
import numpy as np
|
||||
import threading
|
||||
import mesh
|
||||
|
||||
log = structlog.get_logger("helpers")
|
||||
|
||||
|
@ -164,7 +165,8 @@ def add_to_heard_stations(dxcallsign, dxgrid, datatype, snr, offset, frequency):
|
|||
]
|
||||
)
|
||||
break
|
||||
|
||||
# trigger update of routing table
|
||||
mesh.MeshRouter.get_from_heard_stations()
|
||||
|
||||
# for idx, item in enumerate(TNC.heard_stations):
|
||||
# if dxcallsign in item:
|
||||
|
|
66
tnc/mesh.py
Normal file
66
tnc/mesh.py
Normal file
|
@ -0,0 +1,66 @@
|
|||
# -*- coding: UTF-8 -*-
|
||||
"""
|
||||
|
||||
@author: DJ2LS
|
||||
|
||||
HF mesh networking prototype and testing module
|
||||
|
||||
import time
|
||||
MeshParam.routing_table = [['AA1AA', 'direct', 0, 1.0, 25, time.time(), ], ['AA1AA', 'AA2BB', 1, 3.1, 10, time.time(), ],
|
||||
['AA3CC', 'AA2BB', 5, -4.5, -3, time.time(), ]]
|
||||
|
||||
print(MeshParam.routing_table)
|
||||
print("---------------------------------")
|
||||
|
||||
"""
|
||||
# pylint: disable=invalid-name, line-too-long, c-extension-no-member
|
||||
# pylint: disable=import-outside-toplevel, attribute-defined-outside-init
|
||||
|
||||
from static import TNC, MeshParam
|
||||
import time
|
||||
import threading
|
||||
|
||||
class MeshRouter():
|
||||
|
||||
def get_from_heard_stations(self):
|
||||
"""
|
||||
get data from heard stations
|
||||
heard stations format:
|
||||
[dxcallsign,dxgrid,int(time.time()),datatype,snr,offset,frequency]
|
||||
|
||||
TNC.heard_stations.append(
|
||||
[
|
||||
dxcallsign,
|
||||
dxgrid,
|
||||
int(time.time()),
|
||||
datatype,
|
||||
snr,
|
||||
offset,
|
||||
frequency,
|
||||
]
|
||||
)
|
||||
"""
|
||||
dxcallsign = 0
|
||||
dxgrid = 1
|
||||
timestamp = 2
|
||||
type = 3
|
||||
snr = 4
|
||||
offset = 5
|
||||
frequency = 6
|
||||
|
||||
|
||||
for item in TNC.heard_stations:
|
||||
new_router = [item[dxcallsign], 'direct', 0, item[snr], item[snr], item[timestamp]]
|
||||
self.add_router_to_routing_table(new_router)
|
||||
|
||||
def add_router_to_routing_table(self, new_router):
|
||||
# destination callsign # router callsign # hops # rx snr # route quality # timestamp
|
||||
for _, item in enumerate(MeshParam.routing_table):
|
||||
# update routing entry if exists
|
||||
if new_router[0] in item[0] and new_router[1] in item[1]:
|
||||
print(f"UPDATE {MeshParam.routing_table[_]} >>> {new_router}")
|
||||
MeshParam.routing_table[_] = new_router
|
||||
|
||||
# add new routing entry if not exists
|
||||
if new_router not in MeshParam.routing_table:
|
||||
MeshParam.routing_table.append(new_router)
|
|
@ -93,6 +93,9 @@ class HamlibParam:
|
|||
hamlib_rf: int = 0
|
||||
|
||||
@dataclass
|
||||
class MeshParam:
|
||||
routing_table = []
|
||||
@dataclass
|
||||
class ModemParam:
|
||||
tuning_range_fmin: float = -50.0
|
||||
tuning_range_fmax: float = 50.0
|
||||
|
|
Loading…
Reference in a new issue