summaryrefslogtreecommitdiffstats
path: root/src/target
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2018-08-02 03:50:57 +0700
committerVadim Yanitskiy <axilirator@gmail.com>2018-08-02 03:50:57 +0700
commitb914cfd48898a2cd4129c85a07fb246477fec34d (patch)
treeba8e4a77bc320532a191f54f104eca853080753d /src/target
parent488f92d8b869ffa626b83ff75ed93989a43e0732 (diff)
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
Diffstat (limited to 'src/target')
-rw-r--r--src/target/trx_toolkit/burst_fwd.py39
1 files changed, 24 insertions, 15 deletions
diff --git a/src/target/trx_toolkit/burst_fwd.py b/src/target/trx_toolkit/burst_fwd.py
index 144ae5f4..bfbe0d61 100644
--- a/src/target/trx_toolkit/burst_fwd.py
+++ b/src/target/trx_toolkit/burst_fwd.py
@@ -131,8 +131,22 @@ class BurstForwarder:
# 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 @@ class BurstForwarder:
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 @@ class BurstForwarder:
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 @@ class BurstForwarder:
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 @@ class BurstForwarder:
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()