summaryrefslogtreecommitdiffstats
path: root/src/target/trx_toolkit/burst_fwd.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/target/trx_toolkit/burst_fwd.py')
-rw-r--r--src/target/trx_toolkit/burst_fwd.py59
1 files changed, 20 insertions, 39 deletions
diff --git a/src/target/trx_toolkit/burst_fwd.py b/src/target/trx_toolkit/burst_fwd.py
index b418aef1..69245317 100644
--- a/src/target/trx_toolkit/burst_fwd.py
+++ b/src/target/trx_toolkit/burst_fwd.py
@@ -1,10 +1,10 @@
-#!/usr/bin/env python
# -*- coding: utf-8 -*-
# TRX Toolkit
# Burst forwarding between transceivers
#
-# (C) 2017-2018 by Vadim Yanitskiy <axilirator@gmail.com>
+# (C) 2017-2020 by Vadim Yanitskiy <axilirator@gmail.com>
+# Contributions by sysmocom - s.f.m.c. GmbH
#
# All Rights Reserved
#
@@ -17,14 +17,12 @@
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
import logging as log
-class BurstForwarder:
+from trx_list import TRXList
+
+class BurstForwarder(TRXList):
""" Performs burst forwarding between transceivers.
BurstForwarder distributes bursts between the list of given
@@ -35,41 +33,22 @@ class BurstForwarder:
- actual RX / TX frequencies,
- list of active timeslots.
- Each to be distributed L12TRX message is being transformed
- into a TRX2L1 message, and then forwarded to transceivers
+ Each to be distributed 'TxMsg' message is being transformed
+ into a 'RxMsg' message, and then forwarded to transceivers
with partially initialized header. All uninitialized header
fields (such as rssi and toa256) shall be set by each
transceiver individually before sending towards the L1.
"""
- def __init__(self, trx_list = None):
- # List of Transceiver instances
- if trx_list is not None:
- self.trx_list = trx_list
- else:
- self.trx_list = []
-
- def add_trx(self, trx):
- if trx in self.trx_list:
- log.error("TRX is already in the list")
- return
-
- self.trx_list.append(trx)
-
- def del_trx(self, trx):
- if trx not in self.trx_list:
- log.error("TRX is not in the list")
- return
-
- self.trx_list.remove(trx)
-
def forward_msg(self, src_trx, rx_msg):
- # Transform from L12TRX to TRX2L1
- tx_msg = rx_msg.gen_trx2l1()
- if tx_msg is None:
- log.error("Forwarding failed, could not transform "
- "message (%s) => dropping..." % rx_msg.desc_hdr())
+ # Originating Transceiver may use frequency hopping,
+ # so let's precalculate its Tx frequency in advance
+ tx_freq = src_trx.get_tx_freq(rx_msg.fn)
+
+ if src_trx.rf_muted:
+ del rx_msg.burst # burst bits are omited
+ rx_msg.burst = None
# Iterate over all known transceivers
for trx in self.trx_list:
@@ -79,9 +58,11 @@ class BurstForwarder:
# Check transceiver state
if not trx.running:
continue
- if trx.rx_freq != src_trx.tx_freq:
- continue
- if tx_msg.tn not in trx.ts_list:
+
+ # Match Tx/Rx frequencies of the both transceivers
+ if trx.get_rx_freq(rx_msg.fn) != tx_freq:
continue
- trx.send_data_msg(src_trx, rx_msg, tx_msg)
+ # Transform from TxMsg to RxMsg and forward
+ tx_msg = rx_msg.trans(ver = trx.data_if._hdr_ver)
+ trx.handle_data_msg(src_trx, rx_msg, tx_msg)