Use Your Mobile as a Bluetooth Modem in Linux

As there is no pc-suite or something as yet for linux, it may appear difficult to connect your mobile via bluetooth and to the internet as well. But as I found out recently it is really simple. I am able to connect my Nokia N70 via bluetooth in Ubuntu linux. And now, I can surf the internet from linux through GPRS. I think it will work with all bluetooth enabled mobile with a working gprs connection.

First get bluez-gnome installed if you don't have already.

$ sudo apt-get install bluez-gnome

Now on your phone open Bluetooth and select the 'Paired devices' tab (by pressing the right button). Under 'options' select 'New paired device'. It will find your computer. Select your computer-name. This will prompt for passcode. Give same passcode for this and when will be asked by the computer later. You can select yes to 'Authorise device to make connections automatically?', so that you will not be asked each time you try to connect it.

Now you have find out your mobile's bluetooth address. Enter the following command

$ hcitool scan

This should show you something like this

Scanning ...
XX:XX:XX:XX:XX:XX N70

The xx:xx:xx:xx:xx:xx is the bluetooth address. Now run the command

$ sdptool browse xx:xx:xx:xx:xx:xx

There will be a section like this

Service Name: Dial-Up Networking
Service RecHandle: 0x1000f
Service Class ID List:
"Dialup Networking" (0x1103)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 3
Language Base Attr List:
code_ISO639: 0x454e
encoding: 0x6a
base_offset: 0x100
Profile Descriptor List:
"Dialup Networking" (0x1103)
Version: 0x0100

Note the Channel number. It may be different.


Now, modify the file '/etc/bluetooth/rfcomm.conf'

$ sudo gedit $home/etc/bluetooth/rfcomm.conf

so that it looks like the one below

rfcomm0 {
# # Automatically bind the device at startup
bind yes;
#
# # Bluetooth address of the device
device xx:xx:xx:xx:xx:xx;
#
# # RFCOMM channel for the connection
channel 3;
#
# # Description of the connection
comment "Nokia N70";
}

Check if you can connect your mobile

$ rfcomm release 0
$ rfcomm connect 0

You should see

Press CTRL-C for hangup

Now you have to create these ppp scripts. The code should be changed in some places according to your operator. Possible parts of the code that should be changed are written in bold.

/etc/ppp/peers/bsnl

# from samiksblog.blogspot.com
noauth
#change this if you move the path to your connect script
connect "/usr/sbin/chat -v -f /etc/chatscripts/bsnl-connect"
#change this if you move the path to your disconnect script
disconnect "/usr/sbin/chat -v -f /etc/chatscripts/bsnl-disconnect"
#I found that I needed this to remove problems with loopback on connecting
silent
#remove this if you don't want lots of information going to /var/log/messages
debug
#this is the device specified in your rfcomm.conf file
/dev/rfcomm0
#speed at which to connect - might be worth trying higher...
115200
#this is needed so that a default route is added to your routing table
defaultroute
#this is needed so that you pick up Orange's DNS settings
usepeerdns

/etc/chatscripts/bsnl-connect

#from www.hingston.demon.co.uk/mike/nokia6680.html
TIMEOUT 5
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 12

OK ATE1
#here's the magic bit!
OK 'AT+CGDCONT=1,"IP","celloneportal"'
OK ATD*99***1#

** celloneportal is the access point name. You must replace it with your service provider's access point.

/etc/chatscripts/bsnl-disconnect

# from www.hingston.demon.co.uk/mike/nokia6680.html
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"

Now you are ready to connect. To connect run the following

$ pon bsnl

And to disconnect

$ poff bsnl

Comments

  1. hi....you have given a lot of useful information here by spending your valuable time i have just installed red hat enterprise linux 3 on my pc i want to connect to internet by mobile in linux.. i have nokia 6681 handset i have both data cable and bluetooth.. i started installing the bluez-gnome acc to ur instructions but when i followed the first step
    $ sudo apt-get install bluez-gnome
    my pc gave errors and i could not move to next steps will u plzz halp me ...thax
    ipsharry@gmail.com

    ReplyDelete
  2. does bluez-gnome has been include in Ubuntu 8.04 package?

    ReplyDelete
  3. yes, bluez-gnome is included in ubuntu 8.04

    ReplyDelete
  4. i've follow your step, and finally when i run the command:
    $ pon bsnl
    the bluetooth icon on my phone (Samsung J200) blink red and blue (it's working on connection), but...

    - is there any DIALOGUE when the pon bsnl being executed?
    'cause there's no any messages appear on my terminal, and i can't still connect to the internet :-(

    - is there NETWORK MONITOR ICON on the taskbar when the connection run?

    ReplyDelete
  5. When you execute 'pon bsnl' there will NOT be any message or dialog box. Also, the network monitor icon will NOT be ON. Still you should be able to browse the web.
    See the GPRS icon on your phone to make sure you are connected. Also, you may have to set some proxies in your browser depending on your service provider.

    ReplyDelete
  6. Samik, thank you very much..
    now my GPRS connection is RUNNING well, although more slowly than running on W****S :-)

    Alhamdulilllah...

    ReplyDelete
  7. Very usefully info, after struggling for more than 4-5 hrs manage to get connected .

    ReplyDelete
  8. hai..........

    I had got lot many information in your blog i will definitely try to modify with your existing with your new ideas.

    In the mid of my searching journey i had visited lot many sites.I had got a lot of information in this site also.


    http://www.adminkernel.com/networking-concepts/

    ReplyDelete
  9. A little confused when you say:

    Check if you can connect your mobile

    rfcomm release 0
    rfcomm connect 0

    Are these typed into terminal? If so, I get "no such device"

    What am I doing wrong?

    Thank you for clear instructions up to here

    ReplyDelete
  10. Sorry for the confusion. Yes, those commands are typed into terminal.

    It is okay if you get "no such device" when you type the first command. It is only to make sure the device not already connected.

    ReplyDelete
  11. Thanks a lot mate!!!!!!!!!!

    ReplyDelete

Post a Comment

Popular posts from this blog

Power On Your Computer by Keyboard, Mouse or Alarm

Comet Lulin Comes Closer

Into the World of Computer Gaming