How Bluetooth LE works? -- Host stack
How Bluetooth LE works? – Host stack
Table of Contents
- 1 Bluetooth LE hosts stack architecture
- 2 L2CAP
- 3 Attribute
- 4 The Attribute Protocol and The Generic Attribute Profile
1 Bluetooth LE hosts stack architecture
Bluetooth LE's host stack is built under the Host Control interface, which is used to connect with controller part. As showing in the above figures, there are at least three layers which need to introduce in this article, GATT, ATT, L2CAP.+----------------------------------+ | | | Generic Attribute Profile | +----------------------------------+ | | | Attribute Protocol | +----------------------------------+ | | | L2CAP | +----------------------------------+
2 L2CAP
L2CAP provided a layer just like TCP on The Internet, you can open an L2CAP type socket and bind a port number into it, then build your communication program based on it. In Bluetooth LE, only fixed ports are used to build upper protocol(Attribute Protocol).
In this section, I mentioned port and channel, never minded, they are actually the same meaning. Another thing should be pointed is that L2CAP is not only used for Bluetooth LE, but also for Bluetooth classic, and according to the above table, there are only three L2CAP's channels used to implemented the Bluetooth LE.
Channel 0x0004 is used for Attribute Protocol, Channel 0x0005 is used for LE signaling protocol, Channel 0x0006 is used for the security manager.
Channel Identifier | Use |
0x0000 | Reserved: cannot be used |
0x0001 | Bluetooth Classic signaling channel |
0x0002 | "Connectionless" channel |
0x0003 | AMP manager protocol |
0x0004 | Attribute Protocol |
0x0005 | LE signaling Protocol |
0x0006 | Security Manager Protocol |
0x0007 to 0x003E | Reserved: maybe used in the future |
0x003F | AMP test protocol |
0x0040 to 0xFFFF | Connection-oriented channels |
In this section, I mentioned port and channel, never minded, they are actually the same meaning. Another thing should be pointed is that L2CAP is not only used for Bluetooth LE, but also for Bluetooth classic, and according to the above table, there are only three L2CAP's channels used to implemented the Bluetooth LE.
Channel 0x0004 is used for Attribute Protocol, Channel 0x0005 is used for LE signaling protocol, Channel 0x0006 is used for the security manager.
3 Attribute
To understand Attribute is to understand Bluetooth LE. So the first question is what the attribute is?
The attribute type is used to identify the type of attribute, this identity is also called UUID, which is huge and has 128-bit length. In order to short the attribute size, a simpler and short 16-bit number is used to replace the large UUID.
A collection of attributes is called a database. A database defines how those attributes are used in services and profiles. There is only one attribute server on each device, there is only one attribute database on each device.
A service is a grouping of one or more characteristics; a characteristic is a grouping of one or more attributes.
An Attribute is a piece of labeled and addressable data. The above table shows that an attribute composed of three segments: handle, type, and value. The attribute handles' valid value are from 0x0001 to 0xFFFF, 0x0000 is an invalid handle. I consider the attribute handle is the address of an attribute in a device.+-----------------+-----------------------+----------------------+ | handle(2 oct) | type(2 or 16 octets) | value(0 to 512 oct) | +-----------------+-----------------------+----------------------+
The attribute type is used to identify the type of attribute, this identity is also called UUID, which is huge and has 128-bit length. In order to short the attribute size, a simpler and short 16-bit number is used to replace the large UUID.
A collection of attributes is called a database. A database defines how those attributes are used in services and profiles. There is only one attribute server on each device, there is only one attribute database on each device.
A service is a grouping of one or more characteristics; a characteristic is a grouping of one or more attributes.
4 The Attribute Protocol and The Generic Attribute Profile
The Attribute Protocol defines how a client and server can send standard messages between one another. The GATT procedures define standard way that services, characteristics, and their descriptors can be discovered and then used.
The Attribute protocol defines six basic operations to manipulate the attributes, which is Request, Response, Command, Indication, Confirmation, Notification. Those operations are annoying, I couldn't illustrate them all in details, they can only be understood by reading the real code.
The GATT procedures can be considered to split into three basic types: Discovery procedures, client-initiated procedures, and server-initiated procedures.
So, That's all of them, about the Attribute protocol and GATT profile still need more words to figure them out, and there is still some part of them which I didn't understand without reading some codes. Next, I should write some applications in order to understand them.
The Attribute protocol defines six basic operations to manipulate the attributes, which is Request, Response, Command, Indication, Confirmation, Notification. Those operations are annoying, I couldn't illustrate them all in details, they can only be understood by reading the real code.
The GATT procedures can be considered to split into three basic types: Discovery procedures, client-initiated procedures, and server-initiated procedures.
So, That's all of them, about the Attribute protocol and GATT profile still need more words to figure them out, and there is still some part of them which I didn't understand without reading some codes. Next, I should write some applications in order to understand them.
Comments
Post a Comment