feat(ble/bluedroid): Support LE Security Levels Characteristic
This commit is contained in:
@@ -377,6 +377,13 @@ config BT_GATTS_APPEARANCE_WRITABLE
|
||||
help
|
||||
Enabling this option allows remote GATT clients to write appearance
|
||||
|
||||
config BT_GATTS_SECURITY_LEVELS_CHAR
|
||||
bool "Enable LE GATT Security Levels Characteristic"
|
||||
depends on BT_GATTS_ENABLE
|
||||
default n
|
||||
help
|
||||
Enable LE GATT Security Levels Characteristic
|
||||
|
||||
menuconfig BT_GATTC_ENABLE
|
||||
bool "Include GATT client module(GATTC)"
|
||||
depends on BT_BLE_ENABLED
|
||||
|
||||
@@ -580,6 +580,12 @@
|
||||
#define UC_BT_GATTS_APPEARANCE_WRITABLE FALSE
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_GATTS_SECURITY_LEVELS_CHAR
|
||||
#define UC_BT_GATTS_SECURITY_LEVELS_CHAR CONFIG_BT_GATTS_SECURITY_LEVELS_CHAR
|
||||
#else
|
||||
#define UC_BT_GATTS_SECURITY_LEVELS_CHAR FALSE
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_BLE_ACT_SCAN_REP_ADV_SCAN
|
||||
#define UC_BT_BLE_ACT_SCAN_REP_ADV_SCAN CONFIG_BT_BLE_ACT_SCAN_REP_ADV_SCAN
|
||||
#else
|
||||
|
||||
@@ -798,6 +798,12 @@
|
||||
#define GATTS_APPEARANCE_WRITABLE FALSE
|
||||
#endif
|
||||
|
||||
#if (UC_BT_GATTS_SECURITY_LEVELS_CHAR == TRUE)
|
||||
#define BT_GATTS_SECURITY_LEVELS_CHAR TRUE
|
||||
#else
|
||||
#define BT_GATTS_SECURITY_LEVELS_CHAR FALSE
|
||||
#endif
|
||||
|
||||
#ifdef UC_BT_BLE_ACT_SCAN_REP_ADV_SCAN
|
||||
#define BTM_BLE_ACTIVE_SCAN_REPORT_ADV_SCAN_RSP_INDIVIDUALLY UC_BT_BLE_ACT_SCAN_REP_ADV_SCAN
|
||||
#endif
|
||||
|
||||
@@ -256,6 +256,12 @@ tGATT_STATUS gap_read_attr_value (UINT16 handle, tGATT_VALUE *p_value, BOOLEAN i
|
||||
UINT8_TO_STREAM(p, p_db_attr->attr_value.addr_resolution);
|
||||
p_value->len = 1;
|
||||
break;
|
||||
#if (BT_GATTS_SECURITY_LEVELS_CHAR == TRUE)
|
||||
case GATT_UUID_GAP_GATT_SECURITY_LEVELS:
|
||||
UINT16_TO_STREAM(p, p_db_attr->attr_value.security_level);
|
||||
p_value->len = 2;
|
||||
break;
|
||||
#endif // (BT_GATTS_SECURITY_LEVELS_CHAR == TRUE)
|
||||
}
|
||||
return GATT_SUCCESS;
|
||||
}
|
||||
@@ -464,6 +470,17 @@ void gap_attr_db_init(void)
|
||||
p_db_attr->attr_value.addr_resolution = 0;
|
||||
p_db_attr++;
|
||||
|
||||
#if (BT_GATTS_SECURITY_LEVELS_CHAR == TRUE)
|
||||
/* Add LE Security Levels Characteristic */
|
||||
uuid.len = LEN_UUID_16;
|
||||
uuid.uu.uuid16 = p_db_attr->uuid = GATT_UUID_GAP_GATT_SECURITY_LEVELS;
|
||||
p_db_attr->handle = GATTS_AddCharacteristic(service_handle, &uuid,
|
||||
GATT_PERM_READ, GATT_CHAR_PROP_BIT_READ,
|
||||
NULL, NULL);
|
||||
p_db_attr->attr_value.security_level = 0x0101;
|
||||
p_db_attr++;
|
||||
#endif // (BT_GATTS_SECURITY_LEVELS_CHAR == TRUE)
|
||||
|
||||
/* start service now */
|
||||
memset (&app_uuid.uu.uuid128, 0x81, LEN_UUID_128);
|
||||
|
||||
@@ -517,6 +534,12 @@ void GAP_BleAttrDBUpdate(UINT16 attr_uuid, tGAP_BLE_ATTR_VALUE *p_value)
|
||||
p_db_attr->attr_value.addr_resolution = p_value->addr_resolution;
|
||||
break;
|
||||
|
||||
#if (BT_GATTS_SECURITY_LEVELS_CHAR == TRUE)
|
||||
case GATT_UUID_GAP_GATT_SECURITY_LEVELS:
|
||||
p_db_attr->attr_value.security_level = p_value->security_level;
|
||||
break;
|
||||
#endif // (BT_GATTS_SECURITY_LEVELS_CHAR == TRUE)
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -119,6 +119,9 @@ typedef union {
|
||||
UINT16 icon;
|
||||
UINT8 *p_dev_name;
|
||||
UINT8 addr_resolution;
|
||||
#if (BT_GATTS_SECURITY_LEVELS_CHAR == TRUE)
|
||||
UINT16 security_level;
|
||||
#endif // (BT_GATTS_SECURITY_LEVELS_CHAR == TRUE)
|
||||
|
||||
} tGAP_BLE_ATTR_VALUE;
|
||||
|
||||
|
||||
@@ -52,6 +52,8 @@
|
||||
#define GATT_UUID_GAP_PREF_CONN_PARAM 0x2A04
|
||||
#define GATT_UUID_GAP_CENTRAL_ADDR_RESOL 0x2AA6
|
||||
|
||||
#define GATT_UUID_GAP_GATT_SECURITY_LEVELS 0x2BF5
|
||||
|
||||
/* Attribute Profile Attribute UUID */
|
||||
#define GATT_UUID_GATT_SRV_CHGD 0x2A05
|
||||
/* Attribute Protocol Test */
|
||||
@@ -81,7 +83,7 @@
|
||||
#define GATT_UUID_GM_CONTROL_POINT 0x2A52
|
||||
#define GATT_UUID_GM_FEATURE 0x2A51
|
||||
|
||||
/* device infor characteristic */
|
||||
/* device information characteristic */
|
||||
#define GATT_UUID_SYSTEM_ID 0x2A23
|
||||
#define GATT_UUID_MODEL_NUMBER_STR 0x2A24
|
||||
#define GATT_UUID_SERIAL_NUMBER_STR 0x2A25
|
||||
|
||||
Reference in New Issue
Block a user