Bluetooth pair use command line

Source: Internet
Author: User

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 scanScanning ...        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 shoshould 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 cocould 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
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:EBBrowsing 00:18:13:50:0C:EB ...Service Description: Sony Ericsson K750Service RecHandle: 0x10000Service Class ID List:  "PnP Information" (0x1200)Service Name: Dial-up NetworkingService RecHandle: 0x10001Service Class ID List:  "Dialup Networking" (0x1103)  "Generic Networking" (0x1201)Protocol Descriptor List:  "L2CAP" (0x0100)  "RFCOMM" (0x0003)    Channel: 1Profile Descriptor List:  "Dialup Networking" (0x1103)    Version: 0x0100Service Name: Serial PortService RecHandle: 0x10002Service Class ID List:  "Serial Port" (0x1101)Protocol Descriptor List:  "L2CAP" (0x0100)  "RFCOMM" (0x0003)    Channel: 2Service Name: HF Voice GatewayService RecHandle: 0x10003Service Class ID List:  "Handfree Audio Gateway" (0x111f)  "Generic Audio" (0x1203)Protocol Descriptor List:  "L2CAP" (0x0100)  "RFCOMM" (0x0003)    Channel: 3Profile Descriptor List:  "Handsfree" (0x111e)    Version: 0x0101Service Name: HS Voice GatewayService RecHandle: 0x10004Service Class ID List:  "Headset Audio Gateway" (0x1112)  "Generic Audio" (0x1203)Protocol Descriptor List:  "L2CAP" (0x0100)  "RFCOMM" (0x0003)    Channel: 4Profile Descriptor List:  "Headset" (0x1108)    Version: 0x0100Service Name: OBEX Object PushService RecHandle: 0x10005Service 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: 0x0100Service Name: OBEX File TransferService RecHandle: 0x10006Service 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: 0x0100Service Name: OBEX SyncML ClientService RecHandle: 0x10007Service 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 ServerService RecHandle: 0x10008Service Class ID List:  "IrMC Sync" (0x1104)Protocol Descriptor List:  "L2CAP" (0x0100)  "RFCOMM" (0x0003)    Channel: 8  "OBEX" (0x0008)Profile Descriptor List:  "IrMC Sync" (0x1104)    Version: 0x0100Service Name: Mouse & KeyboardService Description: Remote ControlService Provider: Sony EricssonService RecHandle: 0x10009Service 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: 0x100Profile Descriptor List:  "Human Interface Device" (0x1124)    Version: 0x0100chris@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
'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 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 abve, 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 re nearly there. now that you have your RFCOMM node fully configured and your phone and computer are running red, 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/descrithconn and put the following into it:

debugnoauthconnect "/usr/sbin/chat -v -f /etc/chatscripts/bluetoothconn"usepeerdns/dev/rfcomm0 115200defaultroutecrtsctslcp-echo-failure 0

Now edit the file/etc/chatscripts/bluetoothconn and make sure it contains the following:

TIMEOUT 35ECHO    ONABORT   'nBUSYr'ABORT   'nERRORr'ABORT   'nNO ANSWERr'ABORT   'nNO CARRIERr'ABORT   'nNO DIALTONEr'ABORT   'nRINGINGrnrnRINGINGr'''      rATOK      '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 shoshould be-and found that *** 2 worked. you might have to play around
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 '#'.

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

Follow me on Twitter to catch all my tech updates http://www.twitter.com/planet_guru

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.