Tuesday, May 6, 2008

GPRS Internet over Bluetooth on Debian

My Configuration

  • Debian 4.0 ( Etch )
  • Integrated Bluetooth on my laptops
  • Sony Ericsson P910i Cellphone
  • Vodacom GPRS/EDGE/3G connection

This should be portable across all Debian-based distibutions, and telecoms. But the configuration might vary from phone to phone (notably the channel number).

See GPRS for more general information.

Any "#" prompt means root, i.e. run sudo -s before you do this.

Install the relevent packages

# aptitude install bluez-gnome pppconfig

Permissions

Your user needs to be able to dial-out (if you are the first user on an ubuntu system, this is already done):

# adduser my-username-here dialout

Log out and in again.

Connect to your phone

Turn on bluetooth on your phone and computer.

If you've already tried connecting them before, delete any reference to your computer from your phone's list of Bluetooth devices. And delete any reference to your phone's ID from the files in /var/lib/bluetooth/computer-id-here/.

If the gnome bluetooth applet doesn't appear, run:

$ bluetooth-applet

It should make your computer discoverable by default.

Do a bluetooth scan on the phone, and add your computer as a paired device.

Enter the same number in both phone and computer. They should bond.

Now you can edit the properties of the computer on the phone's list of Bluetooth devices and tell it to always accept connections from the computer.

Debugging connections

If you need to find your phone's bluetooth ID, make the phone discoverable, and run

$ sdptool scan

If things go wrong here, go into /var/lib/bluetooth/*PC-Address*/ and look for your phone's address in those files. If it's there, remove it, and

# invoke-rc.d bluetooth restart

and try again.

If your phone isn't a P900

You'll need to find out what channel to connect to:

# sdptool browse 00:0A:D9:EA:A4:F8        <- Insert your phone's ID here
Browsing 00:0A:D9:EA:A4:F8 ...
Service Name: Voice gateway
Service Description: Voice gateway
Service Provider: Sony Ericsson
Service RecHandle: 0x10000
Service Class ID List:
"Headset Audio Gateway" (0x1112)
"Generic Audio" (0x1203)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 8
Language Base Attr List:
code_ISO639: 0x656e
encoding: 0x6a
base_offset: 0x100
Profile Descriptor List:
"Headset" (0x1108)
Version: 0x0100

Service Name: OBEX Object Push
Service RecHandle: 0x10001
Service Class ID List:
"OBEX Object Push" (0x1105)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 1
"OBEX" (0x0008)
Profile Descriptor List:
"OBEX Object Push" (0x1105)
Version: 0x0100

Service Name: OBEX File Transfer
Service RecHandle: 0x10002
Service Class ID List:
"OBEX File Transfer" (0x1106)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 2
"OBEX" (0x0008)

Service Name: Bluetooth Serial Port
Service Description: Bluetooth Serial Port
Service Provider: Symbian Ltd.
Service RecHandle: 0x10003
Service Class ID List:
"Serial Port" (0x1101)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 3
Language Base Attr List:
code_ISO639: 0x656e
encoding: 0x6a
base_offset: 0x100

Service Name: Dial-up Networking
Service Description: Dial-up Networking
Service Provider: Sony Ericsson
Service RecHandle: 0x10004
Service Class ID List:
"Dialup Networking" (0x1103)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 4
Language Base Attr List:
code_ISO639: 0x656e
encoding: 0x6a
base_offset: 0x100
Profile Descriptor List:
"Dialup Networking" (0x1103)
Version: 0x0100

The number you want is the Channel number for Dial-up Networking.

Configure bluez

# vi /etc/bluetooth/rfcomm.conf

Add this stanza at the end:

rfcomm0 {
bind yes;
device 00:0A:D9:EA:A4:F8; <- Insert your phone's ID here
channel 4;
comment "P900 PPP connection";
}
# /etc/init.d/bluez-utils restart

Configure PPP

# cat > /etc/ppp/peers/bluetooth << EOF
hide-password
noauth
connect "/usr/sbin/chat -v -f /etc/chatscripts/bluetooth"
debug
/dev/rfcomm0
115200
defaultroute
noipdefault
user "x"
remotename bluetooth
ipparam bluetooth

usepeerdns
lcp-echo-interval 0
novj
EOF
# cat > /etc/chatscripts/bluetooth << EOF
ABORT BUSY ABORT 'NO CARRIER' ABORT VOICE ABORT 'NO DIALTONE' ABORT 'NO DIAL TONE' ABORT 'NO ANSWER' ABORT DELAYED
ATZ
OK-AT-OK "ATDT*99***1#"
CONNECT \d\c
EOF

You might need to change the *99***1#. See GPRS#Cell Phone for details.

# echo '"x" bluetooth "x"' >> /etc/ppp/pap-secrets

Test and debug

$ pon bluetooth
# tail -f /var/log/syslog

You should see the connection progress.

Enjoy.

BTW: You can make your phone undiscoverable again :-)

Troubleshooting

  1. The above instructions can easily be adapted for USB cable use. The earlier bluetooth specific steps can be skipped, start at the ppp configuration step. The device specified must be the USB appropriate modem device, eg. /dev/ttyACM0. If you are unsure of what device to use, monitor the log files (eg. /var/log/syslog) to see what device is detected when the phone is plugged via USB.
    • The main disadvantage to using bluetooth is it increases the battery consumption of the phone. The advantage to using bluetooth is that you can put the phone in a further away location where it gets a better cellphone signal.
  1. The dial number specified is critical, if by mistake, you use your MMS connection, it will appear to connect fine, but nothing will work :-)
  1. If for some silly reason, you already have a default route, ppp will not replace it with a new one. You'll have to sort this out yourself.

No comments: