I've been trying to figure out how I can use pybluez to monitor nearby devices...
I want to be able to run my program and have it search for devices every 20 seconds. The problem is, how do I get pybluez to place nicely? :/
Using their example code http://code.google.com/p/pybluez/source/browse/trunk/examples/simple/inquiry.py, it's easy enough to get it to discover devices. You run that code and it'll spit out MAC address and, if you choose, the device names.
How can I put this in a loop? I've been playing around with the following code but it's failing >.<
import bluetooth
def search():
while True:
devices = bluetooth.discover_devices(lookup_names = True)
yield devices
for addr, name in search():
print "{0} - {1}".format(addr, name)