--- bluetooth-guide.xml?revision=1.17.orig 2010-08-03 22:31:10.000000000 +0100 +++ bluetooth-guide.xml?revision=1.17 2010-08-19 23:17:48.000000000 +0100 @@ -172,32 +172,106 @@ BlueZ - The Bluetooth Stack
-Installing BlueZ +What is BlueZ?

Now that the device is detected by the kernel, we need a layer that lets applications communicate with the Bluetooth device. BlueZ provides the official -Linux Bluetooth stack. The ebuilds that provide what we need are -bluez-libs and bluez-utils. Devices that need Broadcom firmware +Linux Bluetooth stack. The ebuild that provides what we need is +bluez. Devices that need Broadcom firmware files or the like may need bluez-firmware.

+ +
+ +
+BlueZ permission control + + +

+Before installing, it is a good idea to choose how to control users' ability to +use bluetooth. +

-
-# emerge net-wireless/bluez-libs net-wireless/bluez-utils
+

+There are two methods: +

+ +
    + +
  • "consolekit": identifies users who are sat in front of the computer, + and grants them access;
  • +
  • "plugdev": allows members of the plugdev group to use bluetooth
  • +
+ + +

+Although the permission policy can be tuned by editing the dbus permission rules +for bluez, the consolekit USE flag must be set accordingly +

+ +
    +
  • consolekit — means the consolekit method is used and requires + it to be enabled in some dependencies
  • +
  • -consolekit — selects the plugdev method, and does not + require any consolekit support in dependencies.
  • +
+ + +
+ +
+Installing bluez + + +

+Now we can install the package, using the following command. +

+
+# emerge net-wireless/bluez
 
+

+This ebuild might require certain USE flags to be enabled for other ebuilds: +

+ + + +

+Now the bluetooth stack is completely installed, but you need other tools to do +anything useful with it. +

+ +

+You can get some tools enabling the test-programs USE flag +for bluez, which will install some testing utilities. But this is a +limited set of tools, mainly intended for testing — you probably want to +install an external bluetooth utilities package. +

+
-BlueZ configuration and PIN pairing +BlueZ configuration

Now it's time to see if the Bluetooth device is being picked up correctly by the -system. We start up the required Bluetooth services first. +system. We start up the required Bluetooth services first. (It may have been +started when you plugged the device, if it uses some hotpluggable interface +(like USB).)

+ +
 (Start up Bluetooth)
 # /etc/init.d/bluetooth start
@@ -273,9 +347,14 @@
         #encrypt enable;
 }
 
+ +
+
+PIN pairing (<bluez-4) +

-After that, we have to configure the Bluetooth device PIN. That will help in +After configuration, we have to configure the Bluetooth device PIN. That will help in pairing this device with another one.

