Establishing a GPRS connection to the internet using a bluetooth cellphone

This document contains some details I found out while setting up a GPRS internet connection on my laptop. The following hardware is being used:

Software is Debian GNU/Linux 4.0 (testing at the time of this writing), Linux kernel 2.6.17 and BlueZ bluetooth stack. Unfortunately the kernel had to be patched to make the Socket card work.

First check that your bluetooth adapter has been setup correctly. If it is, the following command should tell you its bluetooth MAC address:

> hcitool dev
Devices:
        hci0    00:02:34:56:AF:FE
>

Now make sure that bluetooth is enabled on your mobile phone, and that it's configured to be visible to other bluetooth devices. Then let your linux box search for DUN capable devices:

> sdptool search DUN
Inquiring ...
Searching for DUN on 00:B0:07:66:B7:AD ...
Service Name: Dial-up Networking
Service RecHandle: 0x10000
Service Class ID List:
  "Dialup Networking" (0x1103)
  "Generic Networking" (0x1201)
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 1
Profile Descriptor List:
  "Dialup Networking" (0x1103)
    Version: 0x0100

>

The line set in bold shows the RFCOMM channel number that your particular cellphone uses for DUN connections. With this knowledge you can bind an RFCOMM device node to your phone:

rfcomm bind <rfcomm-device-number> <remote-bdaddr> <DUN-RFCOMMchannel>
Example:  rfcomm bind 0 00:B0:07:66:B7:AD 1

This command does not actually create the bluetooth connection, it only binds a tty device /dev/rfcomm<n> to your phone's DUN profile. The connection is going to be opened as soon as an application opens that device node (you could test it using minicom if you like: type "ATD<some-phone-number>", press Enter and the mobile phone should dial the number you gave). In case the computer and phone are not yet paired, the phone asks for a PIN code upon first connection attempt -- please refer to BlueZ documentation on how to pair bluetooth devices.

The last configuration step is to setup the PPP daemon pppd. I use the following files:

/etc/ppp/peers/gprs:

/dev/rfcomm0
connect '/usr/sbin/chat -v -f /etc/chatscripts/gprs'
noauth
defaultroute
usepeerdns
connect-delay 2000           # might be necessary for T610 only
noipdefault
lcp-echo-interval 0          # might be necessary for T610 only

/etc/chatscripts/gprs:

TIMEOUT         5
ABORT           '\nBUSY\r'
ABORT           '\nERROR\r'
ABORT           '\nNO ANSWER\r'
ABORT           '\nNO CARRIER\r'
ABORT           '\nNO DIALTONE\r'
ABORT           '\nRINGING\r\n\r\nRINGING\r'
''              \rAT
# necessary if you didn't configure a GPRS internet account in your phone (example only, must edit!):
#OK             AT+CGQREQ=1,2,4,3,9,31
#OK             AT+CGDCONT=1,"IP","internet.eplus.de"
TIMEOUT         12
# in the following line, the "1" means to use the pre-configured GPRS account with CID=1
OK              ATD*99***1#

Finally, you can establish the internet connection simply by running:

pppd call gprs

If installed, you can also use pon gprs / poff gprs to establish / terminate the GPRS connection. Those commands can also be called by non-root users as long as they're members of the dip group.

Once everything works, the rfcomm call described above can be omitted by configuring the BlueZ utils to automatically bind the rfcomm device on system startup. Add the following lines to /etc/bluetooth/rfcomm.conf (example):

rfcomm0 {
        bind yes;
        device 00:B0:07:66:B7:AD;
        channel 1;
        comment "DUN-T610";
}

References