Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Finding A Bluetooth Device With Pybluez

DZone's Guide to

Finding A Bluetooth Device With Pybluez

·
Free Resource
Last time, I show how to use pys60 to discover
bluetooth devices. Here's another bluetooth
snippet, but this time it use pybluez (BT on Linux).

import bluetooth

target_name = "My Phone"
target_address = None

nearby_devices = bluetooth.discover_devices()

for bdaddr in nearby_devices:
    if target_name == bluetooth.lookup_name( bdaddr ):
        target_address = bdaddr
        break

if target_address is not None:
    print "found target bluetooth device with address ", target_address
else:
    print "could not find target bluetooth device nearby"

Taken from Albert Huang's exellent pybluez tutorial.
Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}