Ubuntu Hardy Heron: Nokia N95 as 3G modem

I posted this article two years ago in ubuntu.sg website. Sadly, the site has since been taken down. However, I believe this article still has some value as Ubuntu Hardy 8.04 has not reached end-of-line yet. Therefore, I am reposting the article here.

Background

There are two ways of using a telecom’s 3G mobile network to access the internet.

First, you can subscribe to a separate mobile plan, which gives you an extra SIM card and a 3G modem (usually a USB dongle, but sometimes a 3G modem router). The advantage of this method is you are not tied to your existing mobile phone line. Using your phone as a 3G modem will drain your phone battery pretty fast. Furthermore, USB modem should be faster than Bluetooth modem. For instance, if you subscribed to a 2Mbps data plan, you are probably able to utilize up to this speed.

The second method is to use your existing 3G phone as a modem. You connects the PC to the phone via Bluetooth. The advantage is you don’t have to subscribe to a separate mobile plan. Instead, you add a data subscription on top of your existing voice plan, which should be cheaper overall. The drawback is your phone might run out of battery and then you would loose your voice calls as well. Also, Bluetooth modem speed is about 400kbps maximum, so you will not get the full data speed you subscribed to.

This article explains how to connect to the internet using the second method.

Prerequisite

  1. PC or laptop with Ubuntu Hardy Heron 8.04 fully updated
  2. Any USB bluetooth device known to work with Ubuntu
  3. Nokia N95 8GB
  4. Singtel Broadband on Mobile data plan

The instructions below were tested using latest Ubuntu Hardy, fully updated. It would probably work with older versions as well, but you might faced problem with Bluetooth connectivity.

This will only work with “Singtel Broadband on Mobile” plan. I have previously tried the same set-up with a borrowed Starhub MaxMobile plan, and found there were some differences to get it working. Unfortunately, I have not pursue the Starhub set-up in detail (since it was borrowed from a friend) and cannot comment further on the differences.

I am using a Nokia N95 8GB phone. Based on various instructions/howtos in the internet, many Nokia phones and possibly other brands should work as well. However, I do not have any other hardware to test this. If you are successful in using this instructions on other phone models, please post a comment to tell us about it.

Step 1: Bluetooth pairing of phone to PC

I wrote about this process here.

Once the pairing is completed, keep the phone’s Bluetooth in visible mode for the remaining steps below. Only after the internet access is confirmed to be working should you turn the phone’s Bluetooth to hidden mode.

Step 2: Scan for the Bluetooth serial modem channel

In your Ubuntu PC, open a terminal window and run this command:

hcitool scan

It will take a few seconds to scan, and reply with something like this:

00:11:22:33:44:55	N95

The first part is the Bluetooth’s MAC address; note this down.

Next, run this command, but using the MAC address you got previously:

sdptool browse 00:11:22:33:44:55 | grep -A 10 Dial-Up | \
grep Channel

It will reply with something like this:

Channel: 2

This is the Bluetooth channel for the dial-up networking, i.e. the serial modem channel. Note this down as well.

Step 3: Enable Bluetooth serial modem channel

Edit the file /etc/bluetooth/rfcomm.conf with root privilege:

gksudo gedit /etc/bluetooth/rfcomm.conf

Add these lines to the bottom of the file, but using the MAC address and the channel you got previously:

rfcomm0 {
	# Automatically bind the device at startup
	bind yes;

	# Bluetooth address of the device
	device 00:11:22:33:44:55;

	# RFCOMM channel for the connection
	channel	2;

	# Description of the connection
	comment "Nokia N95";
}

Save and close the file.

Restart the Bluetooth stack:

sudo /etc/init.d/bluetooth restart

Step 4: Configure wvdial

Wvdial is the command line dial-up program (installed by default). You can use this only, but if you prefer a GUI, refer to the next section. In any case, it is advisable to test out the connection using wvdial first, since it will give you useful error messages if the connection failed.

Edit /etc/evdial.conf with root privilege:

gksudo gedit /etc/wvdial.conf

Change the file to these lines:

