Vadim Yanitskiy has uploaded this change for review. ( 
https://gerrit.osmocom.org/10304


Change subject: trx_toolkit/burst_fwd.py: separate burst preprocessing
......................................................................

trx_toolkit/burst_fwd.py: separate burst preprocessing

This change separates burst preprocessing (i.e. both RSSI and ToA
calculation) from BurstForwarder.transform_msg() because it's not
actually related to the message transformation process.

Change-Id: Ia7ad970593f38d9a9401975eb6dae67cd0c94e11
---
M src/target/trx_toolkit/burst_fwd.py
1 file changed, 24 insertions(+), 15 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/04/10304/1

diff --git a/src/target/trx_toolkit/burst_fwd.py 
b/src/target/trx_toolkit/burst_fwd.py
index 144ae5f..bfbe0d6 100644
--- a/src/target/trx_toolkit/burst_fwd.py
+++ b/src/target/trx_toolkit/burst_fwd.py
@@ -131,8 +131,22 @@
                # Generate a random RSSI value
                return random.randint(rssi_min, rssi_max)

+       # DL burst preprocessing
+       def preprocess_dl_burst(self, msg):
+               # Calculate both RSSI and ToA values
+               msg.toa256 = self.calc_dl_toa256()
+               msg.rssi = self.calc_dl_rssi()
+
+       # UL burst preprocessing
+       def preprocess_ul_burst(self, msg):
+               # Calculate both RSSI and ToA values,
+               # also apply Timing Advance
+               msg.toa256 = self.calc_ul_toa256()
+               msg.toa256 -= self.calc_ta256()
+               msg.rssi = self.calc_ul_rssi()
+
        # Converts a L12TRX message to TRX2L1 message
-       def transform_msg(self, msg_raw, dl = True):
+       def transform_msg(self, msg_raw):
                # Attempt to parse a message
                try:
                        msg_l12trx = DATAMSG_L12TRX()
@@ -142,18 +156,7 @@
                        return None

                # Compose a new message for L1
-               msg_trx2l1 = msg_l12trx.gen_trx2l1()
-
-               # Randomize both RSSI and ToA values
-               if dl:
-                       msg_trx2l1.toa256 = self.calc_dl_toa256()
-                       msg_trx2l1.rssi = self.calc_dl_rssi()
-               else:
-                       msg_trx2l1.toa256 = self.calc_ul_toa256()
-                       msg_trx2l1.toa256 -= self.calc_ta256()
-                       msg_trx2l1.rssi = self.calc_ul_rssi()
-
-               return msg_trx2l1
+               return msg_l12trx.gen_trx2l1()

        # Downlink handler: BTS -> BB
        def bts2bb(self):
@@ -169,7 +172,7 @@
                        return None

                # Process a message
-               msg = self.transform_msg(data, dl = True)
+               msg = self.transform_msg(data)
                if msg is None:
                        return None

@@ -177,6 +180,9 @@
                if msg.tn != self.ts_pass:
                        return None

+               # Burst preprocessing
+               self.preprocess_dl_burst(msg)
+
                # Validate and generate the payload
                payload = msg.gen_msg()

@@ -201,10 +207,13 @@
                        return None

                # Process a message
-               msg = self.transform_msg(data, dl = False)
+               msg = self.transform_msg(data)
                if msg is None:
                        return None

+               # Burst preprocessing
+               self.preprocess_ul_burst(msg)
+
                # Validate and generate the payload
                payload = msg.gen_msg()


--
To view, visit https://gerrit.osmocom.org/10304
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia7ad970593f38d9a9401975eb6dae67cd0c94e11
Gerrit-Change-Number: 10304
Gerrit-PatchSet: 1
Gerrit-Owner: Vadim Yanitskiy <[email protected]>

Reply via email to