python/trx: get rid of FakePM class

Change-Id: Ie96eb9735ecaa3329135c7be976ffd277a2f64f4
This commit is contained in:
Vadim Yanitskiy 2019-01-19 09:28:23 +07:00
parent 435d7557e8
commit 7da82f458f
6 changed files with 8 additions and 69 deletions

View File

@ -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")

View File

@ -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

View File

@ -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

View File

@ -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])

View File

@ -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)

View File

@ -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)