Bluetooth Low Energy Scans

From packets2photons
Jump to navigation Jump to search

The following python3 code will show how you can use the Linux command line to scan for Bluetooth LE devices.


import os

#r+ because the file is already there, w without the file
myfile = open("scan.txt", "r+")

os.system("hciconfig hci0 down")
os.system("hciconfig hci0 up")

os.system("timeout -s SIGINT 5s hcitool -i hci0 lescan > scan.txt")
scan = open("scan.txt","r")
readscan =
if "C3:6A:89:53:31:ED" in readscan:
    print("In office")
    print("Not in office")