mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
changed router to origin
This commit is contained in:
parent
6c1d8a1415
commit
6ec7397eef
|
@ -159,10 +159,10 @@ ipcRenderer.on("action-update-mesh-table", (event, arg) => {
|
||||||
}
|
}
|
||||||
destination.appendChild(destinationText);
|
destination.appendChild(destinationText);
|
||||||
|
|
||||||
var router = document.createElement("td");
|
var origin = document.createElement("td");
|
||||||
var routerText = document.createElement("span");
|
var originText = document.createElement("span");
|
||||||
routerText.innerText = routes[i]["router"];
|
originText.innerText = routes[i]["origin"];
|
||||||
router.appendChild(routerText);
|
origin.appendChild(originText);
|
||||||
|
|
||||||
var frametype = document.createElement("td");
|
var frametype = document.createElement("td");
|
||||||
var frametypeText = document.createElement("span");
|
var frametypeText = document.createElement("span");
|
||||||
|
@ -186,7 +186,7 @@ ipcRenderer.on("action-update-mesh-table", (event, arg) => {
|
||||||
|
|
||||||
row.appendChild(timestamp);
|
row.appendChild(timestamp);
|
||||||
row.appendChild(destination);
|
row.appendChild(destination);
|
||||||
row.appendChild(router);
|
row.appendChild(origin);
|
||||||
row.appendChild(frametype);
|
row.appendChild(frametype);
|
||||||
row.appendChild(payload);
|
row.appendChild(payload);
|
||||||
row.appendChild(attempt);
|
row.appendChild(attempt);
|
||||||
|
|
|
@ -56,7 +56,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col">Timestamp</th>
|
<th scope="col">Timestamp</th>
|
||||||
<th scope="col">Destination</th>
|
<th scope="col">Destination</th>
|
||||||
<th scope="col">Router</th>
|
<th scope="col">Origin</th>
|
||||||
<th scope="col">Frametype</th>
|
<th scope="col">Frametype</th>
|
||||||
<th scope="col">Payload</th>
|
<th scope="col">Payload</th>
|
||||||
<th scope="col">Attempt</th>
|
<th scope="col">Attempt</th>
|
||||||
|
|
56
tnc/mesh.py
56
tnc/mesh.py
|
@ -271,7 +271,7 @@ class MeshRouter():
|
||||||
|
|
||||||
|
|
||||||
def mesh_signalling_dispatcher(self):
|
def mesh_signalling_dispatcher(self):
|
||||||
# [timestamp, destination, router, frametype, payload, attempt, status]
|
# [timestamp, destination, origin, frametype, payload, attempt, status]
|
||||||
# --------------0------------1---------2---------3--------4---------5--------6 #
|
# --------------0------------1---------2---------3--------4---------5--------6 #
|
||||||
|
|
||||||
|
|
||||||
|
@ -295,11 +295,11 @@ class MeshRouter():
|
||||||
# check if it is time to transmit
|
# check if it is time to transmit
|
||||||
if time.time() >= transmission_time:
|
if time.time() >= transmission_time:
|
||||||
entry[5] += 1
|
entry[5] += 1
|
||||||
self.log.info("[MESH] [TX] Ping", destination=entry[1])
|
self.log.info("[MESH] [TX] Ping", destination=entry[1], origin=entry[2])
|
||||||
channel_busy_timeout = time.time() + 5
|
channel_busy_timeout = time.time() + 5
|
||||||
while ModemParam.channel_busy and time.time() < channel_busy_timeout:
|
while ModemParam.channel_busy and time.time() < channel_busy_timeout:
|
||||||
threading.Event().wait(0.01)
|
threading.Event().wait(0.01)
|
||||||
self.transmit_mesh_signalling_ping(bytes.fromhex(entry[1]))
|
self.transmit_mesh_signalling_ping(bytes.fromhex(entry[1]), bytes.fromhex(entry[2]))
|
||||||
#print("...")
|
#print("...")
|
||||||
|
|
||||||
def received_routing_table(self, data_in):
|
def received_routing_table(self, data_in):
|
||||||
|
@ -376,30 +376,31 @@ class MeshRouter():
|
||||||
|
|
||||||
def received_mesh_ping(self, data_in):
|
def received_mesh_ping(self, data_in):
|
||||||
destination = data_in[1:4].hex()
|
destination = data_in[1:4].hex()
|
||||||
|
origin = data_in[4:7].hex()
|
||||||
if destination == Station.mycallsign_crc.hex():
|
if destination == Station.mycallsign_crc.hex():
|
||||||
self.log.info("[MESH] [RX] [PING] [REQ]", destination=destination, mycall=Station.mycallsign_crc.hex())
|
self.log.info("[MESH] [RX] [PING] [REQ]", destination=destination, origin=origin, mycall=Station.mycallsign_crc.hex())
|
||||||
# use case 1: set status to acknowleding if we are the receiver of a PING
|
# use case 1: set status to acknowleding if we are the receiver of a PING
|
||||||
self.add_mesh_ping_to_signalling_table(destination, status="acknowledging")
|
self.add_mesh_ping_to_signalling_table(destination, origin, status="acknowledging")
|
||||||
|
|
||||||
channel_busy_timeout = time.time() + 5
|
channel_busy_timeout = time.time() + 5
|
||||||
while ModemParam.channel_busy and time.time() < channel_busy_timeout:
|
while ModemParam.channel_busy and time.time() < channel_busy_timeout:
|
||||||
threading.Event().wait(0.01)
|
threading.Event().wait(0.01)
|
||||||
|
|
||||||
dxcallsign_crc = Station.mycallsign_crc
|
# dxcallsign_crc = Station.mycallsign_crc
|
||||||
self.transmit_mesh_signalling_ping_ack(dxcallsign_crc)
|
self.transmit_mesh_signalling_ping_ack(bytes.fromhex(destination), bytes.fromhex(origin))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
self.log.info("[MESH] [RX] [PING] [REQ]", destination=destination, mycall=Station.mycallsign_crc.hex())
|
self.log.info("[MESH] [RX] [PING] [REQ]", destination=destination, origin=origin, mycall=Station.mycallsign_crc.hex())
|
||||||
# lookup if entry is already in database - if so, udpate and exit
|
# lookup if entry is already in database - if so, udpate and exit
|
||||||
for item in MESH_SIGNALLING_TABLE:
|
for item in MESH_SIGNALLING_TABLE:
|
||||||
if item[1] == destination and item[5] >= self.signalling_max_attempts:
|
if item[1] == destination and item[5] >= self.signalling_max_attempts:
|
||||||
# use case 2: set status to forwarded if we are not the receiver of a PING and out of retries
|
# use case 2: set status to forwarded if we are not the receiver of a PING and out of retries
|
||||||
self.add_mesh_ping_to_signalling_table(destination, status="forwarded")
|
self.add_mesh_ping_to_signalling_table(destination, origin, status="forwarded")
|
||||||
return
|
return
|
||||||
|
|
||||||
print("......................")
|
print("......................")
|
||||||
# use case 1: set status to forwarding if we are not the receiver of a PING and we don't have an entry in our database
|
# use case 1: set status to forwarding if we are not the receiver of a PING and we don't have an entry in our database
|
||||||
self.add_mesh_ping_to_signalling_table(destination, status="forwarding")
|
self.add_mesh_ping_to_signalling_table(destination, origin, status="forwarding")
|
||||||
|
|
||||||
def received_mesh_ping_ack(self, data_in):
|
def received_mesh_ping_ack(self, data_in):
|
||||||
# TODO:
|
# TODO:
|
||||||
|
@ -408,16 +409,17 @@ class MeshRouter():
|
||||||
# if not, then add to table
|
# if not, then add to table
|
||||||
|
|
||||||
destination = data_in[1:4].hex()
|
destination = data_in[1:4].hex()
|
||||||
|
origin = data_in[4:7].hex()
|
||||||
timestamp = time.time()
|
timestamp = time.time()
|
||||||
router = ""
|
#router = ""
|
||||||
frametype = "PING-ACK"
|
frametype = "PING-ACK"
|
||||||
payload = ""
|
payload = ""
|
||||||
attempt = 0
|
attempt = 0
|
||||||
|
|
||||||
|
|
||||||
if destination == Station.mycallsign_crc.hex():
|
if destination == Station.mycallsign_crc.hex():
|
||||||
self.log.info("[MESH] [RX] [PING] [ACK]", destination=destination, mycall=Station.mycallsign_crc.hex())
|
self.log.info("[MESH] [RX] [PING] [ACK]", destination=destination, origin=origin, mycall=Station.mycallsign_crc.hex())
|
||||||
self.add_mesh_ping_ack_to_signalling_table(destination, status="acknowledged")
|
self.add_mesh_ping_ack_to_signalling_table(destination, origin, status="acknowledged")
|
||||||
else:
|
else:
|
||||||
#status = "forwarding"
|
#status = "forwarding"
|
||||||
#self.add_mesh_ping_ack_to_signalling_table(destination, status)
|
#self.add_mesh_ping_ack_to_signalling_table(destination, status)
|
||||||
|
@ -428,23 +430,23 @@ class MeshRouter():
|
||||||
self.add_mesh_ping_ack_to_signalling_table(destination, status="forwarded")
|
self.add_mesh_ping_ack_to_signalling_table(destination, status="forwarded")
|
||||||
return
|
return
|
||||||
|
|
||||||
self.add_mesh_ping_ack_to_signalling_table(destination, status="forwarding")
|
self.add_mesh_ping_ack_to_signalling_table(destination, origin, status="forwarding")
|
||||||
#dxcallsign_crc = bytes.fromhex(destination)
|
#dxcallsign_crc = bytes.fromhex(destination)
|
||||||
#self.transmit_mesh_signalling_ping_ack(dxcallsign_crc)
|
#self.transmit_mesh_signalling_ping_ack(dxcallsign_crc)
|
||||||
|
|
||||||
print(MESH_SIGNALLING_TABLE)
|
print(MESH_SIGNALLING_TABLE)
|
||||||
|
|
||||||
|
|
||||||
def add_mesh_ping_to_signalling_table(self, destination, status):
|
def add_mesh_ping_to_signalling_table(self, destination, origin, status):
|
||||||
timestamp = time.time()
|
timestamp = time.time()
|
||||||
router = ""
|
#router = ""
|
||||||
frametype = "PING"
|
frametype = "PING"
|
||||||
payload = ""
|
payload = ""
|
||||||
attempt = 0
|
attempt = 0
|
||||||
|
|
||||||
# [timestamp, destination, router, frametype, payload, attempt, status]
|
# [timestamp, destination, origin, frametype, payload, attempt, status]
|
||||||
# --------------0------------1---------2---------3--------4---------5--------6-----#
|
# --------------0------------1---------2---------3--------4---------5--------6-----#
|
||||||
new_entry = [timestamp, destination, router, frametype, payload, attempt, status]
|
new_entry = [timestamp, destination, origin, frametype, payload, attempt, status]
|
||||||
for _, item in enumerate(MESH_SIGNALLING_TABLE):
|
for _, item in enumerate(MESH_SIGNALLING_TABLE):
|
||||||
# update entry if exists
|
# update entry if exists
|
||||||
if destination in item[1] and "PING" in item[3]:
|
if destination in item[1] and "PING" in item[3]:
|
||||||
|
@ -465,14 +467,14 @@ class MeshRouter():
|
||||||
|
|
||||||
MESH_SIGNALLING_TABLE.append(new_entry)
|
MESH_SIGNALLING_TABLE.append(new_entry)
|
||||||
|
|
||||||
def add_mesh_ping_ack_to_signalling_table(self, destination, status):
|
def add_mesh_ping_ack_to_signalling_table(self, destination, origin, status):
|
||||||
|
|
||||||
timestamp = time.time()
|
timestamp = time.time()
|
||||||
router = ""
|
#router = ""
|
||||||
frametype = "PING-ACK"
|
frametype = "PING-ACK"
|
||||||
payload = ""
|
payload = ""
|
||||||
attempt = 0
|
attempt = 0
|
||||||
new_entry = [timestamp, destination, router, frametype, payload, attempt, status]
|
new_entry = [timestamp, destination, origin, frametype, payload, attempt, status]
|
||||||
|
|
||||||
for _, item in enumerate(MESH_SIGNALLING_TABLE):
|
for _, item in enumerate(MESH_SIGNALLING_TABLE):
|
||||||
# update entry if exists
|
# update entry if exists
|
||||||
|
@ -528,27 +530,27 @@ class MeshRouter():
|
||||||
threading.Event().wait(0.01)
|
threading.Event().wait(0.01)
|
||||||
|
|
||||||
|
|
||||||
def transmit_mesh_signalling_ping(self, dxcallsign_crc):
|
def transmit_mesh_signalling_ping(self, destination, origin):
|
||||||
|
|
||||||
frame_type = bytes([FRAME_TYPE.MESH_SIGNALLING_PING.value])
|
frame_type = bytes([FRAME_TYPE.MESH_SIGNALLING_PING.value])
|
||||||
|
|
||||||
ping_frame = bytearray(14)
|
ping_frame = bytearray(14)
|
||||||
ping_frame[:1] = frame_type
|
ping_frame[:1] = frame_type
|
||||||
ping_frame[1:4] = dxcallsign_crc
|
ping_frame[1:4] = destination
|
||||||
ping_frame[4:7] = helpers.get_crc_24(Station.mycallsign)
|
ping_frame[4:7] = origin
|
||||||
ping_frame[7:13] = helpers.callsign_to_bytes(Station.mycallsign)
|
ping_frame[7:13] = helpers.callsign_to_bytes(Station.mycallsign)
|
||||||
|
|
||||||
self.enqueue_frame_for_tx([ping_frame], c2_mode=FREEDV_MODE.sig0.value)
|
self.enqueue_frame_for_tx([ping_frame], c2_mode=FREEDV_MODE.sig0.value)
|
||||||
|
|
||||||
def transmit_mesh_signalling_ping_ack(self, dxcallsign_crc):
|
def transmit_mesh_signalling_ping_ack(self, destination, origin):
|
||||||
#dxcallsign_crc = bytes.fromhex(data[1])
|
#dxcallsign_crc = bytes.fromhex(data[1])
|
||||||
|
|
||||||
frame_type = bytes([FRAME_TYPE.MESH_SIGNALLING_PING_ACK.value])
|
frame_type = bytes([FRAME_TYPE.MESH_SIGNALLING_PING_ACK.value])
|
||||||
|
|
||||||
ping_frame = bytearray(14)
|
ping_frame = bytearray(14)
|
||||||
ping_frame[:1] = frame_type
|
ping_frame[:1] = frame_type
|
||||||
ping_frame[1:4] = dxcallsign_crc
|
ping_frame[1:4] = destination
|
||||||
#ping_frame[4:7] = helpers.get_crc_24(Station.mycallsign)
|
ping_frame[4:7] = origin
|
||||||
#ping_frame[7:13] = helpers.callsign_to_bytes(Station.mycallsign)
|
#ping_frame[7:13] = helpers.callsign_to_bytes(Station.mycallsign)
|
||||||
|
|
||||||
self.enqueue_frame_for_tx([ping_frame], c2_mode=FREEDV_MODE.sig0.value)
|
self.enqueue_frame_for_tx([ping_frame], c2_mode=FREEDV_MODE.sig0.value)
|
|
@ -1219,7 +1219,7 @@ def send_tnc_state():
|
||||||
{
|
{
|
||||||
"timestamp": MESH_SIGNALLING_TABLE[_][0],
|
"timestamp": MESH_SIGNALLING_TABLE[_][0],
|
||||||
"destination": MESH_SIGNALLING_TABLE[_][1],
|
"destination": MESH_SIGNALLING_TABLE[_][1],
|
||||||
"router": MESH_SIGNALLING_TABLE[_][2],
|
"origin": MESH_SIGNALLING_TABLE[_][2],
|
||||||
"frametype": MESH_SIGNALLING_TABLE[_][3],
|
"frametype": MESH_SIGNALLING_TABLE[_][3],
|
||||||
"payload": MESH_SIGNALLING_TABLE[_][4],
|
"payload": MESH_SIGNALLING_TABLE[_][4],
|
||||||
"attempt": MESH_SIGNALLING_TABLE[_][5],
|
"attempt": MESH_SIGNALLING_TABLE[_][5],
|
||||||
|
|
Loading…
Reference in a new issue