summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2020-06-03 15:28:11 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2020-06-03 16:28:37 +0200
commiteff1e31beb5258f14089e9958b100f50f36b5122 (patch)
treeba887adb07e7b02123f3770693070a7512ddc76e
parent0ed7c0ee5ffdf8e20824a73a0a3ce9f687c04341 (diff)
fake_trx: Support SETPOWER and NOMTXPOWER TRXC cmdspespin/power-ramp
By default (rssi_rand_threshold=-1) RSSI on the Rx side is computed based on transmitter's tx power and then substracting the the Rx path loss. If FAKE_RSSI is used, then the values in there are used instead. Change-Id: I3ee1a32ca22c3272e66b3ca78e4f67d283844c80
-rw-r--r--src/target/trx_toolkit/ctrl_if_trx.py13
-rwxr-xr-xsrc/target/trx_toolkit/fake_trx.py30
2 files changed, 40 insertions, 3 deletions
diff --git a/src/target/trx_toolkit/ctrl_if_trx.py b/src/target/trx_toolkit/ctrl_if_trx.py
index 65198cfe..e8419751 100644
--- a/src/target/trx_toolkit/ctrl_if_trx.py
+++ b/src/target/trx_toolkit/ctrl_if_trx.py
@@ -239,6 +239,19 @@ class CTRLInterfaceTRX(CTRLInterface):
% (self.trx, ver_cur, ver_req))
return ver_req
+ # Set Power Attenuation
+ if self.verify_cmd(request, "SETPOWER", 1):
+ log.debug("(%s) Recv SETPOWER cmd" % self.trx)
+ # Parse the requested Tx Power Attenuation
+ att_req = int(request[1])
+ self.trx.tx_att_base = att_req
+ return 0
+
+ # Retrieve Nominal Tx power
+ if self.verify_cmd(request, "NOMTXPOWER", 0):
+ log.debug("(%s) Recv NOMTXPOWER cmd" % self.trx)
+ return (0, [str(self.trx.tx_power_base)])
+
# Wrong / unknown command
else:
# We don't care about other commands,
diff --git a/src/target/trx_toolkit/fake_trx.py b/src/target/trx_toolkit/fake_trx.py
index f14d1437..4a49fa3c 100755
--- a/src/target/trx_toolkit/fake_trx.py
+++ b/src/target/trx_toolkit/fake_trx.py
@@ -106,8 +106,11 @@ class FakeTRX(Transceiver):
"""
+ NOMINAL_TX_POWER_DEFAULT = 50 # dBm
+ TX_ATT_DEFAULT = 0 # dB
+ PATH_LOSS_DEFAULT = 110 # dB
+
TOA256_BASE_DEFAULT = 0
- RSSI_BASE_DEFAULT = -60
CI_BASE_DEFAULT = 90
# Default values for NOPE / IDLE indications
@@ -118,9 +121,15 @@ class FakeTRX(Transceiver):
def __init__(self, *trx_args, **trx_kwargs):
Transceiver.__init__(self, *trx_args, **trx_kwargs)
+ # fake RSSI is disabled by default, only enabled through TRXC FAKE_RSSI.
+ # When disabled, RSSI is calculated based on Tx power and Rx path loss
+ self.fake_rssi_enabled = False
+
# Actual ToA, RSSI, C/I, TA values
+ self.tx_power_base = self.NOMINAL_TX_POWER_DEFAULT
+ self.tx_att_base = self.TX_ATT_DEFAULT
self.toa256_base = self.TOA256_BASE_DEFAULT
- self.rssi_base = self.RSSI_BASE_DEFAULT
+ self.rssi_base = self.NOMINAL_TX_POWER_DEFAULT - self.TX_ATT_DEFAULT - self.PATH_LOSS_DEFAULT
self.ci_base = self.CI_BASE_DEFAULT
self.ta = 0
@@ -156,6 +165,10 @@ class FakeTRX(Transceiver):
return random.randint(rssi_min, rssi_max)
@property
+ def tx_power(self):
+ return self.tx_power_base - self.tx_att_base
+
+ @property
def ci(self):
# Check if randomization is required
if self.ci_rand_threshold == 0:
@@ -224,7 +237,12 @@ class FakeTRX(Transceiver):
# Complete message header
msg.toa256 = self.toa256
- msg.rssi = self.rssi
+
+ # Apply RSSI based on transmitter:
+ if not self.fake_rssi_enabled:
+ msg.rssi = src_trx.tx_power - src_msg.pwr - self.PATH_LOSS_DEFAULT
+ else: # Apply fake RSSI
+ msg.rssi = self.rssi
# Version specific fields
if msg.ver >= 0x01:
@@ -272,9 +290,15 @@ class FakeTRX(Transceiver):
elif self.ctrl_if.verify_cmd(request, "FAKE_RSSI", 2):
log.debug("(%s) Recv FAKE_RSSI cmd" % self)
+ # Use negative threshold to disable fake_rssi if previously enabled:
+ if int(request[2]) < 0:
+ self.fake_rssi_enabled = False
+ return 0
+
# Parse and apply both base and threshold
self.rssi_base = int(request[1])
self.rssi_rand_threshold = int(request[2])
+ self.fake_rssi_enabled = True
return 0
# RSSI simulation