From 450f900e227b2d10d1afe470ee50d004eb819107 Mon Sep 17 00:00:00 2001 From: xiongweichao Date: Wed, 26 Mar 2025 10:42:21 +0800 Subject: [PATCH] fix(bt/bluedroid): fix the issue of connection failure when initializing multiple profiles - Due to the number of service security records exceeding the maximum value, the connection failed --- .../common/include/common/bt_target.h | 77 ++++++++++++++++++- 1 file changed, 75 insertions(+), 2 deletions(-) diff --git a/components/bt/host/bluedroid/common/include/common/bt_target.h b/components/bt/host/bluedroid/common/include/common/bt_target.h index 72df53cd5d..7d9aa20b28 100644 --- a/components/bt/host/bluedroid/common/include/common/bt_target.h +++ b/components/bt/host/bluedroid/common/include/common/bt_target.h @@ -958,9 +958,82 @@ #define BTM_SEC_MAX_DEVICE_RECORDS UC_BT_SMP_MAX_BONDS #endif -/* The number of security records for services. 32 AS Default*/ +#if BTA_SDP_INCLUDED +#define BTM_SDP_SEC_SERVICE_RECORDS 1 +#else +#define BTM_SDP_SEC_SERVICE_RECORDS 0 +#endif + +#if BTA_AG_INCLUDED +#define BTM_AG_SEC_SERVICE_RECORDS 1 +#else +#define BTM_AG_SEC_SERVICE_RECORDS 0 +#endif + +#if BTA_HF_INCLUDED +#define BTM_HF_SEC_SERVICE_RECORDS 1 +#else +#define BTM_HF_SEC_SERVICE_RECORDS 0 +#endif + +#if BTA_JV_INCLUDED +#define BTM_JV_SEC_SERVICE_RECORDS (MAX_RFC_PORTS - BTM_HF_SEC_SERVICE_RECORDS - BTM_AG_SEC_SERVICE_RECORDS) +#else +#define BTM_JV_SEC_SERVICE_RECORDS 0 +#endif + +#if AVCT_INCLUDED +#if AVCT_BROWSE_INCLUDED +#define BTM_AVCT_SEC_SERVICE_RECORDS 2 +#else +#define BTM_AVCT_SEC_SERVICE_RECORDS 1 +#endif // AVCT_BROWSE_INCLUDED +#else +#define BTM_AVCT_SEC_SERVICE_RECORDS 0 +#endif + +#if AVDT_INCLUDED +#if AVDT_REPORTING +#define BTM_AVDT_SEC_SERVICE_RECORDS 3 +#else +#define BTM_AVDT_SEC_SERVICE_RECORDS 2 +#endif // AVDT_INCLUDED +#else +#define BTM_AVDT_SEC_SERVICE_RECORDS 0 +#endif + +#if GAP_CONN_INCLUDED +#define BTM_GAP_SEC_SERVICE_RECORDS GAP_MAX_CONNECTIONS +#else +#define BTM_GAP_SEC_SERVICE_RECORDS 0 +#endif + +#if HID_DEV_INCLUDED +#define BTM_HIDD_SEC_SERVICE_RECORDS 3 +#else +#define BTM_HIDD_SEC_SERVICE_RECORDS 0 +#endif + +#if HID_HOST_INCLUDED +#define BTM_HIDH_SEC_SERVICE_RECORDS 3 +#else +#define BTM_HIDH_SEC_SERVICE_RECORDS 0 +#endif + +#if BLE_INCLUDED +#define BTM_GATT_SEC_SERVICE_RECORDS 1 +#else +#define BTM_GATT_SEC_SERVICE_RECORDS 0 +#endif + +#define BTM_SEC_DEV_SERVICE_RECORDS 1 + +/* The number of security records for services. */ #ifndef BTM_SEC_MAX_SERVICE_RECORDS -#define BTM_SEC_MAX_SERVICE_RECORDS 8 // 32 +#define BTM_SEC_MAX_SERVICE_RECORDS (BTM_SDP_SEC_SERVICE_RECORDS + BTM_AG_SEC_SERVICE_RECORDS \ + + BTM_AVCT_SEC_SERVICE_RECORDS + BTM_AVDT_SEC_SERVICE_RECORDS + BTM_GAP_SEC_SERVICE_RECORDS \ + + BTM_HIDD_SEC_SERVICE_RECORDS + BTM_GATT_SEC_SERVICE_RECORDS + BTM_JV_SEC_SERVICE_RECORDS \ + + BTM_HIDH_SEC_SERVICE_RECORDS + BTM_SEC_DEV_SERVICE_RECORDS + BTM_HF_SEC_SERVICE_RECORDS) #endif /* If True, force a retrieval of remote device name for each bond in case it's changed */