Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 286826 | Differences between
and this patch

Collapse All | Expand All

(-)bluetooth-guide.xml?revision=1.17.orig (-137 / +189 lines)
Lines 172-356 Link Here
172
<chapter id="bluez">
172
<chapter id="bluez">
173
<title>BlueZ - The Bluetooth Stack</title>
173
<title>BlueZ - The Bluetooth Stack</title>
174
<section>
174
<section>
175
<title>Installing BlueZ</title>
175
<title>What is BlueZ?</title>
176
<body>
176
<body>
177
177
178
<p>
178
<p>
179
Now that the device is detected by the kernel, we need a layer that lets
179
Now that the device is detected by the kernel, we need a layer that lets
180
applications communicate with the Bluetooth device. BlueZ provides the official
180
applications communicate with the Bluetooth device. BlueZ provides the official
181
Linux Bluetooth stack. The ebuilds that provide what we need are
181
Linux Bluetooth stack. The ebuild that provides what we need is
182
<c>bluez-libs</c> and <c>bluez-utils</c>. Devices that need Broadcom firmware
182
<c>bluez</c>. Devices that need Broadcom firmware 
183
files or the like may need <c>bluez-firmware</c>.
183
files or the like may need <c>bluez-firmware</c>.
184
</p>
184
</p>
185
</body>
186
</section>
187
188
<section>
189
<title>BlueZ permission control</title>
190
191
<body>
192
193
<p>
194
Before installing, it is a good idea to choose how to control users' ability to
195
use bluetooth.
196
</p>
197
198
<p>
199
There are two methods:
200
</p>
201
202
<ul>
203
<!-- This needs to be clarified. This is what I think
204
consolekit is, but I don't use it. -->
205
  <li>"consolekit": identifies users who are sat in front of the computer,
206
  and grants them access;</li>
207
  <li>"plugdev": allows members of the plugdev group to use bluetooth</li>
208
</ul>
209
210
<p>
211
Although the permission policy can be tuned by editing the dbus permission rules
212
for <c>bluez</c>, the <c>consolekit</c> USE flag must be set accordingly
213
</p>
214
215
<ul>
216
  <li><c>consolekit</c> &mdash; means the consolekit method is used and requires
217
  it to be enabled in some dependencies</li>
218
  <li><c>-consolekit</c> &mdash; selects the plugdev method, and does not
219
  require any consolekit support in dependencies.</li>
220
</ul>
221
222
</body>
223
</section>
224
225
<section>
226
<title>Installing bluez</title>
227
228
<body>
229
230
<p>
231
Now we can install the package, using the following command.
232
</p>
185
233
186
<pre caption="Installing bluez-libs and bluez-utils">
234
<pre caption="Installing bluez">
187
# <i>emerge net-wireless/bluez-libs net-wireless/bluez-utils</i>
235
# <i>emerge net-wireless/bluez</i>
188
</pre>
236
</pre>
189
237
238
<p>
239
This ebuild might require certain USE flags to be enabled for other ebuilds:
240
</p>
241
242
<ul>
243
  <li><c>sys-fs/udev</c> must have the <c>extras</c> flag enabled</li>
244
  <li>When <c>bluez</c> is built with <c>consolekit</c> enabled (see above),
245
  <c>sys-auth/pambase</c> must have it enabled too.</li>
