DNS

First and foremost, you'll need a DNS. If the phone cannot resolve the host and domain wsockhost.mrouter it will disconnect from the computer. If you already have a DNS server, then you simply have to make sure wsockhost.mrouter resolves to the IP address of the computer end of the PPP connection. In this HOWTO we'll use 169.254.1.68 because that's what the Windows software m-Router uses. It is perfectly possible to use another IPi, should you decide to do so.

If you don't have a DNS then I propose you use the DNSMasq server. It is small and requires very little configuration. It works by reading the /etc/hosts file. Hence, any entry you put in there will be resolved by dnsmasqd when required. Add the following two to your /etc/hosts and start dnsmasqd

169.254.1.68 wsockhost.mrouter
169.254.1.1  a925

If you lookup wsockhost.mrouter and a925 they should resolve the their respective IP addresses. You can change a925 to whatever you wish to call your phone.

Installing Bluetooth support

Next, you have to enable the Bluetooth subsystem in your kernel. You will find that under Device Drivers -> Networking support. Apart from the correct device driver (if you're unsure of which driver to use, then take a look at this chart) for your BT hardware, you will also need to enable the L2CAP protocol (CONFIG_BT_L2CAP) and the RFCOMM protocol (CONFIG_BT_RFCOMM).

Once that is done, compile and install the new kernel, and, if necessary, reboot.

Now, it's time to install the BlueZ Bluetooth stack. Either you find packages prebuilt for your distribution, or you can grab the source code from http://www.bluez.org. Install all the libraries and tools. Once installed, make sure the drivers you just compiled in the kernel are running (either you compiled them directly into your kernel, or you compiled them as modules, in which case you have to modprobe them before going any further).

Setting up Bluetooth

Hardware

You can see if Linux has detected your Bluetooth adapter by issuing the following commands

$ sudo /usr/sbin/hciconfig hci0 up
$ sudo /usr/sbin/hciconfig hci0

You should see something like:

hci0: Type: USB
      BD Address: DE:AD:BE:EF:00:00 ACL MTU: 192:8 SCO MTU: 64:8
      UP RUNNING PSCAN ISCAN
      RX bytes:273210 acl:3996 sco:0 events:8996 errors:0
      TX bytes:627753 acl:6776 sco:0 commands:2238 errors:0

If you are instead told Can't get device: No such file, that means the device driver for your Bluetooth controller isn't loaded.

hcid, the Bluetooth Host Controller Interface daemon

Open up /etc/bluetooth/hcid.conf with your favourite text editor and set the name variable in the device section to something imaginative. This is the name your computer will use to identify itself to other Bluetooth enabled devices.

Next up is fixing the PIN for pairing the phone with your computer. No matter what I did, I simply could not get the program bluepin to work. If it works for you, then that's great, but I found a solution on a webpage that was as silly as it was simple. Start by making a script with the following content:

#!/bin/sh
cat /etc/bluetooth/pin

Make it executable and put it somewhere in your path, for example /usr/bin/. Set pin_helper to run the script instead of bluepin in hcid.conf. Also make sure security is set to user.

Next, open up /etc/bluetooth/pin in a text editor and put the following in it:

PIN:1111

This will set the PIN of your computer to 1111. Feel free to change it at any time, but remember to keep the PIN:-part.

Now, we're just about set. Start hcid and make sure Bluetooth is enabled on your phone.

Pair your phone to your computer. Enter the PIN on the phone that you put in /etc/bluetooth/pin. The phone may say that the connection was unsuccessful, but will then add the computer anyway. This seems to be normal, since it works just as well for me.

sdpd, the Bluetooth Service Discovery Protocol daemon

Issue the command

$ sdptool browse

and wait for it to scan the proximity for other bluetooth devices. You should get something like this:

Inquiring ...
Browsing 12:34:56:78:90:AB ...
Service Name: Headset Gateway Service
Service Description: Headset Gateway Service
Service Provider: Symbian
Service RecHandle: 0x10002
Service Class ID List:
  "Headset Audio Gateway" (0x1112)
  "Generic Audio" (0x1203)
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 1
Language Base Attr List:
  code_ISO639: 0x656e
  encoding:    0x6a
  base_offset: 0x100
Profile Descriptor List:
  "Headset" (0x1108)
    Version: 0x0100
Service Name: Epoc32:BTListener
Service RecHandle: 0x10003
Service Class ID List:
  "OBEX Object Push" (0x1105)
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 2
  "OBEX" (0x0008)
Profile Descriptor List:
  "OBEX Object Push" (0x1105)
    Version: 0x0100

The Motorola A920/A925/A1000 uses PPP to connect to computers, regardless of whether it's through serial cable, USB cable, IR or BT. But before we start a listening PPP server on your computer, we need to start sdpd and create a Serial Port service. Do that by entering these commands:

sdpd
sdptool add SP

Make sure it's registered by running the following:

sdptool browse FF:FF:FF:00:00:00

This will ask your local sdp daemon what services it's offering. Look for:

Service Name: Serial Port
Service RecHandle: 0x804f4e0
Service Class ID List:
  "Serial Port" (0x1101)
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 1
Profile Descriptor List:
  "Serial Port" (0x1101)
    Version: 0x0100

dund, the Bluetooth Dial-Up Networking daemon

Now it's time to fire up dund and see what happens;

/usr/bin/dund --listen --channel 1 --msdun noauth 169.254.1.68:169.254.1.1 460800 ms-dns 169.254.1.68 lock --persist --nodetach

The nodetach option makes sure that dund grabs the prompt and outputs any errors directly to the shell.

Make sure your phone is set to connect to a computer via Bluetooth in the Control panel. Then, click the Desktop Suite icon, and finally Connect. This may take anywhere from 1 to 15 seconds. Any longer, and there is probably something wrong. Anyway, if things actually worked, you should see something like this on your computer:

dund[4452]: Bluetooth DUN daemon
dund[4471]: New connection from 12:34:56:78:90:AB
Using interface ppp0
Connect: ppp0 <--> /dev/rfcomm0
kernel does not support PPP filtering
Cannot determine ethernet address for proxy ARP
local IP address 169.254.1.68
remote IP address 169.254.1.1

You should now be able to ping your phone from your computer. If that works, you're in business. Congratulations. Your phone is now connected to your computer via Bluetooth.

Surfing the Web

If you wish to use the Internet from your phone through Bluetooth you can do that by any of the two methods described below:

It is, however, not possible to set the phone in Flight mode, as that will also disable the Bluetooth functionality.

If you're not running your own recursive nameserver, it is also a good idea to specify another nameserver when starting dund. Otherwise your phone won't find any domain names besides wsockhost.mrouter. Just add another ms-dns entry. Let's say it's 123.123.123.123;

/usr/bin/dund --listen --channel 1 --msdun noauth 169.254.1.68:169.254.1.1 460800 ms-dns 169.254.1.68 ms-dns 123.123.123.123 lock --persist --nodetach

Of course, you will also have to set up IP forwarding and masquerading, but that's not covered in this HOWTO. Check out section 4.1 in this HOWTO: http://www.netfilter.org/documentation/HOWTO/NAT-HOWTO-4.html#ss4.1. Keep in mind that ppp0 in that HOWTO refers to the Internet connection. Exchange it for the network device you have connected to the Internet.

Extras

I'm running Slackware 10, and here's my rc.bluetooth script.

Sources