wiki:Using

Bluetooth Networking Configuration

Make sure the bluez4 package is installed

opkg install bluez4

The bluetooth script in /etc/init.d/ requires a small change: On line number 42 insert - before the *)

  restart)                                                    
        $0 stop                                               
        exec $0 start
        ;;

Then make sure bluetooth is started automatically

update-rc.d -s bluetooth start 5 .

(I think this can be fixed at source)

Configure the GN Bridge Add

# Bluetooth networking                         
iface pan1 inet static         
        address 192.168.9.1    
        netmask 255.255.255.0  
        network 192.168.9.0    

to /etc/network/interfaces. You can pick your own subnet etc.

And

In /etc/bluetooth/network.conf

[PANU Role]
Interface=bnep%d
[GN Role]
Interface=pan1

Pairing the devices.

Bluez 4 has a simple-agent python script (I think in the examples folder of the source)

#!/usr/bin/python

import gobject

import sys
import dbus
import dbus.service
import dbus.mainloop.glib

class Rejected(dbus.DBusException):
	_dbus_error_name = "org.bluez.Error.Rejected"

class Agent(dbus.service.Object):
	exit_on_release = True

	def set_exit_on_release(self, exit_on_release):
		self.exit_on_release = exit_on_release

	@dbus.service.method("org.bluez.Agent",
					in_signature="", out_signature="")
	def Release(self):
		print "Release"
		if self.exit_on_release:
			mainloop.quit()

	@dbus.service.method("org.bluez.Agent",
					in_signature="os", out_signature="")
	def Authorize(self, device, uuid):
		print "Authorize (%s, %s)" % (device, uuid)

	@dbus.service.method("org.bluez.Agent",
					in_signature="o", out_signature="s")
	def RequestPinCode(self, device):
		print "RequestPinCode (%s)" % (device)
		return raw_input("Enter PIN Code: ")

	@dbus.service.method("org.bluez.Agent",
					in_signature="o", out_signature="u")
	def RequestPasskey(self, device):
		print "RequestPasskey (%s)" % (device)
		passkey = raw_input("Enter passkey: ")
		return dbus.UInt32(passkey)

	@dbus.service.method("org.bluez.Agent",
					in_signature="ou", out_signature="")
	def DisplayPasskey(self, device, passkey):
		print "DisplayPasskey (%s, %d)" % (device, passkey)

	@dbus.service.method("org.bluez.Agent",
					in_signature="ou", out_signature="")
	def RequestConfirmation(self, device, passkey):
		print "RequestConfirmation (%s, %d)" % (device, passkey)
		confirm = raw_input("Confirm passkey (yes/no): ")
		if (confirm == "yes"):
			return
		raise Rejected("Passkey doesn't match")

	@dbus.service.method("org.bluez.Agent",
					in_signature="s", out_signature="")
	def ConfirmModeChange(self, mode):
		print "ConfirmModeChange (%s)" % (mode)

	@dbus.service.method("org.bluez.Agent",
					in_signature="", out_signature="")
	def Cancel(self):
		print "Cancel"

def create_device_reply(device):
	print "New device (%s)" % (device)
	mainloop.quit()

def create_device_error(error):
	print "Creating device failed: %s" % (error)
	mainloop.quit()

if __name__ == '__main__':
	dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)

	bus = dbus.SystemBus()
	manager = dbus.Interface(bus.get_object("org.bluez", "/"),
							"org.bluez.Manager")

	if len(sys.argv) > 1:
		path = manager.FindAdapter(sys.argv[1])
	else:
		path = manager.DefaultAdapter()

	adapter = dbus.Interface(bus.get_object("org.bluez", path),
							"org.bluez.Adapter")

	path = "/test/agent"
	agent = Agent(bus, path)

	mainloop = gobject.MainLoop()

	if len(sys.argv) > 2:
		if len(sys.argv) > 3:
			device = adapter.FindDevice(sys.argv[2])
			adapter.RemoveDevice(device)

		agent.set_exit_on_release(False)
		adapter.CreatePairedDevice(sys.argv[2], path, "DisplayYesNo",
					reply_handler=create_device_reply,
					error_handler=create_device_error)
	else:
		adapter.RegisterAgent(path, "DisplayYesNo")
		print "Agent registered"

	mainloop.run()

	#adapter.UnregisterAgent(path)
	#print "Agent unregistered"

If you run this script over an ssh terminal you should be able to enter the pin. Your laptop would probably have a more elegant way of prompting for the same pin ;).

While your at this over ssh you might as well pair any other bluetooth devices such as a headset etc.

You need the same agent to be running for subsequent connections to work. I added

        sleep 1                                               
        cd /home/root/bt; python simple-agent 2>&1 | logger &
        ifup pan1

to the bluetooth startup script, but please make sure your bluetooth is not discoverable by default. in /etc/bluetooth/main.conf

DiscoverableTimeout = 1
PairableTimeout = 1

Restart bluetooth

/etc/init.d/bluetooth restart

And from your computer - running bluez3 (you will also need to initiate pairing with the pand command).

sudo pand -n -c <bt-address-of-the-FR> 
sudo ifconfig bnep0 192.168.9.10