246
</ul>
247
248
<p>
249
Now the bluetooth stack is completely installed, but you need other tools to do
250
anything useful with it.
251
</p>
252
253
<p>
254
You can get some tools enabling the <c>test-programs</c> USE flag
255
for <c>bluez</c>, which will install some testing utilities. But this is a
256
limited set of tools, mainly intended for testing &mdash; you probably want to
257
install an external bluetooth utilities package.
258
</p>
190
</body>
259
</body>
191
</section>
260
</section>
261
192
<section>
262
<section>
193
<title>BlueZ configuration and PIN pairing</title>
263
<title>Start BlueZ</title>
194
<body>
264
<body>
195
265
196
<p>
266
<p>
197
Now it's time to see if the Bluetooth device is being picked up correctly by the
267
Now it's time to see if the Bluetooth device is being picked up correctly by the
198
system. We start up the required Bluetooth services first.
268
system. We start up the required Bluetooth services first. (It may have been
269
started when you plugged the device, if it uses some hotpluggable interface
270
(like USB).)
199
</p>
271
</p>
200
272
201
<pre caption="Running hciconfig">
273
<pre caption="Running hciconfig">
202
<comment>(Start up Bluetooth)</comment>
274
<comment>(Start up Bluetooth)</comment>
203
# <i>/etc/init.d/bluetooth start</i>
275
# <i>/etc/init.d/bluetooth start</i>
204
* Starting Bluetooth ...
276
* Starting Bluetooth ...
205
*     Starting hcid ...                                                 [ ok ]
206
*     Starting sdpd ...                                                 [ ok ]
207
*     Starting rfcomm ...                                               [ ok ]
277
*     Starting rfcomm ...                                               [ ok ]
208
278
209
# <i>hciconfig</i>
279
# <i>hciconfig</i>
210
hci0:   Type: USB
280
hci0:   Type: USB
211
        BD Address: 00:01:02:03:04:05 ACL MTU: 192:8  SCO MTU: 64:8
281
        BD Address: 00:01:02:03:04:05 ACL MTU: 192:8  SCO MTU: 64:8
212
        DOWN
282
        UP RUNNING PSCAN
213
        RX bytes:131 acl:0 sco:0 events:18 errors:0
283
        RX bytes:131 acl:0 sco:0 events:18 errors:0
214
        TX bytes:565 acl:0 sco:0 commands:17 errors:0
284
        TX bytes:565 acl:0 sco:0 commands:17 errors:0
