Author: Sreekrishnan Venkateswaran
Linux Bluetooth
Bluetooth is a short-range wireless technology for replacing cables that support 723 kbps (asymmetry) and 432 kbps (symmetry) speed, which can transmit data and voice. The BLUETOOTH device has a range of 10 meters (30 feet).
Bluez is the official Linux Bluetooth stack, Host Control Interface, HCI, Bluetooth Protocol core, logical link control, and adapt protocol (L2CAP), SCO audio layer, other Bluetooth service , The user space background process and configuration tool consists.
The Bluetooth specification supports the UART (universal asynchronous receiver / transmitter) and USB transport mechanism for Bluetooth HCI data packets. The Bluez Stack supports these two transport mechanisms (drivers / bluetooth /). Bluez Bnep (Bluetooth Network Packaging Agreement) implements Ethernet simulation on Bluetooth, which allows TCP / IP to run directly on Bluetooth. BNEP Module (NET / Bluetooth / Bnep /) and user mode PAND background process implements Bluetooth Personal Area Network (PAN). BNEP uses REGISTER_NETDEV to register himself as an Ethernet device to the Linux network layer, and use the Netif_Rx described above to describe the WLAN driver to populate SK_BUFFS and send it to the protocol stack. Bluez RFComm (Net / Bluetooth / RFC ») provides serial emulation on Bluetooth, which makes serial port applications (such as minicom) and protocols (such as Point-to-Point Protocol (PPP)) does not change on Bluetooth. The RFCOMM module and user mode Dund background process implements Bluetooth dial-up networks. The following list gives the BLUEZ modules, utilities, background processes, and profiles necessary to configure various protocol services on Bluetooth.
Next, consider the Bluetooth CF card, Bluetooth USB adapter, an example of a built-in CSR Bluetooth chipset and an example of Sony Bluetooth headset, understand how they work in Linux.
Sharp Bluetooth CF Card
The Sharp Bluetooth CF card uses the UART transmitter to transmit HCI data packets. In addition to serial_cs is outside the card service driver with Linux PCMCIA core interactive, Linux PCMCIA / CF layer interactions with other operating systems of the Sharp card is similar to interaction explained to the INTERSIL WLAN CF card. The serial_cs driver (will further explain further interpretation in the "Linux GPRS and Data" section on the "GSM below) to simulate the serial port on the SHARP CF card. The Bluez HCI_UART link driver interacts with the Bluetooth UART channel and connects the simulated serial port to the Bluez Stack.
The following list gives the modules that must be loaded when the card is inserted. Other Bluetooth CF cards, such as Pretec CompactBT cards, and socket Bluetooth cards, with UART interfaces, but have their own card service drivers (DRIVERS / Bluetooth / DTL1_CS.C and DRIVERS / Bluetooth / btuart_cs.c). Before this article, you will find more information about the Bluetooth UART Transmitter. / etc / pcmcia / config entries for Sharp Bluetooth CF cards:
Card "Sharp Bluetooth Card"
Version "Sharp", "Bluetooth Card"
Bind "serial_cs"
The necessary kernel modules to be loaded:
Insmod serial_cs
Insmod Bluez
Insmod L2CAP
Insmod hci_uart
Insmod Bnep (for Pand)
Insmod RFCMM (For Dund)
Bluez user space daemon process, utility and configuration file:
Hciattach TTYSX Any [Baud_Rate] [Flow]
HCICONFIG -A: Check the HCI interface.
Hcitool -a Hci0 Scan 'Flush: Discover other devices.
Hcidump: HCI sniffer.
HCID: HCI background process.
/etc/bluetooth/hcid.conf: HCI background process configuration file used by HCID, which specifies link mode (main or from), link policy, inquiry, and scan mode, and so on.
/ etc / bluetooth / Pindb: Bluez Pin database.
Hcidump: Service Discovery Protocol Background Process.
PAND: Run TCP / IP on Bluetooth (- Listen for server, - Connect for client).
/ etc / bluetooth / pan / dev-up: PAND calls this script when activating TCP / IP. This script can contain a command similar to ifconfig Bnep0 to configure an IP address for the Bluetooth interface.
Hcidump: Run PPP on Bluetooth RFCComm (- Listen for server, - Connect for client).
Belkin Bluetooth USB Adapter
The Belkin Bluetooth USB adapter has a Bluetooth CSR chipset and uses a USB transmitter to transmit HCI data packets. Therefore, the Linux USB layer, the Bluez USB transmitter driver, and the Bluez protocol stack are the main core layers that make the equipment work. Now you will learn how to interact between three layers to make Linux web applications run on this device.
The Linux USB subsystem is similar to the PCMCIA subsystem, which have a host controller device driver interacting with the mobile device, and includes a core layer that provides a service to the host controller and a single device device driver. The USB Host Controller follows one of two standards: UHCI (Universal Host Controller Interface) or OHCI (Open Host Controller Interface). Due to the PCMCIA, the Linux device driver for a single USB device does not depend on the host controller. Data transferred via USB device is divided into four types (or pipelines): Control
Interrupt
Bulk
Isochronous
The first two are commonly used for small messages and then two are used for larger messages.
When the USB device is inserted, the host controller uses the control pipe to enumerate it and assign it to it device address (1 to 127). The device descriptor read by the host controller device driver includes information about the device, such as Class, Subclass, and Protocol. Linux's USBCORE kernel module supports USB host controllers and USB devices. And contain functions and data structures that the USB device driver can use. The USB driver uses USBCORE and its own class / subclass / protocol information (see Struct USB_Driver in INCLUDE / Linux / USB.H) to register two entry points: ProBe and Disconnect. When the corresponding USB device is attached, USBCORE matches the Class information read from the device configuration descriptor during enumeration, and binds the device with the corresponding driver. This core uses a data structure called USB Request Block or URB (defined in Include / Linux / USB.H) to manage data transfer between host and devices. The device driver uses these routines to request various types of data transmission (Control, Interrupt, Bulk, or Isochronous). After the transfer request is complete, the core will notify the driver using the previously registered callback function.
For Bluetooth USB devices, the HCI command uses Control Piping, and the HCI event uses the Interrupt pipe, and the Asynchronous (ACL) data uses Bulk pipeline, while Synchronous (SCO) audio data uses Isochronous pipelines. The Bluetooth specification defines the class / subclass / protocol code 0xE / SubClass / Protocol code 0xE / 0x01 / 0x01 for the Bluetooth USB device. Bluez USB Transport Driver (Drivers / Bluetooth / HCI_USB.C) registers the Class / SubClass / Protocol information to the Linux USB core. When the Belkin USB adapter is inserted, the host controller device driver enumerates it. This driver can be attached to the Belkin USB device from the HCI_USB driver to the USB core from the adapter during the enumeration period. The HCI, ACL, and SCO data read from the HCI_USB drivers from the individual endpoints described above are transparent to the Bluez protocol stack. Once these, the Linux TCP / IP application can run on the Bluez BNEP by using the Bluez services and tools described above, while serial applications can run on the Bluez RFCMM.
Masterboard with built-in CSR Bluetooth chipset
Now, pay attention to the Bluetooth network data stream on the device with built-in Bluetooth chipset. Consider a handheld device with a built-in CSR Bluetooth chipset with a system using a UART interface. For the UART interface, the available protocols transmitting HCI data packets between Bluetooth devices and systems include BlueCore Serial Protocol (BCSP), H4 / UART, and H3 / RS232. The H4 acts as a standard method for transmitting Bluetooth data through the UART. UART is a proprietary BCSP protocol from the CSR defined in the specification to support error checksum retransmission. BCSP includes PCMCIA and CF cards on non-USB devices based on CSR BlueCore chips. Bluez supports BCSP and H4. The traditional serial driver used by this motherboard UART channel can send and receive data from the Bluez UART transport driver. If you are designed to encapsulate HCI data packets using the BSCP protocol, you must use Hciattach (Hciattach TTYSX BCSP) to notify the Bluez link driver where x is the UART channel number connected to the CSR chipset. Now HCI_UART interacts with the CSR chip and transmits Bluetooth data to the Bluez Stack.
SONY HBH-30 Bluetooth headset
The previous Bluetooth device example shows the network data stream. Now consider the transfer of Bluetooth audio (SCO) data by viewing Sony Ericsson Bluetooth headset. Before the headset can start with Linux devices, it must be detected by the Bluetooth link layer on the Linux device. Therefore, you must put your headphones in the discovery mode (by pressing a button on the headset). In addition, you need to configure the PIN of the headset through the Bluez on the Linux device. Applications using Bluez SCO API on Linux Bluetooth devices can now send audio data to headphones. The audio data should be a format that the headset can understand (for example, the A-Law PCM [Pulse Code Moduction] format of the SONY headset). Some public domain utilities can convert audio (or even text files) into a variety of PCM formats.
The Bluetooth chip sets with the PCM interface PIN other than the HCI transmission interface. For example, if the device supports GSM and Bluetooth, the PCM line of the GSM chipset can be directly connected to the PCM audio line of the Bluetooth chip. You may have to configure the Bluetooth chipset on the Linux device to send the SCO audio data packet through the HCI transmission interface rather than the PCM interface.
About author
Sreekrishnan Venkateswaran has a master's degree in computer science in Campl, Campl, India. He started working for IBM India since February 1996. His interest includes designing equipment drivers and network protocols. able to pass
S_krishna@in.ibm.com Contact Sreekrishnan.
Full article:
IBM DeveloperWorks China website