Thursday, November 3, 2011

pybluez bluetooth inquiry

In my yesterday's blog i was talking about pyserial module . today's post i wanted to share a test code for pybluez module which is a python wrapper around the Bluetooth stack. in this sample code below , we will perform a inquiry of all the Bluetooth devices nearby and list them.

from bluetooth import *
print "performing inquiry..."
nearby_devices = discover_devices(lookup_names = True)
print "found %d devices" % len(nearby_devices)
for name, addr in nearby_devices:
print " %s - %s" % (addr, name)


don't forget to download the pybluez module before you try this. this will be an important step.
you will end up getting errors that the bluetooth module is not available if you try to run the program as is.

happy testing!

No comments:

Post a Comment