215
</pre>
285
</pre>
216
286
217
<p>
287
<p>If BlueZ is not started when the device is detected and you use
218
This shows that the Bluetooth device has been recognised. As you might have
288
bluetooth frequenty, you may want to add it to the default runlevel,
219
noticed the device is <e>DOWN</e>. Let's configure it so that we can bring it
289
so that it starts automatically on boot. To do that, use
220
up. The configuration file is at <path>/etc/bluetooth/hcid.conf</path>. The
290
<c>rc-update</c>.</p>
221
required changes to the config file are shown below. For additional details
222
please refer to <c>man hcid.conf</c>.
223
</p>
224
225
<pre caption="Editing /etc/bluetooth/hcid.conf">
226
<comment>(Recommended changes to be made to the file are shown)</comment>
227
228
# HCId options
229
options {
230
        # Automatically initialize new devices
231
        autoinit yes;
232
233
<comment>(Change security to "auto")</comment>
234
        # Security Manager mode
235
        #   none - Security manager disabled
236
        #   auto - Use local PIN for incoming connections
237
        #   user - Always ask user for a PIN
238
        #
239
        security auto;
240
241
        # Pairing mode
242
        pairing multi;
243
244
<comment>(You only need a pin helper if you are using &lt;=bluez-libs-2.x and &lt;=bluez-utils-2.x)
245
(Change pin_helper to use /etc/bluetooth/pin-helper)</comment>
246
        # PIN helper
247
        pin_helper /etc/bluetooth/pin-helper;
248
}
249
250
# Default settings for HCI devices
251
device {
252
<comment>(Set your device name here, you can call it anything you want)</comment>
253
        # Local device name
254
        #   %d - device id
255
        #   %h - host name
256
        name "BlueZ at %h (%d)";
257
258
        # Local device class
259
        class 0x3e0100;
260
261
        # Inquiry and Page scan
262
        iscan enable; pscan enable;
263
264
        # Default link mode
265
        lm accept;
266
267
        # Default link policy
268
        lp rswitch,hold,sniff,park;
269
270
<comment>(Leave as is, if you don't know what exactly these do)</comment>
271
        # Authentication and Encryption (Security Mode 3)
272
        #auth enable;
273
        #encrypt enable;
274
}
275
</pre>
276
277
<p>
278
After that, we have to configure the Bluetooth device PIN. That will help in
279
pairing this device with another one.
280
</p>
281
291
282
<pre caption="Editing /etc/bluetooth/pin">
292
<pre caption="Automatically start bluetooth on boot">
283
<comment>(Replace 123456 with your desired pin number.)</comment>
293
<comment>(We can also add it to the default runlevel.)</comment>
284
123456
294
# <i>rc-update add bluetooth default</i>
295
 * bluetooth added to runlevel default
285
</pre>
296
</pre>
286
297
287
<impo>
288
This number (of your choice) must be the same in all your hosts with Bluetooth
289
devices so they can be paired. This number must also be kept secret since anyone
290
with knowledge of this number can essentially establish connections with your
291
devices.
292
</impo>
293
294
<note>
295
Beginning with <c>>=bluez-libs-3.x</c> and <c>>=bluez-utils-3.x</c>, pin helpers
296
have been replaced by passkey agents. There are a few different graphical
297
passkey agents available to help manage your PIN, such as <c>bluez-gnome</c> and
298
<c>kdebluetooth</c>. You can also use <c>passkey-agent</c> (found in
299
<c>bluez-utils</c>) from the command line.
300
</note>
301
302
</body>
298
</body>
303
</section>
299
</section>
300
304
<section>
301
<section>
305
<title>Services configuration</title>
302
<title>PIN Pairing</title>
306
<body>
303
<body>
307
304
308
<p>
305
<p>
309
Now that we have concluded with the configuration of BlueZ, it's time to restart
306
In <c>=bluez-4</c>, there is no global PIN &mdash; when a device is paired you
310
the necessary services.
307
need some bluetooth utility to input a PIN. One such utility
308
is <c>simple-agent</c>, part of bluez testing utilities (when built
309
with <c>USE="test-programs"</c>).
311
</p>
310
</p>
312
311
313
<pre caption="Starting the Bluetooth daemons">
312
<p>
314
# <i>/etc/init.d/bluetooth restart</i>
313
Before pairing, you must know the bluetooth adapter id
315
<comment>(We can also add it to the default runlevel.)</comment>
314
(run <c>/usr/sbin/hciconfig</c>, if you have several adapters, you need to
316
# <i>rc-update add bluetooth default</i>
315
choose which one you want to pair.
317
 * bluetooth added to runlevel default
316
</p>
318
 * rc-update complete.
319
</pre>
320
317
321
<p>
318
<p>
322
Let's be sure that the Bluetooth daemons started correctly. If we can see that
319
<!-- Does it work with friendly names too? -->
323
both <c>hcid</c> and <c>sdpd</c> are running, then we configured Bluetooth the
320
You also need the MAC address of the device you want to pair with the
324
right way. After that, we can see if the devices are now up and running with
321
adapter. Some devices have this written in some label, others don't. To find it
325
the configured options.
322
out, make the device visible and run <c>hcitool scan</c> &mdash; the result is a
323
list of devices, with their friendly names and MAC addresses.
326
</p>
324
</p>
327
325
328
<pre caption="Checking whether Bluetooth daemons started correctly">
326
<pre caption="pairing with simple-agent">
329
<comment>(Check to see if the services are running)</comment>
327
  <comment>Find the MAC address:</comment>
330
# <i>ps -ae | grep hcid</i>
328
$ hcitool scan
331
26050 ?        00:00:00 hcid
329
Scanning ...
332
# <i>ps -ae | grep sdpd</i>
330
	05:04:03:02:01:00	friendly-name
333
26054 ?        00:00:00 sdpd
334
331
335
# <i>hciconfig -a</i>
332
  <comment>Find the adapter ID:</comment>
333
$ /usr/sbin/hciconfig
336
hci0:   Type: USB
334
hci0:   Type: USB
337
        BD Address: 00:0A:0B:0C:0D:0E ACL MTU: 192:8 SCO MTU: 64:8
335
        BD Address: 00:01:02:03:04:05 ACL MTU: 192:8  SCO MTU: 64:8
338
        UP RUNNING PSCAN ISCAN
336
        UP RUNNING PSCAN
339
        RX bytes:125 acl:0 sco:0 events:17 errors:0
337
        RX bytes:131 acl:0 sco:0 events:18 errors:0
340
        TX bytes:565 acl:0 sco:0 commands:17 errors:0
338
        TX bytes:565 acl:0 sco:0 commands:17 errors:0
341
        Features: 0xff 0xff 0x0f 0x00 0x00 0x00 0x00 0x00
339
342
        Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
340
  <comment>And then pair the device</comment>
343
        Link policy: RSWITCH HOLD SNIFF PARK
341
$ simple-agent hci0 05:04:03:02:01:00
344
        Link mode: SLAVE ACCEPT
342
RequestPinCode (/org/bluez/..../hci0/dev_05_04_03_02_01_00)
345
        Name: 'BlueZ at bluehat (0)'
343
Enter PIN Code: 1234
346
        Class: 0x3e0100
344
  <comment>(Now the remote device will ask you for this same PIN.)</comment>
347
        Service Classes: Networking, Rendering, Capturing, Object Transfer,
345
Release
348
        Audio
346
New device (/org/bluez/..../hci0/dev_05_04_03_02_01_00)
349
        Device Class: Computer, Uncategorized
350
        HCI Ver: 1.1 (0x1) HCI Rev: 0x1e7 LMP Ver: 1.1 (0x1) LMP Subver: 0x1e7
351
        Manufacturer: Cambridge Silicon Radio (10)
352
</pre>
347
</pre>
353
348
349
<p>
350
Other bluetooth packages might be able to handle pairing. This involves a tool
351
which initiates pairing or a tool which listens for pairing requests, or both.
352
<!-- Should this be developed to include instructions on how to do it
353
with other tools? -->
354
</p>
354
</body>
355
</body>
355
</section>
356
</section>
356
</chapter>
357
</chapter>
Lines 367-372 Link Here
367
the <c>hcitool</c> command for the same.
368
the <c>hcitool</c> command for the same.
368
</p>
369
</p>
369
370
371
<!-- some or ALL? -->
372
<note>
373
Some devices have a visibility setting, which if disabled will prevent
374
your device from detecting them.
375
</note>
376
377
370
<pre caption="Checking for local devices">
378
<pre caption="Checking for local devices">
371
# <i>hcitool dev</i>
379
# <i>hcitool dev</i>
372
Devices:
380
Devices:
Lines 391-397 Link Here
391
</p>
399
</p>
392
400
393
<pre caption="Running l2ping">
401
<pre caption="Running l2ping">
394
# <i>l2ping 00:0A:0B:0C:0D:0E</i>
402
# <i>l2ping 00:0A:0B:0C:0D:0E -c 4</i>
395
Ping: 00:0A:0B:0C:0D:0E from 00:01:02:03:04:05 (data size 20) ...
403
Ping: 00:0A:0B:0C:0D:0E from 00:01:02:03:04:05 (data size 20) ...
396
20 bytes from 00:0A:0B:0C:0D:0E id 200 time 69.85ms
404
20 bytes from 00:0A:0B:0C:0D:0E id 200 time 69.85ms
397
20 bytes from 00:0A:0B:0C:0D:0E id 201 time 9.97ms
405
20 bytes from 00:0A:0B:0C:0D:0E id 201 time 9.97ms
Lines 435-440 Link Here
435
        <comment>(Enter the address of the device you want to connect to)</comment>
443
        <comment>(Enter the address of the device you want to connect to)</comment>
436
        device 00:0A:0B:0C:0D:0E;
444
        device 00:0A:0B:0C:0D:0E;
437
445
446
        # RFCOMM channel for the connection
447
	<comment>(Optional. If not specified, it will use channel 1)</comment>
448
        channel 1;
449
438
}
450
}
439
</pre>
451
</pre>
440
452
Lines 480-485 Link Here
480
</p>
492
</p>
481
493
482
<p>
494
<p>
495
A bluetooth device may provide several services, on different
496
channels. To connect to those services using rfcomm, you need to find
497
out the right channel first. You can do that using <c>sdptool</c>,
498
part of bluez.<!-- always or depends on some USE? -->
499
</p>
500
501
<pre caption="Finding the right channel (Bluetooth Service Discovery)">
502
<comment>(The second parameter is the MAC address of the device you want to connect to)</comment>
503
$ sdptool browse 00:01:02:03:04:05
504
Browsing 00:01:02:03:04:05 ...
505
Service Name: OBEX Object Push
506
Service RecHandle: 0x10001
507
Service Class ID List:
508
  "OBEX Object Push" (0x1105)
