I'm working on a Python script to control my Mindstorms NXT with a Raspberry Pi. My problem is, that the NXT has a Bluetooth passkey. You can change the passkey but not delete it.
I want to know how you can connect the PyBluez socket to a device with a passkey.
This is the current program:
import bluetooth
import socket
target_name = "Jerry"
target_address = None
print "performing inquiry..."
nearby_devices = bluetooth.discover_devices()
print "found %d devices" % len(nearby_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"
bluesock= socket.socket(socket.AF_BLUETOOTH, socket.SOCK_STREAM, socket.BTPROTO_RFCOMM)
bluesock.connect((target_address, 1))