Ensure Bluetooth address is retrieved properly
This commit is contained in:
7
btpl.py
7
btpl.py
@@ -16,8 +16,6 @@ enteredRange = "gnome-screensaver-command -d"
|
|||||||
maxMissed = 3
|
maxMissed = 3
|
||||||
# range at which PC is locked (0 - rangeLimit = RSSI)
|
# range at which PC is locked (0 - rangeLimit = RSSI)
|
||||||
rangeLimit = 7
|
rangeLimit = 7
|
||||||
# get Bluetooth address of target device
|
|
||||||
BTAddress = sys.argv[1]
|
|
||||||
# initiate variables for use when processing RSSIs
|
# initiate variables for use when processing RSSIs
|
||||||
status = "gone"
|
status = "gone"
|
||||||
awayCounter = maxMissed
|
awayCounter = maxMissed
|
||||||
@@ -29,7 +27,7 @@ firstRun = True
|
|||||||
def getRSSI():
|
def getRSSI():
|
||||||
# get output from terminal command that retrieves device name
|
# get output from terminal command that retrieves device name
|
||||||
try:
|
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:
|
except Exception as e:
|
||||||
rssi = str(e.output)
|
rssi = str(e.output)
|
||||||
|
|
||||||
@@ -46,6 +44,9 @@ if len(sys.argv) < 2:
|
|||||||
print("Usage: btpl.py <bluetooth address>")
|
print("Usage: btpl.py <bluetooth address>")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
# get Bluetooth address of target device
|
||||||
|
BTAddress = sys.argv[1]
|
||||||
|
|
||||||
# tell user the program is running
|
# tell user the program is running
|
||||||
print("Identifying device...")
|
print("Identifying device...")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user