1. Security Level Characteristic feature
Bluetooth® Security Levels Characteristic feature |
---|
1.1. Security Levels Characteristic (SLC) feature
1.1.1. Principles
LE GATT Security Levels characteristic shall contain the highest security requirements among all server's GATT characteristic while operating on a LE connection.
The value of the LE GATT Security Level characteristic shall be static during a connection.
Security Levels characteristic (UUID: 0x2BF5) contains a sequence of one or more security level requirements:
*security level requirement: uint8_t[2]: security mode, security level
The Attribute Value is a sequence of Security Level Requirements, each with the type uint8[2]. Each Security Level Requirement consists of a Security Mode
field followed by a Security Level field.
The Security Mode and Security Level shall be expressed as the same number as used in their definitions; e.g., mode 1 is represented as 0x01 and level 4 is represented as 0x04.
Bluetooth® Read Security Level Characteristic |
---|
1.2. How to implement SLC on STM32WBA applications
1.2.1. Peripheral
Add a dedicated SLC characteristic (UUID = 0x2BF5) to GAP service
Char_UUID_t uuid; uint16_t gap_SecuLevelsCharac_handle = 0U; static const uint8_t p_additional_svc_record[1] = {0x03}; ret = aci_hal_write_config_data(CONFIG_DATA_GAP_ADD_REC_NBR_OFFSET, CONFIG_DATA_GAP_ADD_REC_NBR_LEN, (uint8_t*) p_additional_svc_record); if (ret != BLE_STATUS_SUCCESS) { LOG_INFO_APP(" Fail : aci_hal_write_config_data command - CONFIG_DATA_GAP_ADD_REC_NBR_OFFSET, result: 0x%02X\n", ret); } else { LOG_INFO_APP(" Success: aci_hal_write_config_data command - CONFIG_DATA_GAP_ADD_REC_NBR_OFFSET\n"); } uint16_t SizeSecuLevelsCharac_C = sizeof(tab_ModeLevel); uuid.Char_UUID_16 = LE_GATT_SECURITY_LEVELS_UUID; ret = aci_gatt_add_char(gap_service_handle, UUID_TYPE_16, (Char_UUID_t *) &uuid, SizeSecuLevelsCharac_C, CHAR_PROP_READ, ATTR_PERMISSION_NONE, GATT_DONT_NOTIFY_EVENTS, 0x10, CHAR_VALUE_LEN_CONSTANT, &gap_SecuLevelsCharac_handle); if (ret != BLE_STATUS_SUCCESS) { APP_DBG_MSG(" Fail : aci_gatt_add_char command : security_levels_char, error code: 0x%2X\n", ret); } else { APP_DBG_MSG(" Success: aci_gatt_add_char command : security_levels_char\n"); } /* write key/vector in characteristic -fixed value for the moment */ ret = aci_gatt_update_char_value(gap_service_handle, gap_SecuLevelsCharac_handle, 0, SizeSecuLevelsCharac_C, (uint8_t *)&tab_ModeLevel); if (ret != BLE_STATUS_SUCCESS) { APP_DBG_MSG(" Fail : aci_gatt_update_char_value - security_levels_char, result: 0x%02X\n", ret); } else { APP_DBG_MSG(" Success: aci_gatt_update_char_value - security_levels_char\n"); }
1.2.2. Central
Discover Security Levels Characteristic added to GAP service (among all characteristics).
2. Example of Security Levels Characteristic feature on STM32WBA
2.1. Advertising data
At startup, Security Levels Characteristic Server application starts Advertising.
Data advertised are composed as follows:
Security Levels Characteristic (SLC) Server Advertising packet | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Manufacturer data are encoded following STMicroelectronicsBlueST SDK v2 as described below:
STMicroelectronics Manufacturer Advertising data | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
2.2. On-board buttons configuration
Button configuration for Bluetooth® LE connection subrating application on Nucleo-WBA55CG boards | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
2.3. Security Levels Characteristic P2P Central and Peripheral applications
- Connection established at 50 ms
- Service, characteristics discovery
- Read Security Levels Characteristic values: mode, level
- If security level reported is higher than Level 1 (no security is required): new pairing process is requested
Bluetooth® Example of flow diagram between p2pServer SLC and p2pClient SLC |
---|
3. Code Example
An STM32WBA Security Level Characteristic code example (peripheral and central) is available from the STM32-Hotspot GitHub[1].
4. References