PyBluez's first and most basic example is "examples/simple/inquiry.py", which is described as "Detecting nearby Bluetooth devices". This is exactly what I'd like to do - detect and list nearby Bluetooth devices.
However when I run the example code:
import bluetooth
print("performing inquiry...")
nearby_devices = bluetooth.discover_devices(
duration=8, lookup_names=True, flush_cache=True, lookup_class=False)
print("found %d devices" % len(nearby_devices))
for addr, name in nearby_devices:
try:
print(" %s - %s" % (addr, name))
except UnicodeEncodeError:
print(" %s - %s" % (addr, name.encode('utf-8', 'replace')))
I notice that
- My phone's Bluetooth network is not detected even though the phone is about 4cm from the laptop which is running this script.
- The 4 Bluetooth devices listed are the 4 which are known/paired with my OS, even though none of them are within 10 miles of me at the moment.
So, I'm wondering why it's doing this and how to make it actually scan/list nearby devices?
I'm on Windows 7 and Python 3.5