forked from espressif/esp-idf
Merge branch 'feat/support_ble_notify_reg_max' into 'master'
feat(bt/bluedroid): Support BLE gattc notify registration number See merge request espressif/esp-idf!26641
This commit is contained in:
@@ -250,6 +250,14 @@ config BT_GATTC_MAX_CACHE_CHAR
|
|||||||
help
|
help
|
||||||
Maximum GATTC cache characteristic count
|
Maximum GATTC cache characteristic count
|
||||||
|
|
||||||
|
config BT_GATTC_NOTIF_REG_MAX
|
||||||
|
int "Max gattc notify(indication) register number"
|
||||||
|
depends on BT_GATTC_ENABLE
|
||||||
|
range 1 64
|
||||||
|
default 5
|
||||||
|
help
|
||||||
|
Maximum GATTC notify(indication) register number
|
||||||
|
|
||||||
config BT_GATTC_CACHE_NVS_FLASH
|
config BT_GATTC_CACHE_NVS_FLASH
|
||||||
bool "Save gattc cache data to nvs flash"
|
bool "Save gattc cache data to nvs flash"
|
||||||
depends on BT_GATTC_ENABLE
|
depends on BT_GATTC_ENABLE
|
||||||
|
@@ -932,7 +932,7 @@ tBTA_GATT_STATUS BTA_GATTC_RegisterForNotifications (tBTA_GATTC_IF client_if,
|
|||||||
}
|
}
|
||||||
if (i == BTA_GATTC_NOTIF_REG_MAX) {
|
if (i == BTA_GATTC_NOTIF_REG_MAX) {
|
||||||
status = BTA_GATT_NO_RESOURCES;
|
status = BTA_GATT_NO_RESOURCES;
|
||||||
APPL_TRACE_ERROR("Max Notification Reached, registration failed.");
|
APPL_TRACE_ERROR("Max Notification Reached, registration failed,see CONFIG_BT_GATTC_NOTIF_REG_MAX in menuconfig");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@@ -319,10 +319,6 @@ typedef struct {
|
|||||||
bool update_incl_srvc;
|
bool update_incl_srvc;
|
||||||
} tBTA_GATTC_SERV;
|
} tBTA_GATTC_SERV;
|
||||||
|
|
||||||
#ifndef BTA_GATTC_NOTIF_REG_MAX
|
|
||||||
#define BTA_GATTC_NOTIF_REG_MAX BTA_GATTC_CONN_MAX
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
BOOLEAN in_use;
|
BOOLEAN in_use;
|
||||||
BD_ADDR remote_bda;
|
BD_ADDR remote_bda;
|
||||||
|
@@ -163,6 +163,13 @@
|
|||||||
#define UC_BT_GATTC_MAX_CACHE_CHAR 40
|
#define UC_BT_GATTC_MAX_CACHE_CHAR 40
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//GATTC NOTIF
|
||||||
|
#ifdef CONFIG_BT_GATTC_NOTIF_REG_MAX
|
||||||
|
#define UC_BT_GATTC_NOTIF_REG_MAX CONFIG_BT_GATTC_NOTIF_REG_MAX
|
||||||
|
#else
|
||||||
|
#define UC_BT_GATTC_NOTIF_REG_MAX 5
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_BT_GATTC_CACHE_NVS_FLASH
|
#ifdef CONFIG_BT_GATTC_CACHE_NVS_FLASH
|
||||||
#define UC_BT_GATTC_CACHE_NVS_FLASH_ENABLED CONFIG_BT_GATTC_CACHE_NVS_FLASH
|
#define UC_BT_GATTC_CACHE_NVS_FLASH_ENABLED CONFIG_BT_GATTC_CACHE_NVS_FLASH
|
||||||
#else
|
#else
|
||||||
|
@@ -248,6 +248,12 @@
|
|||||||
#define GATTC_CONNECT_RETRY_EN FALSE
|
#define GATTC_CONNECT_RETRY_EN FALSE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef UC_BT_GATTC_NOTIF_REG_MAX
|
||||||
|
#define BTA_GATTC_NOTIF_REG_MAX UC_BT_GATTC_NOTIF_REG_MAX
|
||||||
|
#else
|
||||||
|
#define BTA_GATTC_NOTIF_REG_MAX 5
|
||||||
|
#endif
|
||||||
|
|
||||||
#if (UC_BT_SMP_ENABLE)
|
#if (UC_BT_SMP_ENABLE)
|
||||||
#define SMP_INCLUDED TRUE
|
#define SMP_INCLUDED TRUE
|
||||||
#if (BLE_INCLUDED == TRUE)
|
#if (BLE_INCLUDED == TRUE)
|
||||||
|
@@ -1173,39 +1173,39 @@ tGATT_STATUS gatts_write_attr_perm_check (tGATT_SVC_DB *p_db, UINT8 op_code,
|
|||||||
|
|
||||||
if ((op_code == GATT_SIGN_CMD_WRITE) && !(perm & GATT_WRITE_SIGNED_PERM)) {
|
if ((op_code == GATT_SIGN_CMD_WRITE) && !(perm & GATT_WRITE_SIGNED_PERM)) {
|
||||||
status = GATT_WRITE_NOT_PERMIT;
|
status = GATT_WRITE_NOT_PERMIT;
|
||||||
GATT_TRACE_DEBUG( "gatts_write_attr_perm_check - sign cmd write not allowed");
|
GATT_TRACE_DEBUG( "gatts_write_attr_perm_check - sign cmd write not allowed,handle:0x%04x",handle);
|
||||||
}
|
}
|
||||||
if ((op_code == GATT_SIGN_CMD_WRITE) && (sec_flag & GATT_SEC_FLAG_ENCRYPTED)) {
|
if ((op_code == GATT_SIGN_CMD_WRITE) && (sec_flag & GATT_SEC_FLAG_ENCRYPTED)) {
|
||||||
status = GATT_INVALID_PDU;
|
status = GATT_INVALID_PDU;
|
||||||
GATT_TRACE_ERROR( "gatts_write_attr_perm_check - Error!! sign cmd write sent on a encypted link");
|
GATT_TRACE_ERROR( "gatts_write_attr_perm_check - Error!! sign cmd write sent on a encypted link,handle:0x%04x",handle);
|
||||||
} else if (!(perm & GATT_WRITE_ALLOWED)) {
|
} else if (!(perm & GATT_WRITE_ALLOWED)) {
|
||||||
status = GATT_WRITE_NOT_PERMIT;
|
status = GATT_WRITE_NOT_PERMIT;
|
||||||
GATT_TRACE_ERROR( "gatts_write_attr_perm_check - GATT_WRITE_NOT_PERMIT");
|
GATT_TRACE_ERROR( "gatts_write_attr_perm_check - GATT_WRITE_NOT_PERMIT,handle:0x%04x",handle);
|
||||||
}
|
}
|
||||||
/* require authentication, but not been authenticated */
|
/* require authentication, but not been authenticated */
|
||||||
else if ((perm & GATT_WRITE_AUTH_REQUIRED ) && !(sec_flag & GATT_SEC_FLAG_LKEY_UNAUTHED)) {
|
else if ((perm & GATT_WRITE_AUTH_REQUIRED ) && !(sec_flag & GATT_SEC_FLAG_LKEY_UNAUTHED)) {
|
||||||
status = GATT_INSUF_AUTHENTICATION;
|
status = GATT_INSUF_AUTHENTICATION;
|
||||||
GATT_TRACE_ERROR( "gatts_write_attr_perm_check - GATT_INSUF_AUTHENTICATION");
|
GATT_TRACE_ERROR( "gatts_write_attr_perm_check - GATT_INSUF_AUTHENTICATION,handle:0x%04x",handle);
|
||||||
} else if ((perm & GATT_WRITE_MITM_REQUIRED ) && !(sec_flag & GATT_SEC_FLAG_LKEY_AUTHED)) {
|
} else if ((perm & GATT_WRITE_MITM_REQUIRED ) && !(sec_flag & GATT_SEC_FLAG_LKEY_AUTHED)) {
|
||||||
status = GATT_INSUF_AUTHENTICATION;
|
status = GATT_INSUF_AUTHENTICATION;
|
||||||
GATT_TRACE_ERROR( "gatts_write_attr_perm_check - GATT_INSUF_AUTHENTICATION: MITM required");
|
GATT_TRACE_ERROR( "gatts_write_attr_perm_check - GATT_INSUF_AUTHENTICATION: MITM required,handle:0x%04x",handle);
|
||||||
} else if ((perm & GATT_WRITE_ENCRYPTED_PERM ) && !(sec_flag & GATT_SEC_FLAG_ENCRYPTED)) {
|
} else if ((perm & GATT_WRITE_ENCRYPTED_PERM ) && !(sec_flag & GATT_SEC_FLAG_ENCRYPTED)) {
|
||||||
status = GATT_INSUF_ENCRYPTION;
|
status = GATT_INSUF_ENCRYPTION;
|
||||||
GATT_TRACE_ERROR( "gatts_write_attr_perm_check - GATT_INSUF_ENCRYPTION");
|
GATT_TRACE_ERROR( "gatts_write_attr_perm_check - GATT_INSUF_ENCRYPTION,handle:0x%04x",handle);
|
||||||
} else if ((perm & GATT_WRITE_ENCRYPTED_PERM ) && (sec_flag & GATT_SEC_FLAG_ENCRYPTED) && (key_size < min_key_size)) {
|
} else if ((perm & GATT_WRITE_ENCRYPTED_PERM ) && (sec_flag & GATT_SEC_FLAG_ENCRYPTED) && (key_size < min_key_size)) {
|
||||||
status = GATT_INSUF_KEY_SIZE;
|
status = GATT_INSUF_KEY_SIZE;
|
||||||
GATT_TRACE_ERROR( "gatts_write_attr_perm_check - GATT_INSUF_KEY_SIZE");
|
GATT_TRACE_ERROR( "gatts_write_attr_perm_check - GATT_INSUF_KEY_SIZE,handle:0x%04x",handle);
|
||||||
}
|
}
|
||||||
/* LE Authorization check*/
|
/* LE Authorization check*/
|
||||||
else if ((perm & GATT_WRITE_AUTHORIZATION) && (!(sec_flag & GATT_SEC_FLAG_LKEY_AUTHED) || !(sec_flag & GATT_SEC_FLAG_AUTHORIZATION))){
|
else if ((perm & GATT_WRITE_AUTHORIZATION) && (!(sec_flag & GATT_SEC_FLAG_LKEY_AUTHED) || !(sec_flag & GATT_SEC_FLAG_AUTHORIZATION))){
|
||||||
status = GATT_INSUF_AUTHORIZATION;
|
status = GATT_INSUF_AUTHORIZATION;
|
||||||
GATT_TRACE_ERROR( "gatts_write_attr_perm_check - GATT_INSUF_AUTHORIZATION");
|
GATT_TRACE_ERROR( "gatts_write_attr_perm_check - GATT_INSUF_AUTHORIZATION,handle:0x%04x",handle);
|
||||||
}
|
}
|
||||||
/* LE security mode 2 attribute */
|
/* LE security mode 2 attribute */
|
||||||
else if (perm & GATT_WRITE_SIGNED_PERM && op_code != GATT_SIGN_CMD_WRITE && !(sec_flag & GATT_SEC_FLAG_ENCRYPTED)
|
else if (perm & GATT_WRITE_SIGNED_PERM && op_code != GATT_SIGN_CMD_WRITE && !(sec_flag & GATT_SEC_FLAG_ENCRYPTED)
|
||||||
&& (perm & GATT_WRITE_ALLOWED) == 0) {
|
&& (perm & GATT_WRITE_ALLOWED) == 0) {
|
||||||
status = GATT_INSUF_AUTHENTICATION;
|
status = GATT_INSUF_AUTHENTICATION;
|
||||||
GATT_TRACE_ERROR( "gatts_write_attr_perm_check - GATT_INSUF_AUTHENTICATION: LE security mode 2 required");
|
GATT_TRACE_ERROR( "gatts_write_attr_perm_check - GATT_INSUF_AUTHENTICATION: LE security mode 2 required,handle:0x%04x",handle);
|
||||||
} else { /* writable: must be char value declaration or char descritpors */
|
} else { /* writable: must be char value declaration or char descritpors */
|
||||||
if (p_attr->uuid_type == GATT_ATTR_UUID_TYPE_16) {
|
if (p_attr->uuid_type == GATT_ATTR_UUID_TYPE_16) {
|
||||||
switch (p_attr->uuid) {
|
switch (p_attr->uuid) {
|
||||||
@@ -1246,10 +1246,10 @@ tGATT_STATUS gatts_write_attr_perm_check (tGATT_SVC_DB *p_db, UINT8 op_code,
|
|||||||
{
|
{
|
||||||
if (op_code == GATT_REQ_PREPARE_WRITE && offset != 0) { /* does not allow write blob */
|
if (op_code == GATT_REQ_PREPARE_WRITE && offset != 0) { /* does not allow write blob */
|
||||||
status = GATT_NOT_LONG;
|
status = GATT_NOT_LONG;
|
||||||
GATT_TRACE_ERROR( "gatts_write_attr_perm_check - GATT_NOT_LONG");
|
GATT_TRACE_ERROR( "gatts_write_attr_perm_check - GATT_NOT_LONG,handle:0x%04x",handle);
|
||||||
} else if (len != max_size) { /* data does not match the required format */
|
} else if (len != max_size) { /* data does not match the required format */
|
||||||
status = GATT_INVALID_ATTR_LEN;
|
status = GATT_INVALID_ATTR_LEN;
|
||||||
GATT_TRACE_ERROR( "gatts_write_attr_perm_check - GATT_INVALID_PDU");
|
GATT_TRACE_ERROR( "gatts_write_attr_perm_check - GATT_INVALID_PDU,handle:0x%04x",handle);
|
||||||
} else {
|
} else {
|
||||||
status = GATT_SUCCESS;
|
status = GATT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@@ -7,3 +7,4 @@ CONFIG_BT_BLE_ENABLED=y
|
|||||||
CONFIG_BT_HID_ENABLED=y
|
CONFIG_BT_HID_ENABLED=y
|
||||||
CONFIG_BT_HID_HOST_ENABLED=y
|
CONFIG_BT_HID_HOST_ENABLED=y
|
||||||
CONFIG_BT_BLE_42_FEATURES_SUPPORTED=y
|
CONFIG_BT_BLE_42_FEATURES_SUPPORTED=y
|
||||||
|
CONFIG_BT_GATTC_NOTIF_REG_MAX=16
|
||||||
|
Reference in New Issue
Block a user