aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2019-01-19 09:28:23 +0700
committerVadim Yanitskiy <axilirator@gmail.com>2019-01-19 09:32:36 +0700
commit7da82f458f91fe1e2db8156e388d85da3692f83c (patch)
tree5f469fa3852131638b2eda9821a46b70ff29d51c
parent435d7557e895e4ce12bc4d52b93632f66bc423eb (diff)
python/trx: get rid of FakePM class
-rwxr-xr-xapps/grgsm_trx8
-rw-r--r--python/trx/CMakeLists.txt1
-rw-r--r--python/trx/__init__.py1
-rw-r--r--python/trx/ctrl_if_bb.py9
-rw-r--r--python/trx/fake_pm.py53
-rw-r--r--python/trx/radio_if.py5
6 files changed, 8 insertions, 69 deletions
diff --git a/apps/grgsm_trx b/apps/grgsm_trx
index 7eeea50..c3e83d9 100755
--- a/apps/grgsm_trx
+++ b/apps/grgsm_trx
@@ -31,7 +31,6 @@ from gnuradio import eng_notation
from grgsm.trx import CTRLInterfaceBB
from grgsm.trx import RadioInterface
-from grgsm.trx import FakePM
COPYRIGHT = \
"Copyright (C) 2016-2018 by Vadim Yanitskiy <axilirator@gmail.com>\n" \
@@ -65,16 +64,11 @@ class Application:
self.phy_freq_offset, self.bind_addr,
self.remote_addr, self.base_port)
- # Power measurement emulation
- # Noise: -120 .. -105
- # BTS: -75 .. -50
- self.pm = FakePM(-120, -105, -75, -50)
-
# Init TRX CTRL interface
self.server = CTRLInterfaceBB(
self.remote_addr, self.base_port + 101,
self.bind_addr, self.base_port + 1,
- self.radio, self.pm)
+ self.radio)
print("[i] Init complete")
diff --git a/python/trx/CMakeLists.txt b/python/trx/CMakeLists.txt
index ffe5234..4333407 100644
--- a/python/trx/CMakeLists.txt
+++ b/python/trx/CMakeLists.txt
@@ -23,7 +23,6 @@ GR_PYTHON_INSTALL(
udp_link.py
ctrl_if.py
ctrl_if_bb.py
- fake_pm.py
radio_if.py
radio_if_grc.py
dict_toggle_sign.py
diff --git a/python/trx/__init__.py b/python/trx/__init__.py
index c512262..7b20699 100644
--- a/python/trx/__init__.py
+++ b/python/trx/__init__.py
@@ -23,7 +23,6 @@ This is a set of helper classes for the grgsm_trx application.
from udp_link import UDPLink
from ctrl_if import CTRLInterface
from ctrl_if_bb import CTRLInterfaceBB
-from fake_pm import FakePM
from radio_if_grc import RadioInterfaceGRC
from radio_if import RadioInterface
diff --git a/python/trx/ctrl_if_bb.py b/python/trx/ctrl_if_bb.py
index 781c35c..f9840d4 100644
--- a/python/trx/ctrl_if_bb.py
+++ b/python/trx/ctrl_if_bb.py
@@ -27,7 +27,7 @@ import grgsm
from ctrl_if import CTRLInterface
class CTRLInterfaceBB(CTRLInterface):
- def __init__(self, remote_addr, remote_port, bind_addr, bind_port, tb, pm):
+ def __init__(self, remote_addr, remote_port, bind_addr, bind_port, tb):
CTRLInterface.__init__(self, remote_addr, remote_port,
bind_addr, bind_port)
@@ -35,8 +35,6 @@ class CTRLInterfaceBB(CTRLInterface):
# Set link to the follow graph (top block)
self.tb = tb
- # Power measurement
- self.pm = pm
def parse_cmd(self, request):
# Power control
@@ -137,10 +135,7 @@ class CTRLInterfaceBB(CTRLInterface):
# TODO: check freq range
meas_freq = int(request[1]) * 1000
-
- # HACK: send fake low power values
- # until actual power measurement is implemented
- meas_dbm = str(self.pm.measure(meas_freq))
+ meas_dbm = str(self.tb.measure(meas_freq))
return (0, [meas_dbm])
diff --git a/python/trx/fake_pm.py b/python/trx/fake_pm.py
deleted file mode 100644
index 1d76916..0000000
--- a/python/trx/fake_pm.py
+++ /dev/null
@@ -1,53 +0,0 @@
-#!/usr/bin/env python2
-# -*- coding: utf-8 -*-
-
-# Virtual Um-interface (fake transceiver)
-# Power measurement emulation for BB
-#
-# (C) 2017 by Vadim Yanitskiy <axilirator@gmail.com>
-#
-# All Rights Reserved
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-from random import randint
-
-class FakePM:
- # Freq. list for good power level
- bts_list = []
-
- def __init__(self, noise_min, noise_max, bts_min, bts_max):
- # Save power level ranges
- self.noise_min = noise_min
- self.noise_max = noise_max
- self.bts_min = bts_min
- self.bts_max = bts_max
-
- def measure(self, bts):
- if bts in self.bts_list:
- return randint(self.bts_min, self.bts_max)
- else:
- return randint(self.noise_min, self.noise_max)
-
- def update_bts_list(self, new_list):
- self.bts_list = new_list
-
- def add_bts_list(self, add_list):
- self.bts_list += add_list
-
- def del_bts_list(self, del_list):
- for item in del_list:
- if item in self.bts_list:
- self.bts_list.remove(item)
diff --git a/python/trx/radio_if.py b/python/trx/radio_if.py
index 55c8d92..32b767a 100644
--- a/python/trx/radio_if.py
+++ b/python/trx/radio_if.py
@@ -26,6 +26,7 @@
import pmt
import time
import grgsm
+import random
from math import pi
@@ -290,3 +291,7 @@ class RadioInterface(gr.top_block):
print("[i] Setting TA value %d" % ta)
advance_time_sec = ta * self.GSM_SYM_PERIOD_uS * 1e-6
self.tx_time_setter.set_timing_advance(advance_time_sec)
+
+ def measure(self, freq):
+ # HACK: generate a random low RSSI value
+ return random.randint(-120, -100)