509
Protocol Descriptor List:
510
  "L2CAP" (0x0100)
511
  "RFCOMM" (0x0003)
512
<comment>(So if you want to connect to OBEX Object Push, you would use channel 4)</comment>
513
    Channel: 4
514
  "OBEX" (0x0008)
515
Language Base Attr List:
516
  code_ISO639: 0x656e
517
  encoding:    0x6a
518
  base_offset: 0x100
519
Profile Descriptor List:
520
  "OBEX Object Push" (0x1105)
521
    Version: 0x0100
522
523
<comment>(Each service is described in lines like the ones above.)</comment>
524
Service Name: Serial Port
525
Service RecHandle: 0x10002
526
Service Class ID List:
527
<comment>...</comment>
528
</pre>
529
530
<p>
483
Each time you call the <c>rfcomm</c> command, you can also specify the physical
531
Each time you call the <c>rfcomm</c> command, you can also specify the physical
484
device you want to use. Below you can see a small example specifiying the
532
device you want to use. Below you can see a small example specifiying the
485
physical device on the above two commands.
533
physical device on the above two commands.
Lines 574-580 Link Here
574
<body>
622
<body>
575
623
576
<p>
624
<p>
577
KDE makes use of <c>kdebluetooth</c> and provides more utilities than its Gnome
625
KDE makes use of <c>kbluetooth</c> and provides more utilities than its Gnome
578
counterpart as seen below.
626
counterpart as seen below.
579
</p>
627
</p>
580
628
Lines 596-603 Link Here
596
  </li>
