Showing posts with label python bluetooth. Show all posts
Showing posts with label python bluetooth. Show all posts

Tuesday, November 29, 2011

Scan for bluetooth devices using python

scan for bluetooth devices using a python script. the below script can be used for performing the same. remember , you will have to install pybluez module (it is available for both windows and linux). now for the script , here you go!

import bluetooth

print "performing inquiry..."

nearby_devices = bluetooth.discover_devices(lookup_names = True)

print "found %d devices" % len(nearby_devices)

for addr, name in nearby_devices:
print " %s - %s" % (addr, name)


this will print the number of devices , address and name . this can be used as test script for a variety for reasons .

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!

Wednesday, July 13, 2011

pybluez - bluetooth

For all who have been using python or who wanted to use python,
we can access RFCOMM profile via pybluez.
pybluez is the software supplied at code.google.com is a python wraper for bluetooth testing.
for now all the profiles are not supported ( read bluetooth related books/ postings for you to understand what profiles mean) . it supports only RFCOMM and L2CAP.
you can download it from the below.

http://code.google.com/p/pybluez