From 0d7b0c885c87d9722ffaa8e583d6a567e530dd07 Mon Sep 17 00:00:00 2001 From: Mitch Cairns Date: Sun, 2 Feb 2025 17:11:33 -0800 Subject: [PATCH 1/2] feat(bt): Implement SDK Config SDP size options Closes https://github.com/espressif/esp-idf/pull/15321 --- components/bt/host/bluedroid/Kconfig.in | 20 +++++++++++++++++++ .../include/common/bluedroid_user_config.h | 14 +++++++++++++ .../common/include/common/bt_target.h | 9 +++++++-- 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/components/bt/host/bluedroid/Kconfig.in b/components/bt/host/bluedroid/Kconfig.in index a4659e9666..62519ec47a 100644 --- a/components/bt/host/bluedroid/Kconfig.in +++ b/components/bt/host/bluedroid/Kconfig.in @@ -132,6 +132,26 @@ config BT_SDP_COMMON_ENABLED help This enables common SDP operation, such as SDP record creation and deletion. +config BT_SDP_PAD_LEN + int "BT SDP attributes allocated length (bytes)" + depends on BT_CLASSIC_ENABLED + default 300 + range 300 1024 + help + This is the total size of all SDP attributes allowed. + Any attributes that exceed this size are truncated. + The default value is 300. + +config BT_SDP_ATTR_LEN + int "BT SDP attribute allocated length (bytes)" + depends on BT_CLASSIC_ENABLED + default 400 + range 400 1024 + help + This is the maximum allowed size for a single SDP attribute. + Any attributes that exceed this size are truncated. + The default value is 400. + menuconfig BT_HFP_ENABLE bool "Hands Free/Handset Profile" depends on BT_CLASSIC_ENABLED diff --git a/components/bt/host/bluedroid/common/include/common/bluedroid_user_config.h b/components/bt/host/bluedroid/common/include/common/bluedroid_user_config.h index b3f48a1196..107424b2c7 100644 --- a/components/bt/host/bluedroid/common/include/common/bluedroid_user_config.h +++ b/components/bt/host/bluedroid/common/include/common/bluedroid_user_config.h @@ -73,6 +73,20 @@ #define UC_BT_SDP_COMMON_ENABLED FALSE #endif +// SDP Pad Length +#ifdef CONFIG_BT_SDP_PAD_LEN +#define UC_SDP_MAX_PAD_LEN CONFIG_BT_SDP_PAD_LEN +#else +#define UC_SDP_MAX_PAD_LEN 300 +#endif + +// SDP Max Attribute Length +#ifdef CONFIG_BT_SDP_ATTR_LEN +#define UC_SDP_MAX_ATTR_LEN CONFIG_BT_SDP_ATTR_LEN +#else +#define UC_SDP_MAX_ATTR_LEN 400 +#endif + //HFP(AG) #ifdef CONFIG_BT_HFP_AG_ENABLE #define UC_BT_HFP_AG_ENABLED CONFIG_BT_HFP_AG_ENABLE 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 6716615df5..631ef01e32 100644 --- a/components/bt/host/bluedroid/common/include/common/bt_target.h +++ b/components/bt/host/bluedroid/common/include/common/bt_target.h @@ -1658,12 +1658,17 @@ #endif /* defined(HID_DEV_INCLUDED) && (HID_DEV_INCLUDED==TRUE) */ #endif -#ifndef SDP_MAX_PAD_LEN +/* The maximum length, in bytes, of all SDP attributes combined. */ +#if defined(UC_SDP_MAX_PAD_LEN) +#define SDP_MAX_PAD_LEN UC_SDP_MAX_PAD_LEN +#elif !defined(SDP_MAX_PAD_LEN) #define SDP_MAX_PAD_LEN 300 #endif /* The maximum length, in bytes, of an attribute. */ -#ifndef SDP_MAX_ATTR_LEN +#if defined(UC_SDP_MAX_ATTR_LEN) +#define SDP_MAX_ATTR_LEN UC_SDP_MAX_ATTR_LEN +#elif !defined(SDP_MAX_ATTR_LEN) #define SDP_MAX_ATTR_LEN 400 #endif From 57a52f571dc3f2f7b813f6e6e42df78cc9bb99ea Mon Sep 17 00:00:00 2001 From: gongyantao Date: Fri, 14 Feb 2025 11:34:19 +0800 Subject: [PATCH 2/2] change(bt): optimize the macro definition for sdp_max_pad_len --- components/bt/host/bluedroid/Kconfig.in | 26 +++++++++---------- .../include/common/bluedroid_user_config.h | 6 ++--- .../common/include/common/bt_target.h | 8 ++---- 3 files changed, 18 insertions(+), 22 deletions(-) diff --git a/components/bt/host/bluedroid/Kconfig.in b/components/bt/host/bluedroid/Kconfig.in index 62519ec47a..d0e33b1eaf 100644 --- a/components/bt/host/bluedroid/Kconfig.in +++ b/components/bt/host/bluedroid/Kconfig.in @@ -133,25 +133,25 @@ config BT_SDP_COMMON_ENABLED This enables common SDP operation, such as SDP record creation and deletion. config BT_SDP_PAD_LEN - int "BT SDP attributes allocated length (bytes)" + int "One or more BT SDP attributes total allocated length (bytes)" + depends on BT_CLASSIC_ENABLED + default 300 + range BT_SDP_ATTR_LEN 1024 + help + This is the total size of all SDP attributes allowed. + Any attributes that exceed this size are truncated. + The default value is 300. + +config BT_SDP_ATTR_LEN + int "Single BT SDP attribute allocated length (bytes)" depends on BT_CLASSIC_ENABLED default 300 range 300 1024 help - This is the total size of all SDP attributes allowed. - Any attributes that exceed this size are truncated. + This is the maximum allowed size for a single SDP attribute. + Any attributes that exceed this size are truncated. The default value is 300. -config BT_SDP_ATTR_LEN - int "BT SDP attribute allocated length (bytes)" - depends on BT_CLASSIC_ENABLED - default 400 - range 400 1024 - help - This is the maximum allowed size for a single SDP attribute. - Any attributes that exceed this size are truncated. - The default value is 400. - menuconfig BT_HFP_ENABLE bool "Hands Free/Handset Profile" depends on BT_CLASSIC_ENABLED diff --git a/components/bt/host/bluedroid/common/include/common/bluedroid_user_config.h b/components/bt/host/bluedroid/common/include/common/bluedroid_user_config.h index 107424b2c7..fd758e02ec 100644 --- a/components/bt/host/bluedroid/common/include/common/bluedroid_user_config.h +++ b/components/bt/host/bluedroid/common/include/common/bluedroid_user_config.h @@ -76,15 +76,15 @@ // SDP Pad Length #ifdef CONFIG_BT_SDP_PAD_LEN #define UC_SDP_MAX_PAD_LEN CONFIG_BT_SDP_PAD_LEN -#else +#else #define UC_SDP_MAX_PAD_LEN 300 #endif // SDP Max Attribute Length #ifdef CONFIG_BT_SDP_ATTR_LEN #define UC_SDP_MAX_ATTR_LEN CONFIG_BT_SDP_ATTR_LEN -#else -#define UC_SDP_MAX_ATTR_LEN 400 +#else +#define UC_SDP_MAX_ATTR_LEN 300 #endif //HFP(AG) 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 631ef01e32..2b269d068a 100644 --- a/components/bt/host/bluedroid/common/include/common/bt_target.h +++ b/components/bt/host/bluedroid/common/include/common/bt_target.h @@ -1659,17 +1659,13 @@ #endif /* The maximum length, in bytes, of all SDP attributes combined. */ -#if defined(UC_SDP_MAX_PAD_LEN) +#ifndef SDP_MAX_PAD_LEN #define SDP_MAX_PAD_LEN UC_SDP_MAX_PAD_LEN -#elif !defined(SDP_MAX_PAD_LEN) -#define SDP_MAX_PAD_LEN 300 #endif /* The maximum length, in bytes, of an attribute. */ -#if defined(UC_SDP_MAX_ATTR_LEN) +#ifndef SDP_MAX_ATTR_LEN #define SDP_MAX_ATTR_LEN UC_SDP_MAX_ATTR_LEN -#elif !defined(SDP_MAX_ATTR_LEN) -#define SDP_MAX_ATTR_LEN 400 #endif /* The maximum number of attribute filters supported by SDP databases. */