Ubuntu Linux - Bluetooth and GPRS dialup connection

chris (2007-01-18 00:42:48)
91206 views
22 replies
This article explains how to set up a bluetooth connection between your ubuntu laptop and phone and get PPP working with BT's mobile service in the UK. It probably isn't so hard to repeat this for other network providers. I'm sure that if you do a Yahoo search for the GPRS settings of your mobile telco, you'll be up and runnin with little more than a few mintues of poking around.

First you need to install the bluetooth packages on your linux machine:
$sudo apt-get install bluez-utils
$sudo apt-get install blues-pin

Now you need to make sure you have the ppp package installed

$sudo apt-get install ppp


At this point you already have enough software on your machine to do a scan of the local area and see what devices are available. this is done using hcitool. When I run this command, the output looks like this:
$chris@snackerjack-lx:~$ hcitool scan
Scanning ...
        00:07:3A:08:EE:74       n/a
        00:18:13:50:0C:EB       Christo Yahoo!
chris@snackerjack-lx:~$

That means that my laptop can see my phone - it's reporting the MAC address and the device name.

For more information on hcitool, you can run 'man hcitool'. Basically hcitool is a handy bluetooth utility which allows you to scan for and query local bluetooth devices. At this stage you can use hcitool to pair your bluetooth-enabled laptop with your phone. Use the following commands to achieve this:
$sudo hcitool cc 00:18:13:50:0C:EB

Note, you should use the MAC address of your own phone in this command - as reported by the hcitool scan command earlier. This creates a baseband connection to your phone. The next step is:
$sudo hcitool auth 00:18:13:50:0C:EB

This will request authentication with your phone - this is known as 'pairing' and will allow your computer to communicate with your bluetooth phone. Note again, you should replace the mac address with that of your phone. Don't use mine!


The next stage is to use the Service Discovery Protocol to ask your device what bluetooth services it is offering. At this point, if you're feeling really curious, you could re-run your hcitool scan and then run an SDP discovery search on all the listed devices. You never know - it might be interesting. However, this article is about setting up a Dial-up connection through your phone, so let's keep focussed.. The command you need to issue looks like this:
$sdptool browse 00:18:13:50:0C:EB

Again, use your own phone's MAC address - This will list all sorts of bluetooth services that your phone offers. This is what the output looks like when I run this command against my own phone.. I know it's a lot to paste, but it's worth seeing the kind of services which might be on offer:
chris@snackerjack-lx:~$ sdptool browse 00:18:13:50:0C:EB
Browsing 00:18:13:50:0C:EB ...
Service Description: Sony Ericsson K750
Service RecHandle: 0x10000
Service Class ID List:
  "PnP Information" (0x1200)

Service Name: Dial-up Networking
Service RecHandle: 0x10001
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

Service Name: Serial Port
Service RecHandle: 0x10002
Service Class ID List:
  "Serial Port" (0x1101)
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 2

Service Name: HF Voice Gateway
Service RecHandle: 0x10003
Service Class ID List:
  "Handfree Audio Gateway" (0x111f)
  "Generic Audio" (0x1203)
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 3
Profile Descriptor List:
  "Handsfree" (0x111e)
    Version: 0x0101

Service Name: HS Voice Gateway
Service RecHandle: 0x10004
Service Class ID List:
  "Headset Audio Gateway" (0x1112)
  "Generic Audio" (0x1203)
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 4
Profile Descriptor List:
  "Headset" (0x1108)
    Version: 0x0100

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

Service Name: OBEX File Transfer
Service RecHandle: 0x10006
Service Class ID List:
  "OBEX File Transfer" (0x1106)
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 6
  "OBEX" (0x0008)
Profile Descriptor List:
  "OBEX File Transfer" (0x1106)
    Version: 0x0100

Service Name: OBEX SyncML Client
Service RecHandle: 0x10007
Service Class ID List:
  "Error: This is UUID-128" (0x00000002-0000-1000-8000-0002ee000002)
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 7
  "OBEX" (0x0008)

Service Name: OBEX IrMC Sync Server
Service RecHandle: 0x10008
Service Class ID List:
  "IrMC Sync" (0x1104)
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 8
  "OBEX" (0x0008)
Profile Descriptor List:
  "IrMC Sync" (0x1104)
    Version: 0x0100

Service Name: Mouse & Keyboard
Service Description: Remote Control
Service Provider: Sony Ericsson
Service RecHandle: 0x10009
Service Class ID List:
  "Human Interface Device" (0x1124)
