Reprinted from http://www.360doc.com/content/12/0919/13/10388890_237015006.shtml
The Android BlueTooth system is divided into four layers: kernel layer, BlueZ library, BlueTooth adaptation library, BlueTooth JNI part, Java framework layer, and application layer. Next we will analyze the Bluetooth protocol stack of Android.
Android's Bluetooth protocol stack is implemented using BlueZ. BlueZ consists of two parts: kernel code, user-state programs, and tool sets.
The kernel code mainly consists of the BlueZ Core Protocol and driver. The bluetooth protocol is implemented in the kernel source code net/bluetooth, and the driver is located in the kernel source code directory driver/bluetooth. User State programs and tool sets mainly include application interfaces and BlueZ tool sets, which are located in the Android source code directory externel/bluetooth (Note: The Android version is different, and some are in the externel/bluez directory.
1. Bluetooth protocol stack
The architecture of the Bluetooth protocol stack consists of the underlying hardware module, intermediate protocol layer, and high-end application layer.
I. underlying hardware module
Composition:
Link ManagerProtocol (LMP );
Base Band (BB );
RF (Radio Frequency, RF ).
Function:
RF (RF) filters and transmits data streams through the ISM band of 2 to 4 GHz.
The baseband (BB) provides two different physical links, namely, Synchronous Connection Oriented (SCO) and AsynchronousConnection Less (ACL ), responsible for transmitting Frequency hopping, bluetooth data, and information frames, and providing different levels of forward Correction Codes (Frequency Error Correction, FEC) for all types of data packets) or Cyclic Redundancy error Check (CRC ).
The Link Management Protocol (LMP) is responsible for the establishment and removal of two or more device links, as well as the security and control of links, such as authentication and encryption, control, and the size of collaborative bandwidth packages, it provides different access portals for upper-layer software modules.
Host Controller Interface (HCI) is an Interface between hardware and software in the Bluetooth protocol. It provides a unified command to call hardware such as BB, LMP, status, and control register, messages and data transmission between interfaces of the upper and lower modules must be explained by HCI.
Ii. Intermediate protocol layer
Composition:
Logical Link Control and Adaptation Protocol (L2CAP );
Service Discovery Protocol (SDP );
Serial Port simulation protocol (or RFCOMM );
Binary Telephone Control Protocol (TCS ).
Function:
L2CAP is located on the base band (BB) and provides connection-oriented and connectionless data services to the upper layer, it mainly implements data disassembly, service quality control, protocol reuse, grouping and reorganization, and group extraction.
SDP is a client/server-based protocol that works on The L2CAP layer and provides a mechanism for upper-layer applications to discover available services and their attributes, service attributes include the service type and the mechanism or protocol information required by the Service.
RFCOMM is a wireless data simulation protocol for simulation of Wired links, in line with the ETSI standard TS07.10 serial port simulation protocol, it simulation of RS-232 control and data signal on the Bluetooth baseband, it provides transmission capabilities for upper-layer businesses that originally use serial connections.
TCS defines Call Control Signalling for establishing voice and data Call between bluetooth devices, and is responsible for handling the mobile management process of Bluetooth device groups.
Iii. High-end application layer
Composition:
Point-to-PointProtocol (PPP );
Transmission Control Protocol/Network Layer Protocol (TCP/IP );
User data packet Protocol (UDP );
ObjectExchang Protocol (OBEX );
WirelessApplication Protocol (WAP );
WirelessApplication Environment (WAE );
Function:
PPP defines how a serial point-to-point link transmits Internet protocol data. It is mainly used in LAN access, dial-up network, fax, and other application specifications.
TCP/IP and UDP define the communication between the Internet and the network, and between other types of computer devices and peripheral devices.
OBEX supports data exchange between devices and provides the same basic functions as HTTP (Hypertext Transfer Protocol) in the customer/Server mode. Formats such as e-business cards, personal calendars, messages, and notes that can be exchanged.
WAP is used to implement Internet services on digital cellular phones and other small wireless devices. It allows mobile phones to browse webpages, receive emails, and other Internet-based protocols.
WAE provides various applications required for WAP calls and personal digital Assistant (PDA.
2. Relationship between android and Bluetooth protocol stack
The core of the Bluetooth system is BlueZ, so both JNI and the upper layer communicate with BlueZ. JNI and android Application layer, the main means of communication with BlueZ is D-BUS, which is a set of widely used IPC communication mechanism, similar to the Android framework using the Binder. BlueZ is D-BUS-based and provides major interfaces for other parts.