Implementation of Bluetooth Communication in Information Appliances

Label: HCI Bluetooth Protocol

This article refers to the address: http://

Information appliances are the hotspots of research at home and abroad, and information appliances are focused on the cost performance of data transmission methods. Bluetooth can be used as an effective means of communication to realize the transmission of other moderate data such as control information between the home gateway and the information appliance. This article first introduces Bluetooth HCI and Bluetooth protocols L2CAP, BNEP, and then how to implement USB Bluetooth driver under Linux2.4.18, and finally how to achieve wireless communication in Bluetooth personal area network.

1 Basic block diagram of information appliances

The basic structure of information appliances is shown in Figure 1. The home main gateway is responsible for the communication between various home appliances and the external environment. The ways to communicate with the external environment include Ethernet and PSTN fixed-line networks. As far as the interior of the home is concerned, for ordinary information appliances such as air conditioners and televisions, since the amount of data communicated by the home gateway and the home gateway is not large, it is possible to communicate by Bluetooth wireless mode, thereby achieving the purpose of controlling the home appliance work.

Implementation of Bluetooth Communication in Information Appliances

figure 1

2 Bluetooth HCI and L2CAP, BNEP protocol

The Bluetooth protocol system is roughly divided into three layers, namely, the underlying hardware module layer, the intermediate protocol layer, and the high-end application layer.

Contains some specific agreements.

2.1 Bluetooth HCI

The host control interface (HCI) of Bluetooth is the Bluetooth host--the hardware and software interface between the Bluetooth module and the host in the main controller application mode. It is located between the underlying hardware module layer and the intermediate protocol layer of the Bluetooth protocol stack, and is responsible for completing these two. Layer data communication [1]. Currently, the physical interfaces of the Bluetooth HCI transport layer include USB, UART, etc., and Bluetooth devices can use these physical interfaces to implement communication. This article will introduce communication using the USB port as the transport layer.

2.2 Bluetooth L2CAP protocol

Bluetooth's Logical Link Control and Adaptation Protocol (L2CAP) is the core of the entire Bluetooth protocol. It is located at the intermediate protocol layer. It converts the underlying data packets into data packet formats for high-level applications and provides protocol multiplexing. It provides connection-oriented and connectionless services to the upper layer protocol. The L2CAP layer only supports the transmission of ACL (asynchronous connectionless) data, and does not support the transmission of SCO (synchronous connection-oriented) data [1].

2.3 Bluetooth BNEP protocol

The Bluetooth Network Encapsulation Protocol (BNEP), which is developed by the Bluetooth SIG, provides an Ethernet-like interface to the upper-layer IP protocol and supports network protocols supported by the IEEE802.3/Ethernet package [2]. BNEP is implemented through connection-oriented L2CAP, which can be seen as the Bluetooth Media Access Control (MAC) layer. BNEP acts as a bridge throughout the Bluetooth protocol stack, converting IP packets into L2CAP packets for transmission over Bluetooth. The BNEP protocol is mainly used in the Bluetooth personal area network.

3 USB Bluetooth module driver

1. Since the kernel used is Linux 2.4.18, which does not include support for the Bluetooth driver, it must be patched. Unzip the Linux 2.4.18 kernel, put the Bluetooth patch package patch-2.4.18-mh15.gz in the decompressed kernel directory, and execute the command patch –p1 < patch-2.4.18-mh15.gz[3].

2. BNEP (Bluetooth Network Encapsulation Protocol) in the Linux Bluetooth protocol stack implements Ethernet emulation on Bluetooth, which allows TCP/IP to run directly on Bluetooth. Since the essence of the experiment is to implement BNEP-based Ethernet transmission of data via Bluetooth HCI USB, BNEP support must be added during kernel configuration.

3. In the Bluetooth subsystem support option, select L2CAP protocol support, BNEP protocol support (Malticast filter support, and Protocol filter support). The role of these items is to enable the kernel to support the L2CAP and BNEP protocols in the Bluetooth protocol. Then enter the Bluetooth device drivers and select the HCI USB driver. At this point, the kernel's support for USB Bluetooth is completed.

4, download the bluez-libs-2.17.tar.gz Bluetooth library and bluez-utils-2.17.tar.gz toolkit, run the tar zxvf command to extract, then run the make and make install commands, so that we can get the libbluetooth we need .so,, These three library files and hcid, hcitool, pand, hciconfig, sdpd, sdpdtool these six process files.

4 Implementation of Bluetooth wireless communication in home gateway

Introduction of the entire communication process:

1. The USB Bluetooth transport driver (drivers/bluetooth/hci_usb.c) registers the information to the Linux USB core. When USB Bluetooth is plugged in, the host controller device driver enumerates it and assigns it an address, while reading the device information contained in the device descriptor. If the device descriptor read during the enumeration matches the information registered by the hci_usb driver to the Linux USB core, then the driver can be added to the USB device.

2, run hcid (HCI background process), sdpd (service discovery protocol background process), hciconfig (check HCI interface and open Bluetooth device), hcitool (scan Bluetooth device address) these four CRAMFS file system sbin directory process file The execution of these files depends on the three bluetooth library files,, Running the pand --listen --role NAP on the S3C2410 side of the Bluetooth device can be discovered and successfully assigned a unique address, which will allow Ethernet to be connected via Bluetooth. as shown in picture 2.

Implementation of Bluetooth Communication in Information Appliances

figure 2

3. Insert USB Bluetooth on the PC and run BlueSoleil, the Bluetooth driver software under Windows. After scanning and discovering the Bluetooth device, establish a personal LAN.

4. Based on the establishment of the personal area network, BNEP can register itself as an Ethernet device to the Linux network layer. The Bluetooth interface IP address can be changed by the command ifconfig bnep0. The BNEP module and the user mode pand background process implement the Bluetooth Personal Area Network (PAN). After modifying the IP addresses of the two USB Bluetooth to the same network segment, you can use the USB Bluetooth IP address command of the ping PC to implement the wireless communication between the simulated home gateway and the internal device, as shown in the super terminal print information in Figure 3. .

Implementation of Bluetooth Communication in Information Appliances

image 3

5, the experimental results: from Figure 2 and Figure 3 can be seen after running the file containing hcid, sdpd, hciconfig, hcitool four processes bluetooth, you can see the S3C2410 side of the USB Bluetooth address is 00:0D: 18 :01:23:88, and then modify its LAN address with ifconfig bnep0, and finally use ping (Bluetooth address on the PC) to achieve data transmission and reception.

Lipo Battery Cell

Shenzhen Powercom Electronics Co., Ltd. ,