Learning BLE from Scratch: Attributes and UUIDs

Learning BLE from Scratch: Attributes and UUIDs
Attributes play a crucial role in BLE, serving as a bridge between different components. Today, let’s learn about the concept of attributes.
Attributes:
The architecture of BLE is divided into servers and clients.
The way BLE works is by storing data on the server, which the client can access. Data is stored in a format similar to a database or a table.
An attribute is a unit of data stored in the BLE server.

Each attribute consists of four values:Attribute Handle, Attribute Type, Attribute Value, Attribute Permission.

Learning BLE from Scratch: Attributes and UUIDs

Learning BLE from Scratch: Attributes and UUIDs

Each row represents an attribute,Attribute = this piece of data.

Attribute Handle: The index of this piece of data, similar to a serial number at the beginning of a table. The handle can be seen as this serial number, starting from1, with a maximum value of 65,535. Data is located using this serial number.
Attribute Type: The type of this piece of data, which can be understood as indicating what this data is used for. This 2-byte or 16-byte data representing the attribute type is the UUID.
UUID (Universally Unique Identifier): A globally unique identifier:
Why is it 2 bytes or 16 bytes?
The complete UUID is 16 bytes. To improve transmission efficiency, the Bluetooth Special Interest Group(SIG) defined a “Bluetooth UUID base” of 16-byte universally unique identification code, combined with a shorter 2-byte number for use. When transmitting commonly used UUIDs, only the shorter 2-byte version is sent, and the recipient can complete it with the Bluetooth UUID base.

The Bluetooth UUID base is:

0000-0000-0000-1000-8000-0080-5F9B-34FB

To send a 2-byte identification code xxxx, the complete 128b UUID is:

0000-xxxx-0000-1000-8000-0080-5F9B-34FB

Attribute UUIDs are classified by the Bluetooth standards organization:

0x1800-0x26FF: Used to identify the service class’s universally unique identifiers. Common service classes: such as 0x1812 representing HOGP (HID Over GATT Profile), 0x1802 representing heart rate, and 0x180F representing battery service.
0x2700-0x27FF: Used to identify measurement units.
0x2800-0x28FF: Used to differentiate attribute types. For example, 0x2800 indicates a primary service, and 0x2803 indicates this piece of data is a characteristic.
0x2900-0x29FF: Used as characteristic descriptions, providing subscription functions.

0x2A00-0x7FFF: Used to differentiate characteristic types. For example, 0x2A00 represents the device name, and 0x2A19 represents battery level.

Leave a Comment