1 # -*- coding: utf-8 -*-
4 # Burst forwarding between transceivers
6 # (C) 2017-2020 by Vadim Yanitskiy <axilirator@gmail.com>
7 # Contributions by sysmocom - s.f.m.c. GmbH
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2 of the License, or
14 # (at your option) any later version.
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
23 from trx_list
import TRXList
25 class BurstForwarder(TRXList
):
26 """ Performs burst forwarding between transceivers.
28 BurstForwarder distributes bursts between the list of given
29 FakeTRX (Transceiver) instances depending on the following
30 parameters of each transceiver:
32 - execution state (running or idle),
33 - actual RX / TX frequencies,
34 - list of active timeslots.
36 Each to be distributed 'TxMsg' message is being transformed
37 into a 'RxMsg' message, and then forwarded to transceivers
38 with partially initialized header. All uninitialized header
39 fields (such as rssi and toa256) shall be set by each
40 transceiver individually before sending towards the L1.
44 def forward_msg(self
, src_trx
, rx_msg
):
45 # Originating Transceiver may use frequency hopping,
46 # so let's precalculate its Tx frequency in advance
47 tx_freq
= src_trx
.get_tx_freq(rx_msg
.fn
)
50 del rx_msg
.burst
# burst bits are omited
53 # Iterate over all known transceivers
54 for trx
in self
.trx_list
:
58 # Check transceiver state
62 # Match Tx/Rx frequencies of the both transceivers
63 if trx
.get_rx_freq(rx_msg
.fn
) != tx_freq
:
66 # Transform from TxMsg to RxMsg and forward
67 tx_msg
= rx_msg
.trans(ver
= trx
.data_if
._hdr
_ver
)
68 trx
.handle_data_msg(src_trx
, rx_msg
, tx_msg
)