| 1 |
fox2mike |
1.1 |
<?xml version='1.0' encoding="UTF-8"?>
|
| 2 |
|
|
|
| 3 |
|
|
<!DOCTYPE guide SYSTEM "/dtd/guide.dtd">
|
| 4 |
nightmorph |
1.13 |
<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/bluetooth-guide.xml,v 1.12 2007/04/10 06:48:59 nightmorph Exp $ -->
|
| 5 |
fox2mike |
1.1 |
|
| 6 |
|
|
<guide link="/doc/en/bluetooth-guide.xml">
|
| 7 |
|
|
<title>Gentoo Linux Bluetooth Guide</title>
|
| 8 |
|
|
|
| 9 |
|
|
<author title="Author">
|
| 10 |
|
|
<mail link="deathwing00@gentoo.org">Ioannis Aslanidis</mail>
|
| 11 |
|
|
</author>
|
| 12 |
|
|
<author title="Contributor">
|
| 13 |
|
|
<mail link="puggy@gentoo.org">Douglas Russell</mail>
|
| 14 |
|
|
</author>
|
| 15 |
|
|
<author title="Contributor">
|
| 16 |
|
|
<mail link="marcel@holtmann.org">Marcel Holtmann</mail>
|
| 17 |
|
|
</author>
|
| 18 |
neysx |
1.3 |
<author title="Author">
|
| 19 |
fox2mike |
1.1 |
<mail link="fox2mike@gentoo.org">Shyam Mani</mail>
|
| 20 |
|
|
</author>
|
| 21 |
|
|
<author title="Editor">
|
| 22 |
|
|
<mail link="rane@gentoo.org">Ćukasz Damentko</mail>
|
| 23 |
|
|
</author>
|
| 24 |
|
|
|
| 25 |
|
|
<abstract>
|
| 26 |
|
|
This guide will explain how to successfully install a host Bluetooth device,
|
| 27 |
|
|
configure the kernel properly, explain all the possibilities that the Bluetooth
|
| 28 |
neysx |
1.3 |
interconnection offers and how to have some fun with Bluetooth.
|
| 29 |
fox2mike |
1.1 |
</abstract>
|
| 30 |
|
|
|
| 31 |
|
|
<!-- The content of this document is licensed under the CC-BY-SA license -->
|
| 32 |
|
|
<!-- See http://creativecommons.org/licenses/by-sa/2.5 -->
|
| 33 |
|
|
<license/>
|
| 34 |
|
|
|
| 35 |
nightmorph |
1.13 |
<version>1.9</version>
|
| 36 |
|
|
<date>2007-05-16</date>
|
| 37 |
fox2mike |
1.1 |
|
| 38 |
|
|
<chapter id="introduction">
|
| 39 |
|
|
<title>Introduction</title>
|
| 40 |
|
|
<section>
|
| 41 |
|
|
<title>What is Bluetooth?</title>
|
| 42 |
|
|
<body>
|
| 43 |
|
|
|
| 44 |
|
|
<p>
|
| 45 |
|
|
Bluetooth is an industrial specification that provides users a way to connect
|
| 46 |
|
|
and exchange information between devices like personal computers, PDAs or
|
| 47 |
|
|
mobile phones. Using the Bluetooth technology, users can achieve wireless voice
|
| 48 |
|
|
and data transmission between devices at a low cost. Bluetooth also offers the
|
| 49 |
|
|
possibility to create small wireless LANs and to synchronize devices.
|
| 50 |
|
|
</p>
|
| 51 |
|
|
|
| 52 |
|
|
</body>
|
| 53 |
|
|
</section>
|
| 54 |
|
|
<section>
|
| 55 |
|
|
<title>About the content of this guide</title>
|
| 56 |
|
|
<body>
|
| 57 |
|
|
|
| 58 |
|
|
<p>
|
| 59 |
|
|
The first part of this guide is to identify qualified and non-qualified devices
|
| 60 |
|
|
that support the Bluetooth technology. This way, users can purchase Bluetooth
|
| 61 |
|
|
devices that are known to work. After that, the guide explains how to configure
|
| 62 |
|
|
the system kernel, identify the Bluetooth devices installed on the system and
|
| 63 |
|
|
detected by the kernel and install the necessary basic Bluetooth tools.
|
| 64 |
|
|
</p>
|
| 65 |
|
|
|
| 66 |
|
|
<p>
|
| 67 |
|
|
The second part covers how to detect remote devices and how to establish a
|
| 68 |
|
|
connection from or to them by either setting up radio frequency communication
|
| 69 |
|
|
(RFCOMM) or by setting up a personal area network (PAN).
|
| 70 |
|
|
</p>
|
| 71 |
|
|
|
| 72 |
|
|
<p>
|
| 73 |
|
|
The last part of the guide lists in detail applications that can take
|
| 74 |
|
|
advantage of all the possibilities offered by the Bluetooth technology.
|
| 75 |
|
|
</p>
|
| 76 |
|
|
|
| 77 |
|
|
</body>
|
| 78 |
|
|
</section>
|
| 79 |
|
|
</chapter>
|
| 80 |
|
|
|
| 81 |
|
|
<chapter id="devices">
|
| 82 |
|
|
<title>Supported Devices</title>
|
| 83 |
|
|
<section>
|
| 84 |
|
|
<title>Qualified and non-qualified devices that support Bluetooth</title>
|
| 85 |
|
|
<body>
|
| 86 |
|
|
|
| 87 |
|
|
<impo>
|
| 88 |
|
|
These products might work even though some are not qualified Bluetooth
|
| 89 |
|
|
products. Gentoo does not support them in any way, they might just work.
|
| 90 |
|
|
</impo>
|
| 91 |
|
|
|
| 92 |
|
|
<p>
|
| 93 |
|
|
A list of the currently supported devices can be found at: <uri
|
| 94 |
|
|
link="http://www.holtmann.org/linux/bluetooth/features.html">Bluetooth device
|
| 95 |
|
|
features and revision information by Marcel Holtmann</uri>.
|
| 96 |
|
|
</p>
|
| 97 |
|
|
|
| 98 |
|
|
</body>
|
| 99 |
|
|
</section>
|
| 100 |
|
|
</chapter>
|
| 101 |
|
|
|
| 102 |
|
|
<chapter id="kernel">
|
| 103 |
|
|
<title>Configuring the system</title>
|
| 104 |
|
|
<section>
|
| 105 |
|
|
<title>Kernel Configuration</title>
|
| 106 |
|
|
<body>
|
| 107 |
|
|
|
| 108 |
|
|
<p>
|
| 109 |
|
|
As the latest Linux stable kernel is 2.6, the configuration will be done for
|
| 110 |
|
|
these series of the kernel. Most Bluetooth devices are connected to a USB port,
|
| 111 |
nightmorph |
1.12 |
so USB will be enabled too. Please refer to the <uri
|
| 112 |
|
|
link="/doc/en/usb-guide.xml"> Gentoo Linux USB Guide</uri>.
|
| 113 |
fox2mike |
1.1 |
</p>
|
| 114 |
|
|
|
| 115 |
|
|
<pre caption="Configuration for 2.6 kernels">
|
| 116 |
swift |
1.5 |
Networking --->
|
| 117 |
fox2mike |
1.1 |
|
| 118 |
|
|
<*> Bluetooth subsystem support --->
|
| 119 |
|
|
|
| 120 |
|
|
--- Bluetooth subsystem support
|
| 121 |
|
|
<M> L2CAP protocol support
|
| 122 |
|
|
<M> SCO links support
|
| 123 |
|
|
<M> RFCOMM protocol support
|
| 124 |
|
|
[*] RFCOMM TTY support
|
| 125 |
|
|
<M> BNEP protocol support
|
| 126 |
|
|
[*] Multicast filter support
|
| 127 |
|
|
[*] Protocol filter support
|
| 128 |
|
|
<M> HIDP protocol support
|
| 129 |
|
|
|
| 130 |
|
|
Bluetooth device drivers --->
|
| 131 |
|
|
<M> HCI USB driver
|
| 132 |
|
|
[*] SCO (voice) support
|
| 133 |
|
|
<M> HCI UART driver
|
| 134 |
|
|
[*] UART (H4) protocol support
|
| 135 |
|
|
[*] BCSP protocol support
|
| 136 |
|
|
[*] Transmit CRC with every BCSP packet
|
| 137 |
|
|
<M> HCI BCM203x USB driver
|
| 138 |
|
|
<M> HCI BPA10x USB driver
|
| 139 |
|
|
<M> HCI BlueFRITZ! USB driver
|
| 140 |
|
|
<comment>(The four drivers below are for PCMCIA Bluetooth devices and will only
|
| 141 |
|
|
show up if you have also selected PCMCIA support in your kernel.)</comment>
|
| 142 |
|
|
<M> HCI DTL1 (PC Card) driver
|
| 143 |
|
|
<M> HCI BT3C (PC Card) driver
|
| 144 |
|
|
<M> HCI BlueCard (PC Card) driver
|
| 145 |
neysx |
1.3 |
<M> HCI UART (PC Card) device driver
|
| 146 |
fox2mike |
1.1 |
<comment>(The driver below is intended for HCI Emulation software.)</comment>
|
| 147 |
|
|
<M> HCI VHCI (Virtual HCI device) driver
|
| 148 |
|
|
|
| 149 |
|
|
<comment>(Move back three levels to Device Drives and then check if USB is
|
| 150 |
|
|
enabled. This is required if you use a Bluetooth dongle, which are mostly USB
|
| 151 |
|
|
based.)</comment>
|
| 152 |
|
|
USB support --->
|
| 153 |
|
|
|
| 154 |
|
|
<*> Support for Host-side USB
|
| 155 |
|
|
--- USB Host Controller Drivers
|
| 156 |
|
|
<M> EHCI HCD (USB 2.0) support
|
| 157 |
|
|
[ ] Full speed ISO transactions (EXPERIMENTAL)
|
| 158 |
|
|
[ ] Root Hub Transaction Translators (EXPERIMENTAL)
|
| 159 |
|
|
<*> OHCI HCD support
|
| 160 |
|
|
<*> UHCI HCD (most Intel and VIA) support
|
| 161 |
|
|
< > SL811HS HCD support
|
| 162 |
|
|
</pre>
|
| 163 |
|
|
|
| 164 |
|
|
<p>
|
| 165 |
|
|
Now we'll reboot with our new kernel. If everything went fine, we will have a
|
| 166 |
|
|
system that is Bluetooth ready.
|
| 167 |
|
|
</p>
|
| 168 |
|
|
|
| 169 |
|
|
<impo>
|
| 170 |
|
|
Your USB device may have two modes the default of which may not be HCI, but HID.
|
| 171 |
|
|
If this is your case, use <c>hid2hci</c> to switch to HCI mode. Your system
|
| 172 |
|
|
will not remember this change when you next reboot.
|
| 173 |
|
|
</impo>
|
| 174 |
|
|
|
| 175 |
|
|
<pre caption="Checking the Bluetooth devices">
|
| 176 |
|
|
<comment>(One way to check for the device)</comment>
|
| 177 |
|
|
# <i>cat /proc/bus/usb/devices | grep -e^[TPD] | grep -e Cls=e0 -B1 -A1</i>
|
| 178 |
|
|
<comment>(The Cls=e0(unk. ) identifies the Bluetooth adapter.)</comment>
|
| 179 |
|
|
T: Bus=02 Lev=02 Prnt=03 Port=00 Cnt=01 Dev#= 4 Spd=12 MxCh= 0
|
| 180 |
|
|
D: Ver= 1.10 Cls=e0(unk. ) Sub=01 Prot=01 MxPS=64 #Cfgs= 1
|
| 181 |
neysx |
1.3 |
P: Vendor=0a12 ProdID=0001 Rev= 5.25
|
| 182 |
fox2mike |
1.1 |
<comment>(Some might show up on lsusb from sys-apps/usbutils)</comment>
|
| 183 |
|
|
# <i>lsusb</i>
|
| 184 |
|
|
Bus 003 Device 002: ID 046d:c00e Logitech, Inc. Optical Mouse
|
| 185 |
|
|
Bus 003 Device 001: ID 0000:0000
|
| 186 |
|
|
Bus 002 Device 002: ID 0db0:1967 Micro Star International Bluetooth Dongle
|
| 187 |
|
|
</pre>
|
| 188 |
|
|
|
| 189 |
|
|
</body>
|
| 190 |
|
|
</section>
|
| 191 |
|
|
</chapter>
|
| 192 |
|
|
|
| 193 |
|
|
<chapter id="bluez">
|
| 194 |
|
|
<title>BlueZ - The Bluetooth Stack</title>
|
| 195 |
|
|
<section>
|
| 196 |
|
|
<title>Installing BlueZ</title>
|
| 197 |
|
|
<body>
|
| 198 |
|
|
|
| 199 |
|
|
<p>
|
| 200 |
|
|
Now that the device is detected by the kernel, we need a layer that lets
|
| 201 |
|
|
applications communicate with the Bluetooth device. BlueZ provides the official
|
| 202 |
|
|
Linux Bluetooth stack. The ebuilds that provide what we need are
|
| 203 |
|
|
<c>bluez-libs</c> and <c>bluez-utils</c>. Devices that need Broadcom firmware
|
| 204 |
|
|
files or the like may need <c>bluez-firmware</c>.
|
| 205 |
|
|
</p>
|
| 206 |
|
|
|
| 207 |
|
|
<pre caption="Installing bluez-libs and bluez-utils">
|
| 208 |
|
|
# <i>emerge net-wireless/bluez-libs net-wireless/bluez-utils</i>
|
| 209 |
|
|
</pre>
|
| 210 |
|
|
|
| 211 |
|
|
<warn>
|
| 212 |
jkt |
1.7 |
Do not emerge <c>bluez-sdp</c> as it will break <c>bluez-utils</c>!
|
| 213 |
fox2mike |
1.1 |
</warn>
|
| 214 |
|
|
|
| 215 |
|
|
</body>
|
| 216 |
|
|
</section>
|
| 217 |
|
|
<section>
|
| 218 |
|
|
<title>BlueZ configuration and PIN pairing</title>
|
| 219 |
|
|
<body>
|
| 220 |
|
|
|
| 221 |
|
|
<p>
|
| 222 |
|
|
Now it's time to see if the Bluetooth device is being picked up correctly by the
|
| 223 |
|
|
system. We start up the required Bluetooth services first.
|
| 224 |
|
|
</p>
|
| 225 |
|
|
|
| 226 |
|
|
<pre caption="Running hciconfig">
|
| 227 |
|
|
<comment>(Start up Bluetooth)</comment>
|
| 228 |
|
|
# <i>/etc/init.d/bluetooth start</i>
|
| 229 |
|
|
* Starting Bluetooth ...
|
| 230 |
|
|
* Starting hcid ... [ ok ]
|
| 231 |
|
|
* Starting sdpd ... [ ok ]
|
| 232 |
|
|
* Starting rfcomm ... [ ok ]
|
| 233 |
|
|
|
| 234 |
|
|
# <i>hciconfig</i>
|
| 235 |
|
|
hci0: Type: USB
|
| 236 |
|
|
BD Address: 00:01:02:03:04:05 ACL MTU: 192:8 SCO MTU: 64:8
|
| 237 |
|
|
DOWN
|
| 238 |
|
|
RX bytes:131 acl:0 sco:0 events:18 errors:0
|
| 239 |
neysx |
1.3 |
TX bytes:565 acl:0 sco:0 commands:17 errors:0
|
| 240 |
fox2mike |
1.1 |
</pre>
|
| 241 |
|
|
|
| 242 |
|
|
<p>
|
| 243 |
|
|
This shows that the Bluetooth device has been recognised. As you might have
|
| 244 |
|
|
noticed the device is <e>DOWN</e>. Let's configure it so that we can bring it
|
| 245 |
|
|
up. The configuration file is at <path>/etc/bluetooth/hcid.conf</path>. The
|
| 246 |
|
|
required changes to the config file are shown below. For additional details
|
| 247 |
|
|
please refer to <c>man hcid.conf</c>.
|
| 248 |
|
|
</p>
|
| 249 |
|
|
|
| 250 |
|
|
<pre caption="Editing /etc/bluetooth/hcid.conf">
|
| 251 |
|
|
<comment>(Recommended changes to be made to the file are shown)</comment>
|
| 252 |
|
|
|
| 253 |
neysx |
1.6 |
# HCId options
|
| 254 |
|
|
options {
|
| 255 |
|
|
# Automatically initialize new devices
|
| 256 |
|
|
autoinit yes;
|
| 257 |
|
|
|
| 258 |
fox2mike |
1.1 |
<comment>(Change security to "auto")</comment>
|
| 259 |
|
|
# Security Manager mode
|
| 260 |
|
|
# none - Security manager disabled
|
| 261 |
|
|
# auto - Use local PIN for incoming connections
|
| 262 |
|
|
# user - Always ask user for a PIN
|
| 263 |
|
|
#
|
| 264 |
|
|
security auto;
|
| 265 |
|
|
|
| 266 |
neysx |
1.6 |
# Pairing mode
|
| 267 |
|
|
pairing multi;
|
| 268 |
|
|
|
| 269 |
nightmorph |
1.13 |
<comment>(You only need a pin helper if you are using <=bluez-libs-2.x and <=bluez-utils-2.x)
|
| 270 |
|
|
(Change pin_helper to use /etc/bluetooth/pin-helper)</comment>
|
| 271 |
fox2mike |
1.1 |
# PIN helper
|
| 272 |
|
|
pin_helper /etc/bluetooth/pin-helper;
|
| 273 |
neysx |
1.6 |
}
|
| 274 |
fox2mike |
1.1 |
|
| 275 |
neysx |
1.6 |
# Default settings for HCI devices
|
| 276 |
|
|
device {
|
| 277 |
fox2mike |
1.1 |
<comment>(Set your device name here, you can call it anything you want)</comment>
|
| 278 |
|
|
# Local device name
|
| 279 |
|
|
# %d - device id
|
| 280 |
|
|
# %h - host name
|
| 281 |
|
|
name "BlueZ at %h (%d)";
|
| 282 |
|
|
|
| 283 |
neysx |
1.6 |
# Local device class
|
| 284 |
|
|
class 0x3e0100;
|
| 285 |
|
|
|
| 286 |
|
|
# Inquiry and Page scan
|
| 287 |
|
|
iscan enable; pscan enable;
|
| 288 |
|
|
|
| 289 |
|
|
# Default link mode
|
| 290 |
|
|
lm accept;
|
| 291 |
|
|
|
| 292 |
|
|
# Default link policy
|
| 293 |
|
|
lp rswitch,hold,sniff,park;
|
| 294 |
|
|
|
| 295 |
fox2mike |
1.1 |
<comment>(Leave as is, if you don't know what exactly these do)</comment>
|
| 296 |
|
|
# Authentication and Encryption (Security Mode 3)
|
| 297 |
|
|
#auth enable;
|
| 298 |
|
|
#encrypt enable;
|
| 299 |
|
|
}
|
| 300 |
|
|
</pre>
|
| 301 |
|
|
|
| 302 |
|
|
<p>
|
| 303 |
|
|
After that, we have to configure the Bluetooth device PIN. That will help in
|
| 304 |
|
|
pairing this device with another one.
|
| 305 |
|
|
</p>
|
| 306 |
|
|
|
| 307 |
|
|
<pre caption="Editing /etc/bluetooth/pin">
|
| 308 |
nightmorph |
1.13 |
<comment>(Replace 123456 with your desired pin number.)</comment>
|
| 309 |
fox2mike |
1.1 |
123456
|
| 310 |
|
|
</pre>
|
| 311 |
|
|
|
| 312 |
|
|
<impo>
|
| 313 |
|
|
This number (of your choice) must be the same in all your hosts with Bluetooth
|
| 314 |
|
|
devices so they can be paired. This number must also be kept secret since anyone
|
| 315 |
|
|
with knowledge of this number can essentially establish connections with your
|
| 316 |
|
|
devices.
|
| 317 |
|
|
</impo>
|
| 318 |
|
|
|
| 319 |
nightmorph |
1.13 |
<note>
|
| 320 |
|
|
If you are using <c><=bluez-libs-2.x</c> and <c><=bluez-utils-2.x</c> you
|
| 321 |
|
|
can choose from different pin helpers, depending on what you want to use.
|
| 322 |
|
|
Available pin helpers are: <c>/usr/lib/kdebluetooth/kbluepin</c>
|
| 323 |
|
|
(net-wireless/kdebluetooth), <c>/usr/bin/bluepin</c> or
|
| 324 |
|
|
<c>/etc/bluetooth/pin-helper</c> among others.
|
| 325 |
|
|
</note>
|
| 326 |
|
|
|
| 327 |
|
|
<note>
|
| 328 |
|
|
Beginning with <c>>=bluez-libs-3.x</c> and <c>>=bluez-utils-3.x</c>, pin helpers
|
| 329 |
|
|
have been replaced by passkey agents. There are a few different graphical
|
| 330 |
|
|
passkey agents available to help manage your PIN, such as <c>bluez-gnome</c> and
|
| 331 |
|
|
<c>kdebluetooth</c>. You can also use <c>passkey-agent</c> (found in
|
| 332 |
|
|
<c>bluez-utils</c>) from the command line.
|
| 333 |
|
|
</note>
|
| 334 |
|
|
|
| 335 |
fox2mike |
1.1 |
</body>
|
| 336 |
|
|
</section>
|
| 337 |
|
|
<section>
|
| 338 |
|
|
<title>Services configuration</title>
|
| 339 |
|
|
<body>
|
| 340 |
|
|
|
| 341 |
|
|
<p>
|
| 342 |
|
|
Now that we have concluded with the configuration of BlueZ, it's time to restart
|
| 343 |
|
|
the necessary services.
|
| 344 |
|
|
</p>
|
| 345 |
|
|
|
| 346 |
|
|
<pre caption="Starting the Bluetooth daemons">
|
| 347 |
|
|
# <i>/etc/init.d/bluetooth restart</i>
|
| 348 |
|
|
<comment>(We can also add it to the default runlevel.)</comment>
|
| 349 |
|
|
# <i>rc-update add bluetooth default</i>
|
| 350 |
|
|
* bluetooth added to runlevel default
|
| 351 |
|
|
* rc-update complete.
|
| 352 |
|
|
</pre>
|
| 353 |
|
|
|
| 354 |
|
|
<p>
|
| 355 |
|
|
Let's be sure that the Bluetooth daemons started correctly. If we can see that
|
| 356 |
|
|
both <c>hcid</c> and <c>sdpd</c> are running, then we configured Bluetooth the
|
| 357 |
yoswink |
1.4 |
right way. After that, we can see if the devices are now up and running with
|
| 358 |
fox2mike |
1.1 |
the configured options.
|
| 359 |
|
|
</p>
|
| 360 |
|
|
|
| 361 |
swift |
1.2 |
<pre caption="Checking whether Bluetooth daemons started correctly">
|
| 362 |
fox2mike |
1.1 |
<comment>(Check to see if the services are running)</comment>
|
| 363 |
|
|
# <i>ps -ae | grep hcid</i>
|
| 364 |
|
|
26050 ? 00:00:00 hcid
|
| 365 |
|
|
# <i>ps -ae | grep sdpd</i>
|
| 366 |
|
|
26054 ? 00:00:00 sdpd
|
| 367 |
|
|
|
| 368 |
|
|
# <i>hciconfig -a</i>
|
| 369 |
|
|
hci0: Type: USB
|
| 370 |
|
|
BD Address: 00:0A:0B:0C:0D:0E ACL MTU: 192:8 SCO MTU: 64:8
|
| 371 |
neysx |
1.6 |
UP RUNNING PSCAN ISCAN
|
| 372 |
fox2mike |
1.1 |
RX bytes:125 acl:0 sco:0 events:17 errors:0
|
| 373 |
|
|
TX bytes:565 acl:0 sco:0 commands:17 errors:0
|
| 374 |
|
|
Features: 0xff 0xff 0x0f 0x00 0x00 0x00 0x00 0x00
|
| 375 |
|
|
Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
|
| 376 |
|
|
Link policy: RSWITCH HOLD SNIFF PARK
|
| 377 |
|
|
Link mode: SLAVE ACCEPT
|
| 378 |
|
|
Name: 'BlueZ at bluehat (0)'
|
| 379 |
|
|
Class: 0x3e0100
|
| 380 |
|
|
Service Classes: Networking, Rendering, Capturing, Object Transfer,
|
| 381 |
|
|
Audio
|
| 382 |
|
|
Device Class: Computer, Uncategorized
|
| 383 |
|
|
HCI Ver: 1.1 (0x1) HCI Rev: 0x1e7 LMP Ver: 1.1 (0x1) LMP Subver: 0x1e7
|
| 384 |
|
|
Manufacturer: Cambridge Silicon Radio (10)
|
| 385 |
|
|
</pre>
|
| 386 |
|
|
|
| 387 |
|
|
</body>
|
| 388 |
|
|
</section>
|
| 389 |
|
|
</chapter>
|
| 390 |
|
|
|
| 391 |
|
|
<chapter id="detect">
|
| 392 |
|
|
<title>Detecting and Connecting to Remote Devices</title>
|
| 393 |
|
|
<section>
|
| 394 |
|
|
<title>Detecting Bluetooth devices in other hosts</title>
|
| 395 |
|
|
<body>
|
| 396 |
|
|
|
| 397 |
|
|
<p>
|
| 398 |
|
|
At this point we are now ready to detect Bluetooth devices installed in other
|
| 399 |
|
|
machines. This is independent of the host Operating System. We will make use of
|
| 400 |
|
|
the <c>hcitool</c> command for the same.
|
| 401 |
|
|
</p>
|
| 402 |
|
|
|
| 403 |
|
|
<pre caption="Checking for local devices">
|
| 404 |
|
|
# <i>hcitool dev</i>
|
| 405 |
|
|
Devices:
|
| 406 |
|
|
hci0 00:01:02:03:04:05
|
| 407 |
|
|
</pre>
|
| 408 |
|
|
|
| 409 |
|
|
<pre caption="Scanning for remote devices">
|
| 410 |
|
|
# <i>hcitool scan</i>
|
| 411 |
|
|
Scanning ...
|
| 412 |
neysx |
1.3 |
00:0A:0B:0C:0D:0E Grayhat
|
| 413 |
fox2mike |
1.1 |
</pre>
|
| 414 |
|
|
|
| 415 |
|
|
<pre caption="Inquiring remote devices">
|
| 416 |
|
|
# <i>hcitool inq</i>
|
| 417 |
|
|
Inquiring ...
|
| 418 |
neysx |
1.3 |
00:0A:0B:0C:0D:0E clock offset: 0x5579 class: 0x72010c
|
| 419 |
fox2mike |
1.1 |
</pre>
|
| 420 |
|
|
|
| 421 |
|
|
<p>
|
| 422 |
yoswink |
1.4 |
Now that we know the MAC address of the remote Bluetooth devices, we can check
|
| 423 |
fox2mike |
1.1 |
if we paired them correctly.
|
| 424 |
|
|
</p>
|
| 425 |
|
|
|
| 426 |
|
|
<pre caption="Running l2ping">
|
| 427 |
|
|
# <i>l2ping 00:0A:0B:0C:0D:0E</i>
|
| 428 |
|
|
Ping: 00:0A:0B:0C:0D:0E from 00:01:02:03:04:05 (data size 20) ...
|
| 429 |
|
|
20 bytes from 00:0A:0B:0C:0D:0E id 200 time 69.85ms
|
| 430 |
|
|
20 bytes from 00:0A:0B:0C:0D:0E id 201 time 9.97ms
|
| 431 |
|
|
20 bytes from 00:0A:0B:0C:0D:0E id 202 time 56.86ms
|
| 432 |
|
|
20 bytes from 00:0A:0B:0C:0D:0E id 203 time 39.92ms
|
| 433 |
neysx |
1.3 |
4 sent, 4 received, 0% loss
|
| 434 |
fox2mike |
1.1 |
</pre>
|
| 435 |
|
|
|
| 436 |
|
|
</body>
|
| 437 |
|
|
</section>
|
| 438 |
|
|
<section>
|
| 439 |
|
|
<title>Setting up Radio Frequency Communication (RFCOMM)</title>
|
| 440 |
|
|
<body>
|
| 441 |
|
|
|
| 442 |
|
|
<note>
|
| 443 |
|
|
Please note that setting up radio frequency communication is optional.
|
| 444 |
|
|
</note>
|
| 445 |
|
|
|
| 446 |
|
|
<p>
|
| 447 |
|
|
We can establish a radio frequency connection to another Bluetooth device using
|
| 448 |
|
|
the <c>rfcomm</c> command. To make things a little easier especially for users
|
| 449 |
|
|
with multiple devices that support Bluetooth, it is advisable to make a few
|
| 450 |
|
|
changes to the default rfcomm config at <path>/etc/bluetooth/rfcomm.conf</path>.
|
| 451 |
|
|
</p>
|
| 452 |
|
|
|
| 453 |
|
|
<p>
|
| 454 |
|
|
The whole segment of the config starting from <c>rfcomm0 {</c> and ending with
|
| 455 |
|
|
<c>}</c> is the config for the device that will establish a connection at
|
| 456 |
|
|
<path>/dev/rfcomm0</path>. In this case, we will only show one example, rfcomm0.
|
| 457 |
|
|
You can add more devices as you see fit.
|
| 458 |
|
|
</p>
|
| 459 |
|
|
|
| 460 |
|
|
<pre caption="Editing /etc/bluetooth/rfcomm.conf">
|
| 461 |
|
|
<comment>(Only changes that might be needed are shown)</comment>
|
| 462 |
|
|
rfcomm0 {
|
| 463 |
|
|
# Automatically bind the device at startup
|
| 464 |
|
|
<comment>(Creates the device node, /dev/rfcomm0 at start up)</comment>
|
| 465 |
|
|
bind yes;
|
| 466 |
|
|
|
| 467 |
|
|
# Bluetooth address of the device
|
| 468 |
|
|
<comment>(Enter the address of the device you want to connect to)</comment>
|
| 469 |
|
|
device 00:0A:0B:0C:0D:0E;
|
| 470 |
|
|
|
| 471 |
neysx |
1.3 |
}
|
| 472 |
fox2mike |
1.1 |
</pre>
|
| 473 |
|
|
|
| 474 |
|
|
<p>
|
| 475 |
|
|
After configuring RFCOMM, we can connect to any device. Since we've made the
|
| 476 |
|
|
required settings to the <path>/etc/bluetooth/rfcomm.conf</path> file, we just
|
| 477 |
|
|
issue the command shown below. In case you've not made changes to the config
|
| 478 |
|
|
file, an alternative method is also shown in the code listing that follows
|
| 479 |
|
|
</p>
|
| 480 |
|
|
|
| 481 |
|
|
<pre caption="Establishing an RFCOMM connection">
|
| 482 |
|
|
<comment>(The 0 refers to the rfcomm0 in the config file)</comment>
|
| 483 |
|
|
# <i>rfcomm connect 0 </i>
|
| 484 |
|
|
Connected /dev/rfcomm0 to 00:0A:0B:0C:0D:0E on channel 1
|
| 485 |
|
|
Press CTRL-C for hangup
|
| 486 |
|
|
|
| 487 |
|
|
<comment>(If you did not edit /etc/bluetooth/rfcomm.conf)</comment>
|
| 488 |
|
|
# <i>rfcomm connect 0 00:0A:0B:0C:0D:0E 1</i>
|
| 489 |
|
|
Connected /dev/rfcomm0 to 00:0F:DE:69:50:24 on channel 1
|
| 490 |
|
|
Press CTRL-C for hangup
|
| 491 |
|
|
</pre>
|
| 492 |
|
|
|
| 493 |
|
|
<p>
|
| 494 |
|
|
The first parameter after the connect command is the RFCOMM TTY device node
|
| 495 |
|
|
that will be used (usually 0). The second parameter is the MAC address of the
|
| 496 |
|
|
remote device. The third parameter is optional and specifies the channel to be
|
| 497 |
|
|
used. Please, note that in order to connect to a device, that device must be
|
| 498 |
|
|
listening for incoming connections. To do that, we have to explicitly tell it
|
| 499 |
|
|
to listen. We can cancel the communication at any moment by just hitting
|
| 500 |
|
|
CTRL+C.
|
| 501 |
|
|
</p>
|
| 502 |
|
|
|
| 503 |
|
|
<pre caption="Listening for incoming RFCOMM connections">
|
| 504 |
|
|
# <i>rfcomm listen 0 1</i>
|
| 505 |
neysx |
1.3 |
Waiting for connection on channel 1
|
| 506 |
fox2mike |
1.1 |
</pre>
|
| 507 |
|
|
|
| 508 |
|
|
<p>
|
| 509 |
|
|
In a similar way to the connect command, the listen command can receive two
|
| 510 |
|
|
parameters. The first one explicits the RFCOMM TTY device node (usually 0) that
|
| 511 |
|
|
will be used to accept a connection, while the second is the channel that will
|
| 512 |
neysx |
1.3 |
be used.
|
| 513 |
fox2mike |
1.1 |
</p>
|
| 514 |
|
|
|
| 515 |
|
|
<p>
|
| 516 |
|
|
Each time you call the <c>rfcomm</c> command, you can also specify the physical
|
| 517 |
|
|
device you want to use. Below you can see a small example specifiying the
|
| 518 |
|
|
physical device on the above two commands.
|
| 519 |
|
|
</p>
|
| 520 |
|
|
|
| 521 |
|
|
<pre caption="RFCOMM connections specifying physical device">
|
| 522 |
|
|
# <i>rfcomm -i hci0 listen 0 1</i>
|
| 523 |
|
|
Waiting for connection on channel 1
|
| 524 |
|
|
<comment>(To listen to a determined device) </comment>
|
| 525 |
|
|
# <i>rfcomm -i hci0 connect 0 00:0A:0B:0C:0D:0E 1</i>
|
| 526 |
|
|
<comment>(To use a determined device when connecting to another one)</comment>
|
| 527 |
|
|
</pre>
|
| 528 |
|
|
|
| 529 |
|
|
</body>
|
| 530 |
|
|
</section>
|
| 531 |
|
|
<section>
|
| 532 |
|
|
<title>Setting up a Personal Area Network (PAN)</title>
|
| 533 |
|
|
<body>
|
| 534 |
|
|
|
| 535 |
|
|
<note>
|
| 536 |
|
|
Please note that setting up a Personal Area Network is optional. This section
|
| 537 |
|
|
describes how to set up and connect to a Network Access Point, though setting
|
| 538 |
|
|
up a Group Ad-Hoc Network follows a similar way.
|
| 539 |
|
|
</note>
|
| 540 |
|
|
|
| 541 |
|
|
<p>
|
| 542 |
|
|
First of all, we need the <c>bnep</c> module loaded. And probably we want it
|
| 543 |
|
|
loaded each time the computer starts.
|
| 544 |
|
|
</p>
|
| 545 |
|
|
|
| 546 |
|
|
<pre caption="Loading the bnep module">
|
| 547 |
|
|
# <i>modprobe bnep</i>
|
| 548 |
|
|
# <i>echo "bnep" >> /etc/modules.autoload.d/kernel-2.6</i>
|
| 549 |
|
|
</pre>
|
| 550 |
|
|
|
| 551 |
|
|
<p>
|
| 552 |
|
|
We have to start the <c>pand</c> daemon in the host that will provide the NAP.
|
| 553 |
|
|
We'll have to specify that we want to provide a NAP service and that this host
|
| 554 |
|
|
will be the master, thus the other hosts that connect to it, the slaves.
|
| 555 |
|
|
Another possible service is GN (Group ad-hoc Network).
|
| 556 |
|
|
</p>
|
| 557 |
|
|
|
| 558 |
|
|
<pre caption="Running the pand daemon">
|
| 559 |
|
|
# <i>pand --listen --role NAP --master --autozap</i>
|
| 560 |
|
|
</pre>
|
| 561 |
|
|
|
| 562 |
|
|
<p>
|
| 563 |
|
|
After doing that, we have a host listening, so the rest of hosts just have to
|
| 564 |
|
|
connect to that one.
|
| 565 |
|
|
</p>
|
| 566 |
|
|
|
| 567 |
|
|
<pre caption="Connecting to the Network Access Point">
|
| 568 |
|
|
# <i>pand --connect 00:0A:0B:0C:0D:0E --service NAP --autozap</i>
|
| 569 |
|
|
</pre>
|
| 570 |
|
|
|
| 571 |
|
|
<p>
|
| 572 |
|
|
If everything went fine, we can now configure the IP addresses of our hosts.
|
| 573 |
|
|
</p>
|
| 574 |
|
|
|
| 575 |
|
|
<pre caption="bnep IP address configuration">
|
| 576 |
|
|
host0 #<i> ifconfig bnep0 192.168.2.1</i>
|
| 577 |
|
|
host1 #<i> ifconfig bnep0 192.168.2.2</i>
|
| 578 |
|
|
|
| 579 |
|
|
host0 #<i> ifconfig bnep0</i>
|
| 580 |
neysx |
1.3 |
bnep0 Link encap:Ethernet HWaddr 00:0A:0B:0C:0D:0E
|
| 581 |
fox2mike |
1.1 |
inet addr:192.168.2.1 Bcast:192.168.2.255 Mask:255.255.255.0
|
| 582 |
|
|
inet6 addr: fe80::210:60ff:fea3:cb41/64 Scope:Link
|
| 583 |
|
|
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
|
| 584 |
|
|
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
|
| 585 |
|
|
TX packets:5 errors:0 dropped:0 overruns:0 carrier:0
|
| 586 |
|
|
collisions:0 txqueuelen:1000
|
| 587 |
|
|
RX bytes:208 (208.0 b) TX bytes:188 (188.0 b)
|
| 588 |
|
|
|
| 589 |
|
|
host1 #<i> ifconfig bnep0</i>
|
| 590 |
neysx |
1.3 |
bnep0 Link encap:Ethernet HWaddr 00:01:02:03:04:05
|
| 591 |
fox2mike |
1.1 |
inet addr:192.168.2.2 Bcast:192.168.2.255 Mask:255.255.255.0
|
| 592 |
|
|
inet6 addr: fe80::210:60ff:fea2:dd2a/64 Scope:Link
|
| 593 |
|
|
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
|
| 594 |
|
|
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
|
| 595 |
|
|
TX packets:5 errors:0 dropped:0 overruns:0 carrier:0
|
| 596 |
|
|
collisions:0 txqueuelen:1000
|
| 597 |
|
|
RX bytes:208 (208.0 b) TX bytes:188 (188.0 b)
|
| 598 |
|
|
</pre>
|
| 599 |
|
|
|
| 600 |
|
|
<p>
|
| 601 |
|
|
Finally, we can do a simple test to see that the network is working fine.
|
| 602 |
|
|
</p>
|
| 603 |
|
|
|
| 604 |
|
|
<pre caption="IP ping between bnep interfaces">
|
| 605 |
|
|
host1 #<i> ping 192.168.2.1</i>
|
| 606 |
|
|
PING 192.168.2.1 (192.168.2.1) 56(84) bytes of data.
|
| 607 |
|
|
64 bytes from 192.168.2.1: icmp_seq=1 ttl=64 time=34.0 ms
|
| 608 |
|
|
64 bytes from 192.168.2.1: icmp_seq=2 ttl=64 time=37.3 ms
|
| 609 |
|
|
|
| 610 |
|
|
--- 192.168.2.1 ping statistics ---
|
| 611 |
|
|
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
|
| 612 |
neysx |
1.3 |
rtt min/avg/max/mdev = 34.045/35.690/37.336/1.656 ms
|
| 613 |
fox2mike |
1.1 |
</pre>
|
| 614 |
|
|
|
| 615 |
|
|
</body>
|
| 616 |
|
|
</section>
|
| 617 |
|
|
</chapter>
|
| 618 |
|
|
|
| 619 |
|
|
<chapter id="apps">
|
| 620 |
|
|
<title>Desktop Applications for Bluetooth</title>
|
| 621 |
|
|
<section>
|
| 622 |
|
|
<title>Introduction</title>
|
| 623 |
|
|
<body>
|
| 624 |
|
|
|
| 625 |
|
|
<p>
|
| 626 |
|
|
We have quite a few Bluetooth applications that run on the desktop and this
|
| 627 |
|
|
chapter has been divided into 3 parts, one each for Gnome, KDE and Miscellaneous
|
| 628 |
|
|
applications.
|
| 629 |
|
|
</p>
|
| 630 |
|
|
|
| 631 |
|
|
</body>
|
| 632 |
|
|
</section>
|
| 633 |
|
|
<section>
|
| 634 |
|
|
<title>For Gnome</title>
|
| 635 |
|
|
<body>
|
| 636 |
|
|
|
| 637 |
|
|
<p>
|
| 638 |
|
|
If you are a gnome user, you will most probably go with <c>gnome-bluetooth</c>.
|
| 639 |
|
|
It provides the most basic yet most used functionalities, as you can see below.
|
| 640 |
|
|
</p>
|
| 641 |
|
|
|
| 642 |
|
|
<ul>
|
| 643 |
|
|
<li><c>gnome-bluetooth-manager</c>: To manage Bluetooth remote devices.</li>
|
| 644 |
|
|
<li><c>gnome-obex-send</c>: To send files to other devices.</li>
|
| 645 |
|
|
<li><c>gnome-obex-server</c>: To receive files.</li>
|
| 646 |
|
|
</ul>
|
| 647 |
|
|
|
| 648 |
|
|
<pre caption="Installing gnome-bluetooth">
|
| 649 |
|
|
# <i>emerge gnome-bluetooth</i>
|
| 650 |
|
|
</pre>
|
| 651 |
|
|
|
| 652 |
|
|
<p>
|
| 653 |
|
|
This adds menu entries under Applications > System Tools from where you can
|
| 654 |
|
|
easily start up the manager or File sharing to transfer files between devices.
|
| 655 |
|
|
</p>
|
| 656 |
|
|
|
| 657 |
|
|
<p>
|
| 658 |
neysx |
1.3 |
To transfer files (the easy way):
|
| 659 |
fox2mike |
1.1 |
</p>
|
| 660 |
|
|
|
| 661 |
|
|
<ul>
|
| 662 |
|
|
<li>
|
| 663 |
|
|
From the Phone to the Computer - Send the file from the phone via Bluetooth
|
| 664 |
|
|
and it will be picked up and saved to your <path>/home</path> always.
|
| 665 |
|
|
</li>
|
| 666 |
|
|
<!--FIXME : Doesn't work on Nautilus 2.10.x. Bug #103464 for details -->
|
| 667 |
|
|
<!--
|
| 668 |
|
|
<li>
|
| 669 |
|
|
From the Computer to the Phone - Fire up <c>nautilus</c> and select the
|
| 670 |
|
|
file you want to send and right click on it. Select the Send via Bluetooth
|
| 671 |
|
|
option and ask your phone to accept the file.
|
| 672 |
|
|
</li>
|
| 673 |
|
|
-->
|
| 674 |
|
|
</ul>
|
| 675 |
|
|
|
| 676 |
|
|
<p>
|
| 677 |
|
|
<c>gnome-phone-manager</c> is a nifty app that you can use to send and receive
|
| 678 |
|
|
messages to and from your phone, using only your system. You do not have to
|
| 679 |
|
|
touch your phone to read or send messages since all that happens through the
|
| 680 |
|
|
application. You are also notified of a new message on your screen if the option
|
| 681 |
|
|
is enabled under Preferences. Installation is a breeze as always.
|
| 682 |
|
|
</p>
|
| 683 |
|
|
|
| 684 |
|
|
<pre caption="Installing gnome-phone-manager">
|
| 685 |
|
|
# <i>emerge gnome-phone-manager</i>
|
| 686 |
|
|
</pre>
|
| 687 |
|
|
|
| 688 |
|
|
</body>
|
| 689 |
|
|
</section>
|
| 690 |
|
|
<section>
|
| 691 |
|
|
<title>For KDE</title>
|
| 692 |
|
|
<body>
|
| 693 |
|
|
|
| 694 |
|
|
<p>
|
| 695 |
|
|
KDE makes use of <c>kdebluetooth</c> and provides more utilities than its Gnome
|
| 696 |
|
|
counterpart as seen below.
|
| 697 |
|
|
</p>
|
| 698 |
|
|
|
| 699 |
|
|
<ul>
|
| 700 |
|
|
<li><c>kbluetoothd</c>: Bluetooth Meta Server.</li>
|
| 701 |
|
|
<li><c>kbtsearch</c>: Bluetooth device/service search utility.</li>
|
| 702 |
|
|
<li><c>khciconfig</c>: KDE Bluetooth Monitor.</li>
|
| 703 |
|
|
<li><c>kioclient</c>: KIO command line client.</li>
|
| 704 |
|
|
<li><c>qobexclient</c>: Swiss army knife for obex testing/development.</li>
|
| 705 |
|
|
<li><c>kbtobexclient</c>: A KDE Bluetooth Framework Application.</li>
|
| 706 |
|
|
<li><c>kioobex_start</c></li>
|
| 707 |
|
|
<li><c>kbtserialchat</c></li>
|
| 708 |
|
|
<li><c>kbemusedsrv</c>: KDE Bemused Server.</li>
|
| 709 |
|
|
<li><c>kbtobexsrv</c>: KDE OBEX Push Server for Bluetooth.</li>
|
| 710 |
|
|
<li><c>kbluepin</c>: A KDE KPart Application.</li>
|
| 711 |
|
|
<li>
|
| 712 |
|
|
<c>auth-helper</c>: A helper program for kbtobexsrv that sends an
|
| 713 |
|
|
authentication request for a given ACL link.
|
| 714 |
|
|
</li>
|
| 715 |
|
|
</ul>
|
| 716 |
|
|
|
| 717 |
|
|
<pre caption="Installing kdebluetooth">
|
| 718 |
|
|
# <i>emerge kdebluetooth</i>
|
| 719 |
|
|
</pre>
|
| 720 |
|
|
|
| 721 |
|
|
</body>
|
| 722 |
|
|
</section>
|
| 723 |
|
|
<section>
|
| 724 |
|
|
<title>Other Interesting Applications</title>
|
| 725 |
|
|
<body>
|
| 726 |
|
|
|
| 727 |
|
|
<ul>
|
| 728 |
|
|
<li>
|
| 729 |
|
|
<c>app-mobilephone/obexftp</c>: File transfer over OBEX for mobile phones
|
| 730 |
|
|
</li>
|
| 731 |
|
|
<li>
|
| 732 |
|
|
<c>app-mobilephone/bemused</c>: Bemused is a system which allows you to
|
| 733 |
|
|
control your music collection from your phone, using Bluetooth.
|
| 734 |
|
|
</li>
|
| 735 |
|
|
<li>
|
| 736 |
|
|
<c>app-pda/multisync</c>: Multisync allows you to sync contacts, calendar
|
| 737 |
|
|
entries and notes from your mobile phone with your computer, over a
|
| 738 |
|
|
Bluetooth connection (amongst other things). It includes such features as
|
| 739 |
|
|
backing up this information and restoring it later, and syncing with the
|
| 740 |
|
|
Evolution e-mail client. You will need the <c>irmc</c> USE flag set to
|
| 741 |
|
|
ensure that <c>multisync</c> has Bluetooth support.
|
| 742 |
|
|
</li>
|
| 743 |
nightmorph |
1.10 |
<li>
|
| 744 |
|
|
<c>net-wireless/opd</c> and <c>net-wireless/ussp-push</c> are command line
|
| 745 |
|
|
tools (server and client) that can be used to send files to your mobile
|
| 746 |
|
|
phone.
|
| 747 |
|
|
</li>
|
| 748 |
fox2mike |
1.1 |
</ul>
|
| 749 |
|
|
|
| 750 |
|
|
</body>
|
| 751 |
|
|
</section>
|
| 752 |
|
|
</chapter>
|
| 753 |
|
|
|
| 754 |
|
|
<chapter>
|
| 755 |
|
|
<title>Acknowledgements</title>
|
| 756 |
|
|
<section>
|
| 757 |
|
|
<body>
|
| 758 |
|
|
|
| 759 |
|
|
<p>
|
| 760 |
|
|
Special thanks to <mail link="marcel@holtmann.org">Marcel Holtmann</mail>
|
| 761 |
|
|
for his time and dedication to the Bluetooth development and for reviewing this
|
| 762 |
|
|
guide. And big thanks to <mail link="puggy@gentoo.org">Douglas Russell</mail>
|
| 763 |
|
|
for performing additional hardware tests and improving this guide.
|
| 764 |
|
|
</p>
|
| 765 |
|
|
|
| 766 |
|
|
</body>
|
| 767 |
|
|
</section>
|
| 768 |
|
|
</chapter>
|
| 769 |
|
|
</guide>
|