644
  </li>
597
</ul>
645
</ul>
598
646
599
<pre caption="Installing kdebluetooth">
647
<pre caption="Installing kbluetooth">
600
# <i>emerge kdebluetooth</i>
648
# <i>emerge kbluetooth</i>
601
</pre>
649
</pre>
602
650
603
</body>
651
</body>
Lines 608-626 Link Here
608
656
609
<ul>
657
<ul>
610
  <li>
658
  <li>
611
    <c>app-mobilephone/obexftp</c>: File transfer over OBEX for mobile phones
659
    <c>app-mobilephone/gnokii</c>: Program to access some features
660
    like SMS, calendar and address book. It is also able to set some
661
    phone settings, like its clock. Has graphical and commandline
662
    interfaces. You will need the <c>bluetooth</c> USE flag set to
663
    ensure that <c>gnokii</c> has Bluetooth support.
612
  </li>
664
  </li>
613
  <li>
665
  <li>
614
    <c>app-mobilephone/bemused</c>: Bemused is a system which allows you to
666
    <c>app-mobilephone/obexftp</c>: File transfer over OBEX for mobile phones. 
615
    control your music collection from your phone, using Bluetooth.
667
    You will need the <c>bluetooth</c> USE flag set to ensure
668
    that <c>obexftp</c> has Bluetooth support.
616
  </li>
669
  </li>
617
  <li>
670
  <li>
618
    <c>app-pda/multisync</c>: Multisync allows you to sync contacts, calendar
671
    <c>app-pda/multisync-gui</c>: Multisync allows you to sync contacts, calendar
619
    entries and notes from your mobile phone with your computer, over a
672
    entries and notes from your mobile phone with your computer, over a
620
    Bluetooth connection (amongst other things). It includes such features as
673
    Bluetooth connection (amongst other things). It includes such features as
621
    backing up this information and restoring it later, and syncing with the
674
    backing up this information and restoring it later, and syncing with the
622
    Evolution e-mail client. You will need the <c>irmc</c> USE flag set to
675
    Evolution e-mail client.
623
    ensure that <c>multisync</c> has Bluetooth support.
624
  </li>
676
  </li>
625
  <li>
677
  <li>
626
    <c>net-wireless/opd</c> and <c>net-wireless/ussp-push</c> are command line
678
    <c>net-wireless/opd</c> and <c>net-wireless/ussp-push</c> are command line

Return to bug 286826