summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2018-01-27 22:09:53 +0700
committerVadim Yanitskiy <axilirator@gmail.com>2018-01-29 04:19:01 +0700
commite3a23102b715387b0a3d8d4e16d04ac52cde98b4 (patch)
tree227bf398bbac8fb944fa3fdfe2f8b16b72b21f82
parentd273ebf611bfafa6234961b13979f21d0223caec (diff)
fake_trx/burst_gen.py: also handle RSSI and ToA values
-rwxr-xr-xsrc/target/fake_trx/burst_gen.py36
1 files changed, 29 insertions, 7 deletions
diff --git a/src/target/fake_trx/burst_gen.py b/src/target/fake_trx/burst_gen.py
index ced2de3d..9141b674 100755
--- a/src/target/fake_trx/burst_gen.py
+++ b/src/target/fake_trx/burst_gen.py
@@ -46,10 +46,16 @@ class Application:
burst_type = None
burst_count = 1
- pwr = None
+
+ # Common header fields
fn = None
tn = None
+ # Message specific header fields
+ rssi = None
+ toa = None
+ pwr = None
+
def __init__(self):
self.print_copyright()
self.parse_argv()
@@ -95,7 +101,13 @@ class Application:
if self.pwr is not None:
msg.pwr = self.pwr
- # TODO: also set TRX2L1 specific fields
+ # Set time of arrival
+ if self.toa is not None:
+ msg.toa = self.toa
+
+ # Set RSSI
+ if self.rssi is not None:
+ msg.rssi = self.rssi
# Generate a random burst
if self.burst_type == "NB":
@@ -141,7 +153,9 @@ class Application:
" -c --burst-count How much bursts to send (default 1)\n" \
" -f --frame-number Set frame number (default random)\n" \
" -t --timeslot Set timeslot index (default random)\n" \
- " -l --power-level Set transmit level (default random)\n" \
+ " --pwr Set power level (default random)\n" \
+ " --rssi Set RSSI (default random)\n" \
+ " --toa Set TOA (default random)\n\n"
print(s % (self.remote_addr, self.base_port))
@@ -151,7 +165,7 @@ class Application:
def parse_argv(self):
try:
opts, args = getopt.getopt(sys.argv[1:],
- "m:r:p:b:c:f:t:l:h",
+ "m:r:p:b:c:f:t:h",
[
"help",
"conn-mode=",
@@ -161,7 +175,9 @@ class Application:
"burst-count=",
"frame-number=",
"timeslot=",
- "power-level=",
+ "rssi=",
+ "toa=",
+ "pwr=",
])
except getopt.GetoptError as err:
self.print_help("[!] " + str(err))
@@ -187,8 +203,14 @@ class Application:
self.fn = int(v)
elif o in ("-t", "--timeslot"):
self.tn = int(v)
- elif o in ("-l", "--power-level"):
- self.pwr = abs(int(v))
+
+ # Message specific header fields
+ elif o == "--pwr":
+ self.pwr = int(v)
+ elif o == "--rssi":
+ self.rssi = int(v)
+ elif o == "--toa":
+ self.toa = float(v)
def check_argv(self):
# Check connection mode