[Dialer Defaults]
Init1=ATZ
Init2=ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Init3=AT+CGDCONT=1,"IP","internet","",0,0
modem=/dev/rfcomm0
Baud=460800
Modem Type=Analog Modem
ISDN=0
Phone = *99#
Username = user
Password = passwd
New PPPD = yes

Note the “user” and “passwd” are entered as they are. Singtel don’t require username or password at all; these are just placeholders. Save and close the file.

Step 5: Dial-up using wvdial

Disconnect you PC from other internet connections you may have.

Now, run wvdial and it will make the internet connection:

wvdial

You should see “Connected” message at end of it. Open a second terminal window and run this command:

ifconfig

You should see a new “ppp” device with a valid IP address.

Open the Firefox browser. By default, the dial-up connection by wvdial would not be known to the Ubuntu network manager and the browser will start in offline mode. Open “File” menu and un-check “Work Offline”. Then, surf to a website. If everything is OK, you should get a valid webpage. Success!

Step 6: Install Gnome-PPP

If you prefer GUI when connecting, a good application is Gnome-PPP. Install it using Synaptic Package Manager, or run this command:

sudo apt-get install gnome-ppp

Step 7: Configure Gnome-PPP

Once installed, you should see new icon for Gnome-PPP under the “Application > Internet” menu.

The Gnome-PPP main window looks like this:

Gnome PPP

Even though Singtel does not require a username and password, you still need to enter something into the fields in the main window and check “Remember password”. Due to a bug, Gnome-PPP would not work properly if you leave these fields blank. Enter “*99#” as the phone number.

Next, click “Setup”. Change the settings to exactly as shown:

Gnome PPP setup

Next, click “Init Strings…” Add the “Init 3″ string exactly as shown:

Gnome PPP init strings

Or, copy/paste this string here (to avoid typo error):

AT+CGDCONT=1,"IP","internet","",0,0

Close both dialogboxes to get back to the main window.

Step 8: Dial-up using Gnome-PPP

Click “Connect”. It will take a few seconds, then you should get a “Connected” message. If it doesn’t work, click “Log”, and check for any error message. Else, you can run “ifconfig” again to see if you got a “ppp” device and a valid IP address.

Troubleshooting

A common problem is the Bluetooth serial modem channel can some time change. If it did, you could repeat the steps above to find the channel and make appropriate changes. Or, you could do what I did, described below.

Add multiple rfcomm entries to /etc/bluetooth/rfcomm.conf, like this:

rfcomm2 {
	# Automatically bind the device at startup
	bind yes;

	# Bluetooth address of the device
	device 00:11:22:33:44:55;

	# RFCOMM channel for the connection
	channel	2;

	# Description of the connection
	comment "Nokia N95";
}

rfcomm4 {
	# Automatically bind the device at startup
	bind yes;

	# Bluetooth address of the device
	device 00:11:22:33:44:55;

	# RFCOMM channel for the connection
	channel	4;

	# Description of the connection
	comment "Nokia N95";
}

Here, the file has two entries, rfcomm2 for channel 2 and rfcomm4 for channel 4. Don’t forget to restart the Bluetooth stack every time you make a change to /etc/bluetooth/rfcomm.conf.

Next, create a bash script “scan-bt-channel.sh” to scan for the channel (this will help you avoid entering the same lengthy command every time, which gets old after a while):

#!/bin/bash

DUNCH=\`sdptool browse 00:11:22:33:44:55 | \
grep -A 10 Dial-Up | grep Channel`
echo $DUNCH
notify-send -t 5000 "Bluetooth Dial-Up Networking"\
"$DUNCH"
EOF

Make the script file executable:

chmod +x scan-bt-channel.sh

Install “libnotify-bin” (required for the script to show a pop-up balloon message):

sudo apt-get install libnotify-bin

Now, simply run this script first. It will inform you about the current Bluetooth serial modem channel. Then, before you click “Connect” in Gnome-PPP, change the “Setup > Device” field to the correct rfcomm.

Post a Comment

Your email is never published nor shared. Required fields are marked *