Setting up PPP to use the Bluetooth connection

The final phase is to set up PPP scripts and options to use the established connection. The scripts and options are set in two files which you will need to edit.

Step 1. Set up the chat script
Put this chat script in the file /etc/chatscripts/smart-3g (SMART being my cellphone service provider; you can use a different name.) The file location is referenced in the PPP options settings, given in step 2.

This simple four line script will dial up the connection to the Internet provider. You don't invoke this directly, but through the ppp startup command given in step 3.

"" ATZW2
OK AT&F
OK ATD*99***1#
CONNECT ""


Step 2. PPP options
Put this in /etc/ppp/peers/smart-3g. The filename itself is arbitrary, but it has to be in the /etc/ppp/peers directory.

connect '/usr/sbin/chat -v -f /etc/chatscripts/smart-3g'
ipparam smart-3g
/dev/rfcomm0
115200
crtscts
noccp
noipdefault
usepeerdns
ipcp-accept-remote
ipcp-accept-local
defaultroute
debug
noauth


For a full explanation of these options, read the descriptions in the /etc/ppp/options file.

Step 3. Fire up the PPP connection
Open a terminal session and initiate the connection with this command.

pon smart-3g

smart-3g is, of course, the name I gave the connection. Follow the filename that you used in step 2. You should see the connection fire up.

Be aware that you will be subject to connection charges. In my case, it's a relatively cheap P10 ($0.20) per thirty minutes.

Setting up Bluetooth Device for Communications

After you've configured the pairing between cellphone and Ubuntu, the next thing you need to do is set up the RF communications between the cellphone and the computer.

Step 1. What's the channel?
The cellphone's dial-up networking service listens at a particular channel. In my setup it's channel 1, but you'll want to be sure. To check what the channel is, run sdptool browse. A sample output is:

Inquiring ...
Browsing 00:17:B0:B4:52:C8 ...
Service Name: Dial-up networking
Service RecHandle: 0x10010
Service Class ID List:
"Dialup Networking" (0x1103)
"Generic Networking" (0x1201)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 1
Language Base Attr List:
code_ISO639: 0x656e
encoding: 0x6a
base_offset: 0x100
Profile Descriptor List:
"Dialup Networking" (0x1103)
Version: 0x0100


Note that in the Protocol Descriptor List, it specifies the channel 1.

Step 2. What's the device ID?
As in the previous stage, you can run hcitool scan to figure this out. My output is:

Scanning ...
00:17:B0:B4:52:C8 Nokia6233


Step 3. Configuring rfcomm.conf
Armed with the information above, you can now edit /etc/bluetooth/rfcomm.conf. Configure it with the following settings:

rfcomm0 {
bind yes;
device 00:17:B0:AF:E4:A9;
channel 1;
comment "nokia";
}


And you're done!


The next step will be to set up PPP to use this connection. 

Pairing the cellphone via Bluetooth in Ubuntu

Step-1: Load Bluetooth Drivers

You'll need to install Bluetooth utilities for Ubuntu.

To install the Bluetooth utilities,

sudo apt-get install bluez-utils
Step-2: Detect the phone

Now, try to detect the phone from Ubuntu.

First, turn on Bluetooth services on the cellphone. On a Nokia, follow the following sequence: Menu->Settings->Connectivity->Bluetooth. Turn on Bluetooth and make sure the the visibility is Shown to all.

Then, run hcitool scan. Sample output is:

Scanning ...
00:17:B0:B4:52:C8 Nokia6233


The six octet number (00:17:B0:B4:52:C8) is my cellphone's unique ID. Yours will be different.



Step-3: Change hcid.conf security option

You'll have to change the default Bluetooth configuration of Ubuntu, specifically the section pertaining to security. Ordinarily, you shouldn't need to go through this step if the security configuration was set properly. (I speak for the case of Edgy; this may change in future versions.)

Edit /etc/bluetooth/hcid.conf (you will need to go sudo for this). Change the line:

security user;

to

security auto;

and restart Bluetooth services by running sudo /etc/init.d/bluetooth restart.

By the way, hcid stands for Bluetooth Host Controller Interface demon. /etc/bluetooth/hcid.conf contains all the options needed by the daemon. It consists of sections and parameters for pairing, security, and others.


Step-4: Pair the phone
Finally, the pairing!

Go back to the Bluetooth menu of your cellphone and activate the pairing. On the Nokia 6233, the sequence is Menu->Settings->Connectivity->Bluetooth->Paired Devices. Click on New. The phone will then search for Devices, after which the hostname of your Ubuntu machine should appear.

Select Pair. You will be prompted for a passcode. The passcode number is as given in /etc/bluetooth/hcid.conf. The default is 1234.

You will have the option to let the computer connect automatically to the phone. Choose "Yes" if this will a more or less permanent connection; choose "No" if this is only temporary or if you want the security of confirmation.

And you're all set!