1#Simple bluetooth connect
2import bluetooth
3
4target_name = "My Phone"
5target_address = None
6
7nearby_devices = bluetooth.discover_devices()
8
9for bdaddr in nearby_devices:
10 if target_name == bluetooth.lookup_name( bdaddr ):
11 target_address = bdaddr
12 break
13
14if target_address is not None:
15 print("found target bluetooth device with address "), target_address
16else:
17 print("could not find target bluetooth device nearby")