Setting up Bluetooth communication with a NXT Brick under Fedora linux
it is vital that the following python packages are installed:
- NXT Python
- PyBlueZ for Bluetooth communication
to test PyBlueZ, the following can be used (code by Albert Huang <albert@csail.mit.edu>)
#!/usr/bin/env python
import bluetooth
print "performing inquiry..."
nearby_devices = bluetooth.discover_devices(lookup_names = True)
print "found %d devices" % len(nearby_devices)
for name, addr in nearby_devices:
print " %s - %s" % (addr, name)
as I do not care for gnome, my default desktop is KDE,
what follows is my procedure for pairing with a NXT Brick.
[root@motoko]# /usr/bin/bluetooth-applet &
a Bluetooth icon will appear in your system tray,
right-click the Bluetooth icon and click “Preferences” from the popup.
- set the radio button under “Mode of operation” to be “Visible and connectable for other devices”
(even if it ought to be “connectible”) - click “Close”
on the NXT Brick, from the root menu,
- select “Bluetooth” and press the square button.
- select “Search” and press the square button.
- after it has finished searching, select the name that matches your computer and press the square button.
- select “[1]” and press the square button.
- wait for it to connect.
- enter passkey, or press the square button for the “1234″ default.
- Bluetooth icon will begin to blink, click it and enter the passkey in the resulting dialog.
- right-click the Bluetooth icon and click “Preferences” from the popup.
- select the NXT Brick in the “Bonded devices” box.
- Click “Set Trusted”
- click “Close”
the connection can now be tested with the following python code:
#!/usr/bin/env python import nxt.locator sock = nxt.locator.find_one_brick() if sock: brick = sock.connect() name, host, signal_strength, user_flash = brick.get_device_info() print 'NXT brick name: %s' % name print 'Host address: %s' % host print 'Bluetooth signal strength: %s' % signal_strength print 'Free user flash: %s' % user_flash sock.close()