![]() |
Bluetooth LE Profile API document
Bluetooth LE Profile API document Rev.1.00 [May 22, 2020]
|
The GATT Database consists of the attribute defined as Service, Characteristic and Characteristic Descriptor.
The protocol stack utilizes the instance of st_ble_gatts_db_cfg_t type structure set by R_BLE_GATTS_SetDbInst() as GATT Database.
The components of the GATT Database are the following arrays.
No.1 | An array in which UUIDs to be used are registered. | (const uint8_t *) |
No.2 | An array in which variable attribute values are registered. | (uint8_t *) |
No.3 | An array in which fixed attribute values are registered. | (const uint8_t *) |
No.4 | An array in which attribute values handled per GATT client are managed. | (uint8_t *) |
No.5 | An array in which default attribute values to be managed by each GATT client are registered. | (const uint8_t *) |
No.6 | An array in which information on the position where UUIDs are used is registered. | (st_ble_gatts_db_uuid_cfg_t *) |
No.7 | An array in which the detailed information of attributes is registered. | (st_ble_gatts_db_attr_cfg_t *) |
No.8 | An array in which the detailed information of characteristics is registered. | (st_ble_gatts_db_char_cfg_t *) |
No.9 | An array in which the detailed information of services is registered. | (st_ble_gatts_db_serv_cfg_t *) |
This section describes the No.1-No.9 components of the GATT Database as Figure 2.1.
No.1-No.4 are collections of the fixed values and the variables referred in the GATT Database.
The UUIDs to be used in the GATT Database will be listed by No.1.
When this array is generated as the name of "gatt_const_uuid_arr", it would be as follows.
Attribute values to be used as variable such as HeartRateMeasurement indicated by attribute handle in the red above will be registered by No.2.
When this array is generated as the name of "gatt_value_arr", it would be as follows.
Attribute values to be used as fixed value such as Characteristic Declaration indicated by attribute handle in the blue above will be registered by No.3.
When this array is generated as the name of "gatt_const_value_arr", it would be as follows.
The memory to store values that need to be managed for each GATT client such as CCCD indicated by attribute handle in the green above will be allocated by No.4.
Prepare the array that will be the size of variable * the number of GATT client.
When this array is generated as the name of "gatt_db_peer_specific_val_arr", it would be as follows.
The default values of attributes that need to be managed for each GATT client will be registered by No.5.
When this array is generated as the name of "gatt_db_const_peer_specific_val_arr", it would be as follows.
The information on the placement of each UUID in GATT Database will be registered by No.6.
This consists of the first position and the last position where the UUID is used and the index of No.1.
For each UUID registered in No.1, it consists of information indicating the first position where its UUID is placed on GATT Database and the last position where it is placed. If the UUID is placed in only one place, the last position is represented by 0x0000.
When this array is generated as the name of "gatt_type_table", it would be as follows.
The information indicated in the red dotted line square of Figure 2.1 for each attribute will be registered by No.7.
The information will be registered includes the attribute handles, the UUIDs, the storage area of the attribute value and the permission.
When this array is generated as the name of "gatt_db_attr_table", it would be as follows.
The information indicated in the green dotted line square of Figure 2.1 for each characteristic will be registered by No.8.
The information will be registered includes the total number of attributes in a characteristic, the first attribute handle of the characteristic and the index of service to which the characteristic belongs.
When this array is generated as the name of "gatt_characteristic", it would be as follows.
The information indicated in the blue dotted line square of Figure 2.1 for each service will be registered by No.9.
The information will be registered includes the total number of the service declaration, the properties such as security requirements, the attribute handles indicating range of the service and the index range of belonging characteristics.
When this array is generated as the name of "gatt_service", it would be as follows.
All arrays from No.1 to No.9 and supplementary information will be finally registered in the st_ble_gatts_db_cfg_t structure.
When this variable is generated as the name of "g_gatt_db_table", it would be as follows.
By using this variable as an argument of R_BLE_GATTS_SetDbInst(), GATT Database will be registered in the protocol stack.
Figure 2.2 shows the relationship of the arrays that compose the GATT Database.
GATT Server sets a value to an attribute value in own GATT Database by R_BLE_GATTS_SetAttr().
GATT Server gets an attribute value in the GATT Database by R_BLE_GATTS_GetAttr().
A request for access to the GATT Database from a GATT Client is processed in the following steps.
Step 1 | GATT Server receives a request for access to the GATT Server from a GATT Client. |
Step 2 | Host stack confirms the security requirement of the service to be accessed and the security between GATT Server and GATT Client. |
Step 3 | If the security between GATT Server and the GATT Client does not meet to the security requirement, GATT Server sends an Error Response PDU to the GATT Client. If the security meets to the security requirement, GATT Server notifies the application layer to BLE_GATTS_EVENT_DB_ACCESS_IND event. This event includes the access type. |
Step 4 | The application layer in GATT Server accesses to the GATT Database as needed. For example, when GATT Server has received a request for read a characteristic from GATT Client, the application layer gets the value from a sensor and sets the value to the GATT Database. |
Step 5 | If the processing in the application layer is successfully completed, the application layer returns control to host stack. If the processing in the application layer is failed, it sends an Error response PDU to the GATT Client by R_BLE_GATTS_SendErrRsp(). |
Step 6 | Host stack accesses to the Characteristic or Characteristic Descriptor in the GATT Database. |
Step 7 | Host stack return the result of the access to the Characteristic or Characteristic Descriptor. |