5.5.2 GATT Services and Profile
A GATT service is a collection of characteristics. For example, the heart rate service contains a heart rate measurement characteristic and a body location characteristic. You can group services together to form a profile. Many profiles implement only one service; so the two terms are used interchangeably.
The SimpleBLEPeripheral application has the following four GATT profiles:
- Mandatory GAP Service – This service contains device and access information such as the device name, vendor identification, and product identification. This service is a part of the Bluetooth Low Energy protocol stack and is required for every Bluetooth Low Energy device per the Bluetooth Low Energy specification. The source code for this service is not provided but is built into the stack library.
- Mandatory GATT Service – This service contains information about the GATT server and is a part of the Bluetooth Low Energy protocol stack. This service is required for every GATT server device per the Bluetooth Low Energy specification. The source code for this service is not provided but is built into the stack library.
- Device Information Service – This service exposes information about the device such as the hardware version, software version, firmware version, regulatory information, compliance information, and the name of the manufacturer. The Device Information Service is part of the Bluetooth Low Energy protocol stack and is configured by the application. For more information, see Device Information Service (Bluetooth Specification), version 1.0 (24-May-2011).
- simpleGATTProfile Service – This service is a sample profile for testing and demonstration. The full source code is in the files simpleGATTProfile.c and simpleGATTProfile.h.
Figure 5-9 shows and describes the portion of the attribute table in the SimpleBLEPeripheral project corresponding to the simpleGATTProfile service. This section is an introduction to the attribute table. For information on how this profile is implemented in the code, see Section 5.5.4.2.
The simpleGATTProfile contains the following five characteristics:
- SIMPLEPROFILE_CHAR1 – A 1-byte value that can be read or written from a GATT-client device
- SIMPLEPROFILE_CHAR2 – A 1-byte value that can be read from a GATT-client device, but cannot be written.
- SIMPLEPROFILE_CHAR3 – A 1-byte value that can be written from a GATT-client device, but cannot be read.
- SIMPLEPROFILE_CHAR4 – A 1-byte value that cannot be directly read or written from a GATT-client device (This value is notifiable and can be configured for notifications to be sent to a GATT client device.)
- SIMPLEPROFILE_CHAR5 – A 5-byte value that can be read but not written from a GATT-client device
The following is a line-by-line description of this attribute table, referenced by the attribute handle:
- 0x001F: This attribute is the simpleGATTprofile service declaration. This declaration has a UUID of 0x2800 (Bluetooth-defined GATT_PRIMARY_SERVICE_UUID). The value of this declaration is the UUID of the simpleGATTprofile (custom-defined by TI).
- 0x0020: This attribute is the SIMPLEPROFILE_CHAR1 characteristic declaration. This declaration can be thought of as a pointer to the value of SIMPLEPROFILE_CHAR1. This declaration has a UUID of 0x2803 (Bluetooth-defined GATT_CHARACTER_UUID). The value of this declaration and all other characteristic declarations is a five-byte value explained as follows (from MSB to LSB):
- 0x0021: This attribute is the SIMPLEPROFILE_CHAR1 value. The attribute has a UUID of 0xFFF1 (custom-defined). Its value is the actual payload data of the characteristic. Indicated by its characteristic declaration (handle 0x0020), this value is readable and writeable.
- 0x0022: This attribute is the SIMPLEPROFILE_CHAR1 user description. The attribute has a UUID of 0x2901 (Bluetooth-defined). Its value is a user-readable string describing the characteristic.
- 0x0023 – 0x002F: These attributes follow the same structure as the SIMPLEPROFILE_CHAR1 with regard to the remaining four characteristics. The only different attribute, handle 0x002B, is described in the following bullet.
- 0x002B: This attribute is the SIMPLEPROFILE_CHAR4 client characteristic configuration. This configuration has a UUID of 0x2902 (Bluetooth-defined). By writing to this attribute, a GATT server can configure the SIMPLEPROFILE_CHAR4 for notifications (writing 0x0001) or indications (writing 0x0002). Writing a 0x0000 to this attribute will disable notifications and indications.