Linux Unwired [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Linux Unwired [Electronic resources] - نسخه متنی

Edd Dumbill, Brian Jepson, Roger Weeks

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید








7.4 Linux Bluetooth Support


As with many emerging technologies, there are competing
implementations of Linux Bluetooth support. The main two
implementations are
Affix and
BlueZ. Affix
was originally developed by Nokia and is now hosted as an open source
project at
SourceForge
(http://affix.sourceforge.net).
BlueZ is also hosted at SourceForge is (http://bluez.sourceforge.net) and the
official Bluetooth stack of the Linux kernel.

Although Affix is a mature and functional project, BlueZ receives
more testing and has more widespread adoption. For this reason, this
chapter focuses on the uses of the BlueZ Linux Bluetooth stack and
libraries.

This section includes all the information that you need to install
and configure Bluetooth support from scratch. It is possible that
your Linux distribution already contains preconfigured Bluetooth
support, which will save you effort. However, the installation
instructions provide useful background information for
troubleshooting.


7.4.1 Distributions


As Bluetooth is a relative newcomer to Linux, BlueZ support across
commercial distributions varies. Generally speaking, if the kernel
shipping with your distribution is older than 2.4.22, it is a good
idea to upgrade it. Users of
"bleeding-edge" distributions such
as Debian Unstable and Gentoo should find that Bluetooth is
adequately supported.


7.4.2 Configuring the Kernel


Bluetooth support under
Linux requires a recent kernel. If your
kernel is Version 2.4.22 or better, or a 2.6 series kernel, then
you're all set. Otherwise, you must upgrade your
kernel. Alternatively, if you do not wish to upgrade, and have kernel
2.4.18 or better compiled from source, you can apply the patches from
the "kernel patches" area of the
BlueZ web site (http://bluez.sourceforge.net). Regardless,
it's worth checking out the patches, because there
are often improvements available that have not yet been merged into
the main Linux kernel source.


Patching the Kernel


To patch the kernel, first download the
most recent patch for your kernel
version from the BlueZ web site (for example,
patch-2.4.22-mh1.gz), and place it somewhere
convenient, such as /usr/src/. Change into the
directory where your kernel source is unpacked, typically
/usr/src/linux, and apply the patch:

cd /usr/src/linux 
gzip -dc .. /patch-2.4.22-mh1.gz | patch -p1

Next, run this command:

find . -name '*rej'

If any of the patches were rejected, you'll find
some files ending in .rej. If they were, delete
the kernel source, extract it again (be sure that you have the
correct patch for your kernel version), and try the patch again.

You can then proceed with configuring your kernel for Bluetooth by
running make menuconfig,
make xconfig, or make config.

Chapter 2 explains how to configure and compile
a kernel. Table 7-3 and Table 7-4 show the options that must be set in your
kernel configuration to enable Bluetooth support. You can either
configure Bluetooth support to be compiled into the kernel or to be
loadable on-demand in the form of modules. Many Linux distributions
choose to ship with modules, so we proceed on the assumption that you
will use modules. This removes the need to recompile your kernel if
you acquire a different type of Bluetooth device.

Figure 7-3 and Figure 7-4 show
the Bluetooth configuration options from the 2.4.24 kernel.


Figure 7-3. Configuring Bluetooth support in the Linux kernel



Figure 7-4. Configuring Bluetooth hardware support in the Linux kernel


Table 7-3. BlueZ protocol configuration options

Option


Purpose


Recommended value


Bluetooth subsystem support


Enables the entire BlueZ stack


m


L2CAP protocol support


A basic Bluetooth protocol


m


SCO links support


Bluetooth Audio


m


RFCOMM protocol support


Serial data transfer


m


RFCOMM TTY support


Maps Linux terminal devices (e.g., /dev/rfcomm0)
to Bluetooth serial ports


y


BNEP protocol support


Personal area networking


m


BNEP Multicast filter support, protocol filter support


Advanced filtering for networking


y

Table 7-4. BlueZ hardware support configuration options

Option


Purpose


Recommended value


HCI USB driver


Support for USB dongles


m


SCO (voice) support


Audio transmission support


y


USB zero packet support


Workaround for buggy USB devices


n


HCI UART driver


Support for serial dongles: either PCMCIA, CF, or RS232 serial port


y


UART (H4) protocol support


Serial protocol used for most PCMCIA and CF cards


y


BCSP protocol support


Serial protocol used for PCMCIA and CF cards based on the CSR
BlueCore chipset


y


Transmit CRC with every BCSP packet


Improves reliability of BCSP support, at a slight cost to efficiency


y


HCI BlueFRITZ! USB driver


Support for BlueFRITZ! Bluetooth ISDN


m


HCI VHCI (Virtual HCI device) driver


Support for a virtual Bluetooth device for testing purposes


m


You should not enable the Bluetooth device support in the USB drivers
section of your kernel configuration
(CONFIG_USB_BLUETOOTH).
This is a vestigial driver from very early Bluetooth work and will
prevent the BlueZ Bluetooth stack from operating. If you are using a
distribution's precompiled kernel, this corresponds
to the bluetooth kernel module, and you should
prevent it from being loaded. This can be done either by ensuring the
BlueZ hci_usb module is loaded instead of the
USB Bluetooth module or by disabling the module by adding its name to
hotplug's configuration list
(/etc/hotplug/blacklist).

Once your kernel is compiled and you have rebooted, you must
configure Linux so it knows how to load the appropriate Bluetooth
protocol modules. Most modern distributions come with
/etc/modules.conf already set up for Bluetooth
use, but you may be missing the required configuration.

To verify this, ensure that the contents of Example 7-1 are present in
/etc/modules.conf. If you need to change this
file, run depmod -a to ensure automatic loading of
modules by the kernel. You must be the root user to perform this
operation.

Example 7-1. Module configuration for BlueZ

# BlueZ modules
alias net-pf-31 bluez
alias bt-proto-0 l2cap
alias bt-proto-2 sco
alias bt-proto-3 rfcomm
alias bt-proto-4 bnep
alias tty-ldisc-15 hci_uart
alias char-major-10-250 hci_vhci


Linux distributions may vary in the way they manage the
/etc/modules.conf file. Debian GNU/Linux, for
example, requires you put the contents of Example 7-1 in a separate file in
/etc/modutils and run
/sbin/update-modules; however, if you use the
pre-packaged Debian BlueZ utilities, this file is already provided
for you.


7.4.3 Supporting Subsystems


Depending on your hardware configuration, you must ensure you are
running some extra supporting software to initialize your Bluetooth
device.


7.4.3.1 PCMCIA


If your Bluetooth adapter is a PC card or a CF card, you must have
kernel support for PCMCIA and the
PCMCIA card services software installed.
This software is responsible for initializing your adapter when it is
plugged in and loading the required drivers into the kernel.

BlueZ requires PCMCIA card services to be Version 3.2.2 or higher. If
your Linux distribution has an older version, you can update it from
http://pcmcia-cs.sourceforge.net.
See Chapter 2 for complete instructions on
compiling pcmcia-cs from source.


7.4.3.2 Hotplug


The Linux hotplug
subsystem enables you to plug in a device and have it immediately
ready to use. It is similar in function to the card manager from
PCMCIA card services, except it is generalized to include USB,
Firewire (IEEE 1394), and network devices. The 2.6 series of Linux
kernels adds hotplug capability to even more subsystems, such as SCSI
and input devices.

When hotplug detects a new device, it loads the necessary driver
modules into the kernel, and it runs any scripts the user has
configured. In the case of BlueZ, hotplug is required for certain
Bluetooth devices that require firmware downloaded to them, such as
the USB dongles based on the Broadcom chipset.

Hotplug ships with most Linux distributions. Version 2002_08_26 or
later is required. If you need to install it separately, download it
from http://linux-hotplug.sourceforge.net/.


/ 100