From 6e956dac92b726520710b4eb66830bd43bacc3b2 Mon Sep 17 00:00:00 2001 From: Matthew Grove Date: Fri, 5 Apr 2019 07:38:49 +0100 Subject: [PATCH] Ensure Bluetooth address is retrieved properly --- btpl.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/btpl.py b/btpl.py index ad672aa..ade3e9f 100644 --- a/btpl.py +++ b/btpl.py @@ -16,8 +16,6 @@ enteredRange = "gnome-screensaver-command -d" maxMissed = 3 # range at which PC is locked (0 - rangeLimit = RSSI) rangeLimit = 7 -# get Bluetooth address of target device -BTAddress = sys.argv[1] # initiate variables for use when processing RSSIs status = "gone" awayCounter = maxMissed @@ -29,7 +27,7 @@ firstRun = True def getRSSI(): # get output from terminal command that retrieves device name try: - rssi = subprocess.check_output('hcitool rssi [bluetooth address]', shell=True, stderr=subprocess.DEVNULL) + rssi = subprocess.check_output("hcitool rssi " + BTAddress, shell=True, stderr=subprocess.DEVNULL) except Exception as e: rssi = str(e.output) @@ -46,6 +44,9 @@ if len(sys.argv) < 2: print("Usage: btpl.py ") sys.exit(1) +# get Bluetooth address of target device +BTAddress = sys.argv[1] + # tell user the program is running print("Identifying device...")