Internet via cellphone over Bluetooth

Up to now I only used my Elisa 3G connection with the N810. That works quite well, but sometimes using 3G from my laptop would still be useful. Fortunately it was easy to setup. Assuming you already paired your phone with your laptop via bluetooth, you only need a configuration files, two scripts files and pppd to go online. First you need a ppp config file :

/dev/bluetooth/rfcomm/1 # rfcomm device connect '/usr/sbin/chat -v -f /etc/chatscripts/three-connect' disconnect '/usr/sbin/chat -v -f /etc/chatscripts/three-disconnect' defaultroute # Setup gateway stuff when connected. noipdefault # ask your 3G provider for IP addresses usedns # ask your 3G provider for nameserver addresses noauth # do not request peer authentication nopcomp # disable compression 230400

Save this as /etc/ppp/peers/three

You also need 2 chat scripts to connect to the 3G network and disconnect from the 3G network.

TIMEOUT        10 ECHO           ON  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 TIMEOUT        15 OK             ATE1 OK             'AT+cgdcont=1,"IP","APN"' OK             ATD*99# CONNECT

Replace APN by your 3G providers APN (See http://www.taniwha.org.uk/gprs.html for a list of APNs). Then save this as /etc/chatscripts/three-connect.

ABORT          "BUSY" ABORT          "ERROR" ABORT          "NO DIALTONE" SAY            "\nSending break to the modem\n" ""             "\K" ""             "\K" ""             "\K" ""             "+++ATH" ""             "+++ATH" ""             "+++ATH" SAY            "\nPDP context detached\n"

Save this as /etc/chatscripts/three-disconnect.

Now you need to find out 2 things from your phone : it's bluetooth mac address and the channel used for dialup connectivity. The bluetooth mac can be found easily by doing :

PHONE_MAC=$(hcitool scan | grep 'your phones name' | awk '{print $1}')

Executing :

DUN_CHANNEL=$(sdptool search --bdaddr $PHONE_MAC DUN | grep Channel | awk '{print $2}')

will give you the dialup networking channel.

Now the following commands should setup your 3G connection :

rfcomm bind 1 $PHONE_MAC $DUN_CHANNEL pon three

To stop your 3G connection do :

poff three rfcomm release 1

Scripting this is left as an exercise for the reader. It's adviseable to put the values of $PHONE_MAC and $DUN_CHANNEL in the script rather then scanning for them everytime you want to setup the connection. The scan can be quite slow if there are a lot of devices visible. Obviously you need to update them when you change phones.