@@ -295,12 +374,68 @@ Beginning with >=bluez-libs-3.x and >=bluez-utils-3.x, pin helpers have been replaced by passkey agents. There are a few different graphical passkey agents available to help manage your PIN, such as bluez-gnome and -kdebluetooth. You can also use passkey-agent (found in +kbluetooth. You can also use passkey-agent (found in bluez-utils) from the command line. + +
+ +
+PIN Pairing (=bluez-4, with simple-agent) + +

+In =bluez-4, there is no global PIN — when a device is paired you +need some bluetooth utility to input a PIN. One such utility +is simple-agent, part of bluez testing utilities (when built +with USE="test-programs"). +

+

+Before pairing, you must know the bluetooth adapter id +(run /usr/sbin/hciconfig, if you have several adapters, you need to +choose which one you want to pair. +

+ +

+ +You also need the MAC address of the device you want to pair with the +adapter. Some devices have this written in some label, others don't. To find it +out, make the device visible and run hcitool scan — the result is a +list of devices, with their friendly names and MAC addresses. +

+ +
+  Find the MAC address:
+$ hcitool scan
+Scanning ...
+	05:04:03:02:01:00	friendly-name
+
+  Find the adapter ID:
+$ /usr/sbin/hciconfig
+hci0:   Type: USB
+        BD Address: 00:01:02:03:04:05 ACL MTU: 192:8  SCO MTU: 64:8
+        UP RUNNING PSCAN
+        RX bytes:131 acl:0 sco:0 events:18 errors:0
+        TX bytes:565 acl:0 sco:0 commands:17 errors:0
+
+  And then pair the device
+$ simple-agent hci0 05:04:03:02:01:00
+RequestPinCode (/org/bluez/..../hci0/dev_05_04_03_02_01_00)
+Enter PIN Code: 1234
+  (Now the remote device will ask you for this same PIN.)
+Release
+New device (/org/bluez/..../hci0/dev_05_04_03_02_01_00)
+
+ +

+Other bluetooth packages might be able to handle pairing. This involves a tool +which initiates pairing or a tool which listens for pairing requests, or both. + +

+
Services configuration @@ -391,7 +526,7 @@

-# l2ping 00:0A:0B:0C:0D:0E
+# l2ping 00:0A:0B:0C:0D:0E -c 4
 Ping: 00:0A:0B:0C:0D:0E from 00:01:02:03:04:05 (data size 20) ...
 20 bytes from 00:0A:0B:0C:0D:0E id 200 time 69.85ms
 20 bytes from 00:0A:0B:0C:0D:0E id 201 time 9.97ms
@@ -435,6 +570,10 @@
         (Enter the address of the device you want to connect to)
         device 00:0A:0B:0C:0D:0E;
 
+        # RFCOMM channel for the connection
+	(Optional. If not specified, it will use channel 1)
+        channel 1;
+
 }
 
@@ -480,6 +619,42 @@

+A bluetooth device may provide several services, on different +channels. To connect to those services using rfcomm, you need to find +out the right channel first. You can do that using sdptool, +part of bluez. +

+ +
+(The second parameter is the MAC address of the device you want to connect to)
+$ sdptool browse 00:01:02:03:04:05
+Browsing 00:01:02:03:04:05 ...
+Service Name: OBEX Object Push
+Service RecHandle: 0x10001
+Service Class ID List:
+  "OBEX Object Push" (0x1105)
+Protocol Descriptor List:
+  "L2CAP" (0x0100)
+  "RFCOMM" (0x0003)
+(So if you want to connect to OBEX Object Push, you would use channel 4)
+    Channel: 4
+  "OBEX" (0x0008)
+Language Base Attr List:
+  code_ISO639: 0x656e
+  encoding:    0x6a
+  base_offset: 0x100
+Profile Descriptor List:
+  "OBEX Object Push" (0x1105)
+    Version: 0x0100
+
+(Each service is described in lines like the ones above.)
+Service Name: Serial Port
+Service RecHandle: 0x10002
+Service Class ID List:
+...
+
+ +

Each time you call the rfcomm command, you can also specify the physical device you want to use. Below you can see a small example specifiying the physical device on the above two commands. @@ -574,7 +749,7 @@

-KDE makes use of kdebluetooth and provides more utilities than its Gnome +KDE makes use of kbluetooth and provides more utilities than its Gnome counterpart as seen below.

@@ -596,8 +771,8 @@ -
-# emerge kdebluetooth
+
+# emerge kbluetooth
 
@@ -608,19 +783,23 @@
  • - app-mobilephone/obexftp: File transfer over OBEX for mobile phones + app-mobilephone/gnokii: Program to access some features + like SMS, calendar and address book. It is also able to set some + phone settings, like its clock. Has graphical and commandline + interfaces. You will need the bluetooth USE flag set to + ensure that gnokii has Bluetooth support.
  • - app-mobilephone/bemused: Bemused is a system which allows you to - control your music collection from your phone, using Bluetooth. + app-mobilephone/obexftp: File transfer over OBEX for mobile phones. + You will need the bluetooth USE flag set to ensure + that obexftp has Bluetooth support.
  • - app-pda/multisync: Multisync allows you to sync contacts, calendar + app-pda/multisync-gui: Multisync allows you to sync contacts, calendar entries and notes from your mobile phone with your computer, over a Bluetooth connection (amongst other things). It includes such features as backing up this information and restoring it later, and syncing with the - Evolution e-mail client. You will need the irmc USE flag set to - ensure that multisync has Bluetooth support. + Evolution e-mail client.
  • net-wireless/opd and net-wireless/ussp-push are command line