trx_toolkit/fake_trx.py: refactor L12TRX -> TRX2L1 burst transformation

The burst transformation in BurstForwarder.forward_msg() used to be
done only once, so then the resulting message was distributed over
the list of connected (and active) transceivers.

This approach limits the path loss simulation capabilities, because
a reference to the same message is passed to FakeTRX.send_data_msg().
If one transceiver changes (or removes) the burst bits, the other
transceivers would not receive the original message.

Let's do the transformation individually for each transceiver,
so the original message will always remain unchanged.

Change-Id: Ia016a3a9bb6e9f17182a7168aa5a501ae9b9978b
This commit is contained in:
Vadim Yanitskiy 2019-11-17 20:37:05 +07:00 committed by laforge
parent 65dbd471fc
commit b1ae186c55
2 changed files with 5 additions and 12 deletions

View File

@ -65,12 +65,6 @@ class BurstForwarder:
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())
# Iterate over all known transceivers
for trx in self.trx_list:
if trx == src_trx:
@ -81,7 +75,9 @@ class BurstForwarder:
continue
if trx.rx_freq != src_trx.tx_freq:
continue
if tx_msg.tn not in trx.ts_list:
if rx_msg.tn not in trx.ts_list:
continue
trx.send_data_msg(src_trx, rx_msg, tx_msg)
# Transform from L12TRX to TRX2L1 and forward
tx_msg = rx_msg.gen_trx2l1(ver = trx.data_if._hdr_ver)
trx.handle_data_msg(src_trx, rx_msg, tx_msg)

View File

@ -199,10 +199,7 @@ class FakeTRX(Transceiver):
# Takes (partially initialized) TRX2L1 message,
# simulates RF path parameters (such as RSSI),
# and sends towards the L1
def send_data_msg(self, src_trx, src_msg, msg):
# Override header version
msg.ver = self.data_if._hdr_ver
def handle_data_msg(self, src_trx, src_msg, msg):
# Complete message header
msg.toa256 = self.toa256
msg.rssi = self.rssi