mirror of
https://github.com/markqvist/LXMF.git
synced 2025-01-13 07:59:27 -05:00
Added physical layer link statistics to reception
This commit is contained in:
parent
f83600430a
commit
a095ba7e40
12
LXMF/LXMF.py
12
LXMF/LXMF.py
@ -1 +1,13 @@
|
||||
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
|
@ -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 ###########################
|
||||
|
@ -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
|
||||
|
@ -2,6 +2,7 @@ import os
|
||||
import glob
|
||||
from .LXMessage import LXMessage
|
||||
from .LXMRouter import LXMRouter
|
||||
from .LXMF import *
|
||||
|
||||
from ._version import __version__
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user