Protocol Descriptor List:
  "L2CAP" (0x0100)
    PSM: 17
  "HIDP" (0x0011)
Language Base Attr List:
  code_ISO639: 0x656e
  encoding:    0x6a
  base_offset: 0x100
Profile Descriptor List:
  "Human Interface Device" (0x1124)
    Version: 0x0100

chris@snackerjack-lx:~$

That's pretty cool - First you can see that I'm using a Sony Ericsson K750 phone and then on every bluetooth 'Service Name:' line, you can see the name of a service on offer. The one we are most interested in is the 'Dial-up Networking' service, however, we can also use this device as a voice gateway, and it will support OBEX transfer requests (ie the exchange of binary objects from other bluetooth devices). I can also use this phone as an input device (service 'Mouse & Keyboard' - note that this last service describes itself as 'Remote Control' and yes, it can be used in precisely that way - so the phone will suddenly become a pointer/mouse within the PAN. I will explain this in another article.

Okay, so where are we now? Well the next step is simply to tell your system which channel you want to talk RFCOMM. RFCOMM is a special bluetooth serial port emulation over radio frequency (hence the name rf communication). It is quite literally an implementation of the RS232 serial protocol over radio. Bluetooth can handle several rfcomm channels consecutively. We just have to decide which one we're going to use for this exercise.. This is dead easy. Just look at the output of the sdp search which you ran just now and look at the RFCOMM channel number in the 'Dial up Networking' service section. In the case above, it's channel 1.

All you do now is specify that channel in your rfcomm.conf - so on my system that looks like this:
rfcomm0 {
        bind yes;
        device 00:18:13:50:0C:EB;
        channel 1;
        comment "PPP connect";
}

At this point, you can set up /dev/rfcomm0 by running the following command:
$sudo /etc/init.d/bluez-utils restart

We're nearly there. Now that you have your rfcomm node fully configured and your phone and computer are paired, all you need to do is set up the PPP and chat settings on your computer. Chat sets up a ppp connection between your modem and a remote ppp service based on rules which you define in a chatscript.

First create the file /etc/ppp/peers/bluetoothconn and put the following into it:
debug
noauth
connect "/usr/sbin/chat -v -f /etc/chatscripts/bluetoothconn"
usepeerdns
/dev/rfcomm0 115200
defaultroute
crtscts
lcp-echo-failure 0

Now edit the file /etc/chatscripts/bluetoothconn and make sure it contains the following:
TIMEOUT 35
ECHO    ON
ABORT   'nBUSYr'
ABORT   'nERRORr'
ABORT   'nNO ANSWERr'
ABORT   'nNO CARRIERr'
ABORT   'nNO DIALTONEr'
ABORT   'nRINGINGrnrnRINGINGr'
''      rAT
OK      'AT+CGDCONT=2,"IP","btmobile.bt.com"'
OK      ATD*99***2#
CONNECT ""

It took me a while to get this configuration to work. I tried several settings for the data profile number, without any real idea of what it should be - and found that ***2 worked. You might have to play around with this for your own telco - try swapping the '2' for any integer between '1' and '4', or even remove the whole lot and just terminate with a '#'.

To bring the connection up, just run the command:
$pon bluetoothconn

and to turn it off again:
$poff Bluetoothconn

It's as simple as that. If you still have questions about your bluetooth and GPRS setup with linux on your laptop and trying to talk to BT, please reply to this and let me know.

Hope that helps.

christo
http://www.twitter.com/planet_guru
comment
mattskr
2007-03-02 17:09:00

Last command not working

Hey so I'm running Ubuntu 6.10 and I followed your tutorial but when I get to '$pon bluetoothconn' it says "bluetoothconn: Command Not Found"

Any ideas?

P.S. The only thing I had to do differently was use /etc/init.d/bluetooth restart instead of bluez-utils
reply icon
chris
2007-03-05 22:21:18

do you have the dev pppd utils installed?

maybe you don't have the PPP connection utilities installed.. try the following:

$ which pon

on my system, that returns /usr/bin/pon. If you don't have that on your system, you'll need to install the debian pppd package.

christo
reply icon
anonymous
2007-03-26 00:57:11

You shouldn't be typing this with the '$' sign, otherwise the shell will try to resolve it as a variable.

see here

$ echo $someval abc
abc
$ someval=dce
$ echo $someval abc
dce abc
reply icon
chris
2007-03-26 22:03:38

linux/unix shell

The dollar '$' sign is conventionally used to indicate the unix prompt. It was not intended that people would actually type that as their command!

thanks


christo

reply icon
knottulf
2007-04-25 20:44:40

unrecognized option

I get this error msg:

root@xxx:/dev# pon bluetooothconn
/usr/sbin/pppd: In file /etc/ppp/peers/bluetooothconn: unrecognized option '/dev/rfcomm0'

when executing "bluetooth restart", I get an error message in a KDE Bluetooth Framework saying "Failed to connect to the SDP server"

According to this thread, it is a bug in KDE, which apparently should not matter...?
https://bugs.launchpad.net/ubuntu/+source/kdebluetooth/+bug/97297

I cannot see any action between my laptop and the cellphone, so I take it that so far, the script for connecting to the internet has not yet been executed.

I have a Sony Ericsson K700i and Kubuntu Feisty Fawn.
reply icon
chris
2007-04-26 08:33:39

Bluetooth rfcomm configuration

Hey -

Have you set up your rfcomm0 configuration file? This lives under /etc/bluetooth/rfcomm.conf. Mine looks like this:

#
# rfcomm configuration file
#

rfcomm0 {
bind yes;
device 00:18:13:50:0C:EB;
channel 1;
comment "Bluetooth PPP Connection";
}

This configures the underlying rfcomm layer (which is part of the Bluez bluetooth stack). You should also check that you have the rfcomm binary installed under /usr/bin/rfcomm. You can use this to configure or query any configured rfcomm devices. So for example, this shows my current bluetooth connection:

chris@snackerjack-lx:~$ rfcomm -a
rfcomm0: 00:18:13:50:0C:EB channel 1 connected [tty-attached]

you will see that this matches the rfcomm0 node in the rfcomm configuration file. I could probably have called that node anything I want. As far as I can make up, Bluez will create the /dev node and then bind to it at run-time.

See how those checks look.

christo
reply icon
deric
2007-05-04 15:20:35

Indicating ISP user/pass

This is one of the most helpful tutorials I came across. I can see my laptop (Thinkpad X40 with Ubunutu Feisty) is dialing my ISP but it fails on authentication.

I noticed in the /etc/ppp/peers/bluetoothconn that you entered "noauth" as credentials. How would I indicate a username and password here? It seems my ISP requires it.

I think this is all i am missing!

Thanx Christo for taking the time to do write this and do all the research.

Big hello from the team at Techno.FM

Cheers

Deric
deric@techno.fm
reply icon
chris
2007-05-05 09:40:10

ppp authentication

Hi Deric

I guess you will first have to find out if your provide is using PAP or CHAP authentication - these are two common mechanisms for authenticating over ppp. If you are using PAP, then you can set up authentication details in your /etc/ppp/pap-secrets. If you are using CHAP, then try the /etc/ppp/chap-secrets. Keep an eye out for any other hints in your /var/lib/ppp.log.

I hope that works. It's awesome having bluetooth dialup working. I have stopped taking the underground to work and now I just take the bus - I pop open the laptop, run 'pon BluetoothDialup' to connect and then make good use of that travel time!

I keep meaning to write a bluetooth remote control article, but can't seem to find the time to do it properly..


christo

reply icon
deric
2007-05-15 15:12:31

Awesome!

That worked! It was PAP... And I am posting this with my cellphone!

Also, have you tried playing with the network manager applet in Gnome ? It actually indicates in the "Dialup" section my ISP!

Anyways... Thanx again.

Cheers

Deric D. Davis
deric_at_techno.fm
reply icon
vonjoost
2007-05-27 19:20:11

rfcomm0 error

hello,

I also keep getting the same error:

/usr/sbin/pppd: In file /etc/ppp/peers/bluetooothconn: unrecognized option '/dev/rfcomm0'

everything else seems to work just fine... i just keep getting that error when i go to connect. My rfcomm.conf looks exactly like the one posted above.

Anyone have any ideas?
reply icon
chris
2007-07-23 13:24:49

restart bluetooth services

note that on some distros, the bluetooth start/stop script thinyg under /etc is just called 'bluetooth', so to restart bluetooth services on say Ubuntu Feisty, you would run the following command instead:

chris@chris-laptop:~$ sudo /etc/init.d/bluetooth restart
* Restarting Bluetooth services
chris@chris-laptop:~$


christo
reply icon
gaston
2007-12-07 17:41:08

Great howto.
It helped me a lot about the way ubuntu likes it.

I just let the " OK 'AT+CGDCONT=2,"IP","btmobile.bt.com"' " away,
and for the phone numer I use *99#
I believe that you can select a gprs/umts profile with the ***1 or ***2 numbers.
My current phone doesn't have more gprs/umts profiles, so I just use the default with *99#

Regards,
Gaston Bougie
reply icon
socialistic
2008-04-26 23:00:10

Various problems

I'm trying to dial-up with bluetooth and cell phone, on Ubuntu 7.10...and this method has yielded several problems for me.

Does the creator of this thread have any contact info so I can speak with them and possibly get my bluetooth problems fixed?

Here's some info from my terminal to give an idea of what's going on so far.

johnny@GOD:~$ sudo apt-get install bluez-utils
Reading package lists...Done
Building dependency tree
Reading state information...Done
bluez-utilz is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

johnny@GOD:~$ sudo apt-get install blues-pin
Reading package lists...Done
Building dependency tree
Reading state information...Done
E: Couldn't find package blues-pin(I tried bluez-pin as well)

johnny@GOD:~$ sudo apt-get install ppp
Reading package lists...Done
Building dependency tree
Reading state information...Done
ppp is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

johnny@GOD:~$ hcitool scan
Scanning ...
00:1C:CC:BE:94:54 BlackBerry 8130

johnny@god:~$ sudo hcitool cc 00:1C:CC:BE:94:54(pairs phone and pc correctly)

johnny@god:~$ sudo hcitool auth 00:1C:CC:BE:94:54
Not Connected.(phone and pc are no longer paired as soon as I enter this auth command.)

I tried the sdptool browse command...and it worked...my dial-up networking rfcomm channel was 3. It only worked if I did the cc command, and not the auth command(which instantly unpairs my phone and pc if entered.)

After my system halted/froze, and I rebooted...I tried the two above commands again(cc and auth), here is what happened.

johnny@god:~$ sudo hcitool cc 00:1C:CC:BE:94:54
Can't create connection: Input/Output Error.
johnny@god:~$ sudo hcitool auth 00:1C:CC:BE:94:54
Not Connected.

So now the cc command doesn't even work, auth command still doesn't work. I also tried edited /etc/bluetooth/rfcomm.conf...but it keeps telling me I don't have permission to save the changes.

Why did the cc command work before, and now it doesn't work/pair anymore? Why doesn't the auth command work at all, and why did it keep un-pairing my phone/pc when cc command did work/pair? Why can't I save the changes I make to /etc/bluetooth/rfcomm.conf? Why doesn't blues-pin install?

Thank you for your time.
reply icon
Jak
2008-08-10 17:28:26

Amazing

I just wanted to express my gratitude. Even more than a year after the original post, it has helped me tremendously. Thanks.
reply iconedit reply
anonymous
2008-09-06 15:56:27

Hi Christo,

I am Hari. I just saw your tutorial about using a mobile phone as Bluetooth modem in Ubuntu. I just wanted to add that if you replace 'bluetoothconn' with 'provider' in both '/etc/ppp/peers/bluetoothconn' and '/etc/chatscripts/bluetoothconn'
you can just type 'pon' for connecting and 'poff' for disconnecting. You dont have to mention the connection name.

Bye
reply iconedit reply
anonymous
2008-09-07 14:39:07

My bluetooth was setup perfectly as you have mentioned in your article. But my mobile does not dial the "*99#". It just shows that "Connected to Indira" and does not do anything. It is still in bluetooth network as I can access the files in the mobile and the bluetooth icon is also surrounded by the indicator.

Please tell me what to do.
reply iconedit reply
rahid
2008-11-12 04:21:29

More help

Some times this way may not help you. I have also faced problem with this. I found more help on http://ubuntu-help.co.cc/index.php/ubuntu-help/35-internet/46-mobile-broadband-internet-over-bluetooth here.

You may try this.
reply icon
Hari
2009-04-06 17:13:29

Blueotooth Modem.

Great howto.
It helped me a lot about the way ubuntu likes it.

I just let the " OK 'AT+CGDCONT=2,"IP","btmobile.bt.com"' " away,
and for the phone numer I use *99#
I believe that you can select a gprs/umts profile with the ***1 or ***2 numbers.
My current phone doesn't have more gprs/umts profiles, so I just use the default with *99#

Regards,
Gaston Bougie


This worked for me also after a years experiments. Another tip : LET THE CONFIGURATION FILES BE NAMED "Provider". IT ELEMINATES THE FILE NAME AFTER "pon". JUST TYPE "Pon", THE CONNECTION IS ACTIVATED.
reply iconedit reply
Zakir
2009-06-05 04:00:18

Fantastic Howto

After spending almost 24 hrs trying to pair my BB 8130 as a tethered modem with my vostro 1510 running Ubuntu 9.04 I came across this great howto. kudos to Chris for this fantastic tutorial. It's fluid, explains all the steps clearly with example. Why all the others howto so techy and hard to understand for the newbie's? It's been a great help. Thanks Chris.







This article explains how to set up a bluetooth connection between your ubuntu laptop and phone and get PPP working with BT's mobile service in the UK. It probably isn't so hard to repeat this for other network providers. I'm sure that if you do a Yahoo search for the GPRS settings of your mobile telco, you'll be up and runnin with little more than a few mintues of poking around.

First you need to install the bluetooth packages on your linux machine:
$sudo apt-get install bluez-utils
$sudo apt-get install blues-pin

Now you need to make sure you have the ppp package installed

$sudo apt-get install ppp


At this point you already have enough software on your machine to do a scan of the local area and see what devices are available. this is done using hcitool. When I run this command, the output looks like this:
$chris@snackerjack-lx:~$ hcitool scan
Scanning ...
        00:07:3A:08:EE:74       n/a
        00:18:13:50:0C:EB       Christo Yahoo!
chris@snackerjack-lx:~$

That means that my laptop can see my phone - it's reporting the MAC address and the device name.

For more information on hcitool, you can run 'man hcitool'. Basically hcitool is a handy bluetooth utility which allows you to scan for and query local bluetooth devices. At this stage you can use hcitool to pair your bluetooth-enabled laptop with your phone. Use the following commands to achieve this:
$sudo hcitool cc 00:18:13:50:0C:EB

Note, you should use the MAC address of your own phone in this command - as reported by the hcitool scan command earlier. This creates a baseband connection to your phone. The next step is:
$sudo hcitool auth 00:18:13:50:0C:EB

This will request authentication with your phone - this is known as 'pairing' and will allow your computer to communicate with your bluetooth phone. Note again, you should replace the mac address with that of your phone. Don't use mine!


The next stage is to use the Service Discovery Protocol to ask your device what bluetooth services it is offering. At this point, if you're feeling really curious, you could re-run your hcitool scan and then run an SDP discovery search on all the listed devices. You never know - it might be interesting. However, this article is about setting up a Dial-up connection through your phone, so let's keep focussed.. The command you need to issue looks like this:
$sdptool browse 00:18:13:50:0C:EB

Again, use your own phone's MAC address - This will list all sorts of bluetooth services that your phone offers. This is what the output looks like when I run this command against my own phone.. I know it's a lot to paste, but it's worth seeing the kind of services which might be on offer:
chris@snackerjack-lx:~$ sdptool browse 00:18:13:50:0C:EB
Browsing 00:18:13:50:0C:EB ...
Service Description: Sony Ericsson K750
Service RecHandle: 0x10000
Service Class ID List:
  "PnP Information" (0x1200)

Service Name: Dial-up Networking
Service RecHandle: 0x10001
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

Service Name: Serial Port
Service RecHandle: 0x10002
Service Class ID List:
  "Serial Port" (0x1101)
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 2

Service Name: HF Voice Gateway
Service RecHandle: 0x10003
Service Class ID List:
  "Handfree Audio Gateway" (0x111f)
  "Generic Audio" (0x1203)
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 3
Profile Descriptor List:
  "Handsfree" (0x111e)
    Version: 0x0101

Service Name: HS Voice Gateway
Service RecHandle: 0x10004
Service Class ID List:
  "Headset Audio Gateway" (0x1112)
  "Generic Audio" (0x1203)
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 4
Profile Descriptor List:
  "Headset" (0x1108)
    Version: 0x0100

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

Service Name: OBEX File Transfer
Service RecHandle: 0x10006
Service Class ID List:
  "OBEX File Transfer" (0x1106)
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 6
  "OBEX" (0x0008)
Profile Descriptor List:
  "OBEX File Transfer" (0x1106)
    Version: 0x0100

Service Name: OBEX SyncML Client
Service RecHandle: 0x10007
Service Class ID List:
  "Error: This is UUID-128" (0x00000002-0000-1000-8000-0002ee000002)
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 7
  "OBEX" (0x0008)

Service Name: OBEX IrMC Sync Server
Service RecHandle: 0x10008
Service Class ID List:
  "IrMC Sync" (0x1104)
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 8
  "OBEX" (0x0008)
Profile Descriptor List:
  "IrMC Sync" (0x1104)
    Version: 0x0100

Service Name: Mouse & Keyboard
Service Description: Remote Control
Service Provider: Sony Ericsson
Service RecHandle: 0x10009
Service Class ID List:
  "Human Interface Device" (0x1124)
Protocol Descriptor List:
  "L2CAP" (0x0100)
    PSM: 17
  "HIDP" (0x0011)
Language Base Attr List:
  code_ISO639: 0x656e
  encoding:    0x6a
  base_offset: 0x100
Profile Descriptor List:
  "Human Interface Device" (0x1124)
    Version: 0x0100

chris@snackerjack-lx:~$

That's pretty cool - First you can see that I'm using a Sony Ericsson K750 phone and then on every bluetooth 'Service Name:' line, you can see the name of a service on offer. The one we are most interested in is the 'Dial-up Networking' service, however, we can also use this device as a voice gateway, and it will support OBEX transfer requests (ie the exchange of binary objects from other bluetooth devices). I can also use this phone as an input device (service 'Mouse & Keyboard') - note that this last service describes itself as 'Remote Control' and yes, it can be used in precisely that way - so the phone will suddenly become a pointer/mouse within the PAN. I will explain this in another article.

Okay, so where are we now? Well the next step is simply to tell your system which channel you want to talk RFCOMM. RFCOMM is a special bluetooth serial port emulation over radio frequency (hence the name rf communication). It is quite literally an implementation of the RS232 serial protocol over radio. Bluetooth can handle several rfcomm channels consecutively. We just have to decide which one we're going to use for this exercise.. This is dead easy. Just look at the output of the sdp search which you ran just now and look at the RFCOMM channel number in the 'Dial up Networking' service section. In the case above, it's channel 1.

All you do now is specify that channel in your rfcomm.conf - so on my system that looks like this:
rfcomm0 {
        bind yes;
        device 00:18:13:50:0C:EB;
        channel 1;
        comment "PPP connect";
}

At this point, you can set up /dev/rfcomm0 by running the following command:
$sudo /etc/init.d/bluez-utils restart

We're nearly there. Now that you have your rfcomm node fully configured and your phone and computer are paired, all you need to do is set up the PPP and chat settings on your computer. Chat sets up a ppp connection between your modem and a remote ppp service based on rules which you define in a chatscript.

First create the file /etc/ppp/peers/bluetoothconn and put the following into it:
debug
noauth
connect "/usr/sbin/chat -v -f /etc/chatscripts/bluetoothconn"
usepeerdns
/dev/rfcomm0 115200
defaultroute
crtscts
lcp-echo-failure 0

Now edit the file /etc/chatscripts/bluetoothconn and make sure it contains the following:
TIMEOUT 35
ECHO    ON
ABORT   'nBUSYr'
ABORT   'nERRORr'
ABORT   'nNO ANSWERr'
ABORT   'nNO CARRIERr'
ABORT   'nNO DIALTONEr'
ABORT   'nRINGINGrnrnRINGINGr'
''      rAT
OK      'AT+CGDCONT=2,"IP","btmobile.bt.com"'
OK      ATD*99***2#
CONNECT ""

It took me a while to get this configuration to work. I tried several settings for the data profile number, without any real idea of what it should be - and found that ***2 worked. You might have to play around with this for your own telco - try swapping the '2' for any integer between '1' and '4', or even remove the whole lot and just terminate with a '#'.

To bring the connection up, just run the command:
$pon bluetoothconn

and to turn it off again:
$poff Bluetoothconn

It's as simple as that. If you still have questions about your bluetooth and GPRS setup with linux on your laptop and trying to talk to BT, please reply to this and let me know.

Hope that helps.

christo
http://www.twitter.com/planet_guru
reply iconedit reply
nesan
2009-06-24 07:32:21

Thank you for the nice tutorial.I followed your tutorial and got it worked. can it implemented in c.
reply icon
senthil
2009-08-27 05:27:23

Hi

Thanks for the tutorial.I tried the tutorial,I am getting the ip,DNS address everything.When i try ping www.google.com,It is not working.What could be the problem.
reply iconedit reply
Ralph
2010-03-09 18:01:51

Thanks!

Great tutorial, just used it as the basis for setting up bluetooth internet on a Nokia N810, good work, very much appreciate the tutorial.
reply iconedit reply