summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2017-07-14 09:19:22 +0700
committerVadim Yanitskiy <axilirator@gmail.com>2017-10-23 22:05:49 +0330
commitf2cedcf6972aef4b7231ac78aec2b98111870fb9 (patch)
treefff2b4ad63768edbdb78fb1954a51b77de5a772a
parentb8138c7408caf0a305d6fa4019bf20e7cbfbdc1c (diff)
fake_trx: implement simple freq. filter
-rw-r--r--src/target/fake_trx/burst_fwd.py20
-rw-r--r--src/target/fake_trx/ctrl_if_bb.py1
-rw-r--r--src/target/fake_trx/ctrl_if_bts.py2
-rwxr-xr-xsrc/target/fake_trx/fake_trx.py3
4 files changed, 26 insertions, 0 deletions
diff --git a/src/target/fake_trx/burst_fwd.py b/src/target/fake_trx/burst_fwd.py
index 1ac74c00..5989ce9c 100644
--- a/src/target/fake_trx/burst_fwd.py
+++ b/src/target/fake_trx/burst_fwd.py
@@ -26,6 +26,10 @@ class BurstForwarder:
# Timeslot filter (drop everything by default)
ts_pass = None
+ # Freq. filter
+ bts_freq = None
+ bb_freq = None
+
def __init__(self, bts_link, bb_link):
self.bts_link = bts_link
self.bb_link = bb_link
@@ -61,6 +65,14 @@ class BurstForwarder:
data, addr = self.bts_link.sock.recvfrom(512)
payload = self.process_payload(data)
+ # BB is not connected / tuned
+ if self.bb_freq is None:
+ return None
+
+ # Freq. filter
+ if self.bb_freq != self.bts_freq:
+ return None
+
# Timeslot filter
if payload[0] != self.ts_pass:
return None
@@ -74,5 +86,13 @@ class BurstForwarder:
data, addr = self.bb_link.sock.recvfrom(512)
payload = self.process_payload(data)
+ # BTS is not connected / tuned
+ if self.bts_freq is None:
+ return None
+
+ # Freq. filter
+ if self.bb_freq != self.bts_freq:
+ return None
+
# Send burst to BTS
self.bts_link.send(payload)
diff --git a/src/target/fake_trx/ctrl_if_bb.py b/src/target/fake_trx/ctrl_if_bb.py
index 3882b6af..440094a0 100644
--- a/src/target/fake_trx/ctrl_if_bb.py
+++ b/src/target/fake_trx/ctrl_if_bb.py
@@ -72,6 +72,7 @@ class CTRLInterfaceBB(CTRLInterface):
# TODO: check freq range
self.rx_freq = int(request[1]) * 1000
+ self.burst_fwd.bb_freq = self.rx_freq
return 0
elif self.verify_cmd(request, "TXTUNE", 1):
diff --git a/src/target/fake_trx/ctrl_if_bts.py b/src/target/fake_trx/ctrl_if_bts.py
index a6b03cf6..96027fe9 100644
--- a/src/target/fake_trx/ctrl_if_bts.py
+++ b/src/target/fake_trx/ctrl_if_bts.py
@@ -27,6 +27,7 @@ from ctrl_if import CTRLInterface
class CTRLInterfaceBTS(CTRLInterface):
# Internal state variables
trx_started = False
+ burst_fwd = None
rx_freq = None
tx_freq = None
pm = None
@@ -88,6 +89,7 @@ class CTRLInterfaceBTS(CTRLInterface):
# TODO: check freq range
self.tx_freq = int(request[1]) * 1000
+ self.burst_fwd.bts_freq = self.tx_freq
return 0
# Wrong / unknown command
diff --git a/src/target/fake_trx/fake_trx.py b/src/target/fake_trx/fake_trx.py
index 533b2647..aaa308d7 100755
--- a/src/target/fake_trx/fake_trx.py
+++ b/src/target/fake_trx/fake_trx.py
@@ -80,6 +80,9 @@ class Application:
self.bb_data = UDPLink(self.bb_addr,
self.bb_base_port + 102, self.bb_base_port + 2)
self.burst_fwd = BurstForwarder(self.bts_data, self.bb_data)
+
+ # Share a BurstForwarder instance between BTS and BB
+ self.bts_ctrl.burst_fwd = self.burst_fwd
self.bb_ctrl.burst_fwd = self.burst_fwd
# Share clock between BTS and BB