Added physical layer link statistics to reception

This commit is contained in:
Mark Qvist 2023-10-23 01:34:20 +02:00
parent f83600430a
commit a095ba7e40
4 changed files with 27 additions and 4 deletions

View File

@ -1 +1,13 @@
APP_NAME = "lxmf"
APP_NAME = "lxmf"
# WARNING! These specifications are floating and not
# yet final! Consider highly experiemental, and expect
# them to change in the future! You have been warned :)
FIELD_EMBEDDED_LXMS = 0x01
FIELD_TELEMETRY = 0x02
FIELD_ICON_APPEARANCE = 0x03
FIELD_FILE_ATTACHMENTS = 0x04
FIELD_IMAGE = 0x05
FIELD_AUDIO = 0x06
FIELD_THREAD = 0x07

View File

@ -842,10 +842,15 @@ class LXMRouter:
self.pending_outbound.append(lxmessage)
self.process_outbound()
def lxmf_delivery(self, lxmf_data, destination_type = None):
def lxmf_delivery(self, lxmf_data, destination_type = None, phy_stats = None):
try:
message = LXMessage.unpack_from_bytes(lxmf_data)
if phy_stats != None:
if "rssi" in phy_stats: message.rssi = phy_stats["rssi"]
if "snr" in phy_stats: message.snr = phy_stats["snr"]
if "q" in phy_stats: message.q = phy_stats["q"]
if destination_type == RNS.Destination.SINGLE:
message.transport_encrypted = True
message.transport_encryption = LXMessage.ENCRYPTION_DESCRIPTION_EC
@ -885,7 +890,8 @@ class LXMRouter:
else:
lxmf_data = data
if self.lxmf_delivery(lxmf_data, packet.destination_type):
phy_stats = {"rssi": packet.rssi, "snr": packet.snr, "q": packet.q}
if self.lxmf_delivery(lxmf_data, packet.destination_type, phy_stats=phy_stats):
packet.prove()
except Exception as e:
@ -907,7 +913,8 @@ class LXMRouter:
def delivery_resource_concluded(self, resource):
RNS.log("Transfer concluded for LXMF delivery resource "+str(resource), RNS.LOG_DEBUG)
if resource.status == RNS.Resource.COMPLETE:
self.lxmf_delivery(resource.data.read(), resource.link.type)
phy_stats = {"rssi": resource.link.rssi, "snr": resource.link.snr, "q": resource.link.q}
self.lxmf_delivery(resource.data.read(), resource.link.type, phy_stats=phy_stats)
### Peer Sync & Propagation ###########################

View File

@ -122,6 +122,9 @@ class LXMessage:
self.progress = None
self.state = LXMessage.DRAFT
self.method = LXMessage.UNKNOWN
self.rssi = None
self.snr = None
self.q = None
self.propagation_packed = None
self.paper_packed = None

View File

@ -2,6 +2,7 @@ import os
import glob
from .LXMessage import LXMessage
from .LXMRouter import LXMRouter
from .LXMF import *
from ._version import __version__