From 1cfb537813dd7b77a27283c2e3f40cce17588153 Mon Sep 17 00:00:00 2001 From: liqigan Date: Tue, 10 Sep 2024 17:59:25 +0800 Subject: [PATCH] fix(bt/bluedroid): Fixed the SDP API compatibility bug --- components/bt/host/bluedroid/Kconfig.in | 1 + .../bluedroid/api/include/api/esp_sdp_api.h | 84 ++++++++++--------- .../bt/host/bluedroid/bta/sdp/bta_sdp_act.c | 24 +++--- .../btc/profile/std/include/bt_sdp.h | 76 +++++++++-------- .../bluedroid/btc/profile/std/sdp/btc_sdp.c | 38 ++++----- .../release-5.x/5.4/bluetooth-classic.rst | 4 +- .../release-5.x/5.4/bluetooth-classic.rst | 4 +- .../classic_bt/bt_l2cap_client/main/main.c | 6 +- .../classic_bt/bt_l2cap_server/main/main.c | 6 +- 9 files changed, 117 insertions(+), 126 deletions(-) diff --git a/components/bt/host/bluedroid/Kconfig.in b/components/bt/host/bluedroid/Kconfig.in index 53a3755c79..e5769d1959 100644 --- a/components/bt/host/bluedroid/Kconfig.in +++ b/components/bt/host/bluedroid/Kconfig.in @@ -126,6 +126,7 @@ config BT_L2CAP_ENABLED config BT_SDP_COMMON_ENABLED bool "BT SDP COMMON" depends on BT_CLASSIC_ENABLED + default y if BT_L2CAP_ENABLED default n help This enables common SDP operation, such as SDP record creation and deletion. diff --git a/components/bt/host/bluedroid/api/include/api/esp_sdp_api.h b/components/bt/host/bluedroid/api/include/api/esp_sdp_api.h index 99bf61be3f..42b134c8cb 100644 --- a/components/bt/host/bluedroid/api/include/api/esp_sdp_api.h +++ b/components/bt/host/bluedroid/api/include/api/esp_sdp_api.h @@ -65,64 +65,66 @@ typedef enum { /** * @brief SDP header structure */ -typedef struct { - esp_bluetooth_sdp_types_t type; /*!< SDP type */ - uint32_t service_name_length; /*!< Service name length */ - char *service_name; /*!< Service name */ - int32_t rfcomm_channel_number; /*!< RFCOMM channel number, if not used set to -1*/ - int32_t l2cap_psm; /*!< L2CAP psm, if not used set to -1 */ - int32_t profile_version; /*!< Profile version */ -} esp_bluetooth_sdp_hdr_t; +typedef struct bluetooth_sdp_hdr_overlay { + esp_bluetooth_sdp_types_t type; /*!< SDP type */ + esp_bt_uuid_t uuid; /*!< UUID type, include uuid and uuid length, only needed to be set for RAW record creation */ + uint32_t service_name_length; /*!< Service name length */ + char *service_name; /*!< Service name */ + int32_t rfcomm_channel_number; /*!< RFCOMM channel number, if not used set to -1*/ + int32_t l2cap_psm; /*!< L2CAP psm, if not used set to -1 */ + int32_t profile_version; /*!< Profile version */ + int user1_ptr_len; /*!< User data1 length, only used for searching RAW record */ + uint8_t *user1_ptr; /*!< User data1 pointer to the raw SDP response data, only used for searching RAW record */ + int user2_ptr_len __attribute__((deprecated)); /*!< User data2 length, only used for searching RAW record */ + uint8_t *user2_ptr __attribute__((deprecated)); /*!< User data2 pointer, only used for searching RAW record */ +} esp_bluetooth_sdp_hdr_overlay_t; /** * @brief Raw SDP record */ -typedef struct { - esp_bluetooth_sdp_hdr_t hdr; /*!< General info */ - esp_bt_uuid_t uuid; /*!< UUID type, include uuid and uuid length */ - int user1_ptr_len; /*!< Length of raw SDP data */ - uint8_t *user1_ptr; /*!< Raw SDP data */ +typedef struct bluetooth_sdp_raw_record { + esp_bluetooth_sdp_hdr_overlay_t hdr; /*!< General info */ } esp_bluetooth_sdp_raw_record_t; /** * @brief Message Access Profile - Server parameters */ -typedef struct { - esp_bluetooth_sdp_hdr_t hdr; /*!< General info */ - uint32_t mas_instance_id; /*!< MAS Instance ID */ - uint32_t supported_features; /*!< Map supported features */ - uint32_t supported_message_types; /*!< Supported message types */ +typedef struct bluetooth_sdp_mas_record { + esp_bluetooth_sdp_hdr_overlay_t hdr; /*!< General info */ + uint32_t mas_instance_id; /*!< MAS Instance ID */ + uint32_t supported_features; /*!< Map supported features */ + uint32_t supported_message_types; /*!< Supported message types */ } esp_bluetooth_sdp_mas_record_t; /** * @brief Message Access Profile - Client (Notification Server) parameters */ -typedef struct { - esp_bluetooth_sdp_hdr_t hdr; /*!< General info */ - uint32_t supported_features; /*!< Supported features */ +typedef struct bluetooth_sdp_mns_record { + esp_bluetooth_sdp_hdr_overlay_t hdr; /*!< General info */ + uint32_t supported_features; /*!< Supported features */ } esp_bluetooth_sdp_mns_record_t; /** * @brief Phone Book Profile - Server parameters */ -typedef struct { - esp_bluetooth_sdp_hdr_t hdr; /*!< General info */ - uint32_t supported_features; /*!< PBAP Supported Features */ - uint32_t supported_repositories; /*!< Supported Repositories */ +typedef struct bluetooth_sdp_pse_record { + esp_bluetooth_sdp_hdr_overlay_t hdr; /*!< General info */ + uint32_t supported_features; /*!< PBAP Supported Features */ + uint32_t supported_repositories; /*!< Supported Repositories */ } esp_bluetooth_sdp_pse_record_t; /** * @brief Phone Book Profile - Client parameters */ -typedef struct { - esp_bluetooth_sdp_hdr_t hdr; /*!< General info */ +typedef struct bluetooth_sdp_pce_record { + esp_bluetooth_sdp_hdr_overlay_t hdr; /*!< General info */ } esp_bluetooth_sdp_pce_record_t; /** * @brief Object Push Profile parameters */ -typedef struct { - esp_bluetooth_sdp_hdr_t hdr; /*!< General info */ +typedef struct bluetooth_sdp_ops_record { + esp_bluetooth_sdp_hdr_overlay_t hdr; /*!< General info */ int supported_formats_list_len; /*!< Supported formats list length */ uint8_t supported_formats_list[SDP_OPP_SUPPORTED_FORMATS_MAX_LENGTH]; /*!< Supported formats list */ } esp_bluetooth_sdp_ops_record_t; @@ -130,8 +132,8 @@ typedef struct { /** * @brief SIM Access Profile parameters */ -typedef struct { - esp_bluetooth_sdp_hdr_t hdr; /*!< General info */ +typedef struct bluetooth_sdp_sap_record { + esp_bluetooth_sdp_hdr_overlay_t hdr; /*!< General info */ } esp_bluetooth_sdp_sap_record_t; /** @@ -148,21 +150,21 @@ typedef enum { * @note Only one primary Device Identification service record can be added in the SDP database. If primary * Device Identification service is created multiple times, only the last one will take effect. */ -typedef struct { - esp_bluetooth_sdp_hdr_t hdr; /*!< General info */ - uint16_t vendor; /*!< Vendor ID */ - uint16_t vendor_id_source; /*!< Vendor ID source, 0x0001 for Bluetooth, 0x0002 for USB, other values reserved, see `esp_sdp_vendor_id_source_t` */ - uint16_t product; /*!< Product ID */ - uint16_t version; /*!< Release version in format 0xJJMN(JJ – major number, M – minor number, N – sub-minor number) */ - bool primary_record; /*!< Indicate if the record is primary, shall set to true if there is a only single device - record, others shall be set to false */ +typedef struct bluetooth_sdp_dip_record { + esp_bluetooth_sdp_hdr_overlay_t hdr; /*!< General info */ + uint16_t vendor; /*!< Vendor ID */ + uint16_t vendor_id_source; /*!< Vendor ID source, 0x0001 for Bluetooth, 0x0002 for USB, other values reserved, see `esp_sdp_vendor_id_source_t` */ + uint16_t product; /*!< Product ID */ + uint16_t version; /*!< Release version in format 0xJJMN(JJ – major number, M – minor number, N – sub-minor number) */ + bool primary_record; /*!< Indicate if the record is primary, shall set to true if there is a only single device + record, others shall be set to false */ } esp_bluetooth_sdp_dip_record_t; /** * @brief SDP record parameters union */ typedef union { - esp_bluetooth_sdp_hdr_t hdr; /*!< General info */ + esp_bluetooth_sdp_hdr_overlay_t hdr; /*!< General info */ esp_bluetooth_sdp_raw_record_t raw; /*!< Raw SDP search data for unknown UUIDs */ esp_bluetooth_sdp_mas_record_t mas; /*!< Message Access Profile - Server */ esp_bluetooth_sdp_mns_record_t mns; /*!< Message Access Profile - Client (Notification Server) */ @@ -205,7 +207,7 @@ typedef union { /** * @brief ESP_SDP_CREATE_RECORD_COMP_EVT */ - struct sdp_crate_record_evt_param { + struct sdp_create_record_evt_param { esp_sdp_status_t status; /*!< Status */ int record_handle; /*!< SDP record handle */ } create_record; /*!< SDP callback param of ESP_SDP_CREATE_RECORD_COMP_EVT */ diff --git a/components/bt/host/bluedroid/bta/sdp/bta_sdp_act.c b/components/bt/host/bluedroid/bta/sdp/bta_sdp_act.c index 2ece2df56d..39d5e2895b 100644 --- a/components/bt/host/bluedroid/bta/sdp/bta_sdp_act.c +++ b/components/bt/host/bluedroid/bta/sdp/bta_sdp_act.c @@ -395,29 +395,29 @@ static void bta_create_raw_sdp_record(bluetooth_sdp_record *record, tSDP_DISC_RE tSDP_DISC_ATTR *p_attr; tSDP_PROTOCOL_ELEM pe; - record->hdr.type = SDP_TYPE_RAW; - record->hdr.service_name_length = 0; - record->hdr.service_name = NULL; - record->hdr.rfcomm_channel_number = -1; - record->hdr.l2cap_psm = -1; - record->hdr.profile_version = -1; + record->raw.hdr.type = SDP_TYPE_RAW; + record->raw.hdr.service_name_length = 0; + record->raw.hdr.service_name = NULL; + record->raw.hdr.rfcomm_channel_number = -1; + record->raw.hdr.l2cap_psm = -1; + record->raw.hdr.profile_version = -1; /* Try to extract a service name */ if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_SERVICE_NAME)) != NULL) { - record->pse.hdr.service_name_length = SDP_DISC_ATTR_LEN(p_attr->attr_len_type); - record->pse.hdr.service_name = (char *)p_attr->attr_value.v.array; + record->raw.hdr.service_name_length = SDP_DISC_ATTR_LEN(p_attr->attr_len_type); + record->raw.hdr.service_name = (char *)p_attr->attr_value.v.array; } if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_GOEP_L2CAP_PSM)) != NULL) { - record->hdr.l2cap_psm = p_attr->attr_value.v.u16; + record->raw.hdr.l2cap_psm = p_attr->attr_value.v.u16; } /* Try to extract an RFCOMM channel */ if (SDP_FindProtocolListElemInRec(p_rec, UUID_PROTOCOL_RFCOMM, &pe)) { - record->pse.hdr.rfcomm_channel_number = pe.params[0]; + record->raw.hdr.rfcomm_channel_number = pe.params[0]; } - record->raw.user1_ptr_len = p_bta_sdp_cfg->p_sdp_db->raw_size; - record->raw.user1_ptr = p_bta_sdp_cfg->p_sdp_db->raw_data; + record->raw.hdr.user1_ptr_len = p_bta_sdp_cfg->p_sdp_db->raw_size; + record->raw.hdr.user1_ptr = p_bta_sdp_cfg->p_sdp_db->raw_data; } diff --git a/components/bt/host/bluedroid/btc/profile/std/include/bt_sdp.h b/components/bt/host/bluedroid/btc/profile/std/include/bt_sdp.h index 5c7202a7ae..69fac9d6cb 100644 --- a/components/bt/host/bluedroid/btc/profile/std/include/bt_sdp.h +++ b/components/bt/host/bluedroid/btc/profile/std/include/bt_sdp.h @@ -38,73 +38,79 @@ typedef enum { SDP_TYPE_DIP_SERVER, // Device Identification Profile } bluetooth_sdp_types; -typedef struct _bluetooth_sdp_hdr { +/** + * Some signals need additional pointers, hence we introduce a + * generic way to handle these pointers. + */ +typedef struct _bluetooth_sdp_hdr_overlay { bluetooth_sdp_types type; + esp_bt_uuid_t uuid; uint32_t service_name_length; char *service_name; int32_t rfcomm_channel_number; int32_t l2cap_psm; int32_t profile_version; -} bluetooth_sdp_hdr; + int user1_ptr_len; + uint8_t *user1_ptr; + int user2_ptr_len; // not used + uint8_t *user2_ptr; // not used +} bluetooth_sdp_hdr_overlay; typedef struct _bluetooth_sdp_raw_record { - bluetooth_sdp_hdr hdr; - esp_bt_uuid_t uuid; - int user1_ptr_len; - uint8_t *user1_ptr; + bluetooth_sdp_hdr_overlay hdr; } bluetooth_sdp_raw_record; typedef struct _bluetooth_sdp_mas_record { - bluetooth_sdp_hdr hdr; - uint32_t mas_instance_id; - uint32_t supported_features; - uint32_t supported_message_types; + bluetooth_sdp_hdr_overlay hdr; + uint32_t mas_instance_id; + uint32_t supported_features; + uint32_t supported_message_types; } bluetooth_sdp_mas_record; typedef struct _bluetooth_sdp_mns_record { - bluetooth_sdp_hdr hdr; - uint32_t supported_features; + bluetooth_sdp_hdr_overlay hdr; + uint32_t supported_features; } bluetooth_sdp_mns_record; typedef struct _bluetooth_sdp_pse_record { - bluetooth_sdp_hdr hdr; - uint32_t supported_features; - uint32_t supported_repositories; + bluetooth_sdp_hdr_overlay hdr; + uint32_t supported_features; + uint32_t supported_repositories; } bluetooth_sdp_pse_record; typedef struct _bluetooth_sdp_pce_record { - bluetooth_sdp_hdr hdr; + bluetooth_sdp_hdr_overlay hdr; } bluetooth_sdp_pce_record; typedef struct _bluetooth_sdp_ops_record { - bluetooth_sdp_hdr hdr; - int supported_formats_list_len; - uint8_t supported_formats_list[SDP_OPP_SUPPORTED_FORMATS_MAX_LENGTH]; + bluetooth_sdp_hdr_overlay hdr; + int supported_formats_list_len; + uint8_t supported_formats_list[SDP_OPP_SUPPORTED_FORMATS_MAX_LENGTH]; } bluetooth_sdp_ops_record; typedef struct _bluetooth_sdp_sap_record { - bluetooth_sdp_hdr hdr; + bluetooth_sdp_hdr_overlay hdr; } bluetooth_sdp_sap_record; typedef struct _bluetooth_sdp_dip_record { - bluetooth_sdp_hdr hdr; - uint16_t vendor; - uint16_t vendor_id_source; - uint16_t product; - uint16_t version; - bool primary_record; + bluetooth_sdp_hdr_overlay hdr; + uint16_t vendor; + uint16_t vendor_id_source; + uint16_t product; + uint16_t version; + bool primary_record; } bluetooth_sdp_dip_record; typedef union { - bluetooth_sdp_hdr hdr; - bluetooth_sdp_raw_record raw; - bluetooth_sdp_mas_record mas; - bluetooth_sdp_mns_record mns; - bluetooth_sdp_pse_record pse; - bluetooth_sdp_pce_record pce; - bluetooth_sdp_ops_record ops; - bluetooth_sdp_sap_record sap; - bluetooth_sdp_dip_record dip; + bluetooth_sdp_hdr_overlay hdr; + bluetooth_sdp_raw_record raw; + bluetooth_sdp_mas_record mas; + bluetooth_sdp_mns_record mns; + bluetooth_sdp_pse_record pse; + bluetooth_sdp_pce_record pce; + bluetooth_sdp_ops_record ops; + bluetooth_sdp_sap_record sap; + bluetooth_sdp_dip_record dip; } bluetooth_sdp_record; #endif /* __BT_SDP_H__ */ diff --git a/components/bt/host/bluedroid/btc/profile/std/sdp/btc_sdp.c b/components/bt/host/bluedroid/btc/profile/std/sdp/btc_sdp.c index f395757c7d..75cc0d7d51 100644 --- a/components/bt/host/bluedroid/btc/profile/std/sdp/btc_sdp.c +++ b/components/bt/host/bluedroid/btc/profile/std/sdp/btc_sdp.c @@ -91,11 +91,6 @@ static int get_sdp_record_size(bluetooth_sdp_record* in_record) records_size = sizeof(bluetooth_sdp_record); break; - case SDP_TYPE_RAW: - if (record->raw.user1_ptr != NULL) { - records_size += record->raw.user1_ptr_len; - } - /* fall through */ default: records_size += sizeof(bluetooth_sdp_record); records_size += record->hdr.service_name_length; @@ -254,12 +249,6 @@ static void copy_sdp_record_common(bluetooth_sdp_record* in_record, bluetooth_sd *(free_ptr) = '\0'; // Set '\0' termination of string free_ptr++; } - - if (in_record->hdr.type == SDP_TYPE_RAW && in_record->raw.user1_ptr != NULL) { - out_record->raw.user1_ptr = (UINT8 *)free_ptr; // Update pointer - memcpy(free_ptr, in_record->raw.user1_ptr, in_record->raw.user1_ptr_len); // Copy content - free_ptr += in_record->raw.user1_ptr_len; - } } static void copy_sdp_record(bluetooth_sdp_record* in_record, bluetooth_sdp_record* out_record) @@ -402,6 +391,7 @@ static int add_raw_sdp(const bluetooth_sdp_raw_record *rec) UINT8 temp[LEN_UUID_128]; UINT8* p_temp = temp; UINT32 sdp_handle = 0; + const esp_bt_uuid_t *p_uuid = &rec->hdr.uuid; BTC_TRACE_DEBUG("%s(): scn 0x%02x, psm = 0x%04x\n service name %s", __func__, rec->hdr.rfcomm_channel_number, rec->hdr.l2cap_psm, rec->hdr.service_name); @@ -411,15 +401,15 @@ static int add_raw_sdp(const bluetooth_sdp_raw_record *rec) return sdp_handle; } - if (rec->uuid.len == ESP_UUID_LEN_16) { + if (p_uuid->len == ESP_UUID_LEN_16) { UINT8_TO_BE_STREAM (p_temp, (UUID_DESC_TYPE << 3) | SIZE_TWO_BYTES); - UINT16_TO_BE_STREAM (p_temp, rec->uuid.uuid.uuid16); - } else if (rec->uuid.len == ESP_UUID_LEN_32) { + UINT16_TO_BE_STREAM (p_temp, p_uuid->uuid.uuid16); + } else if (p_uuid->len == ESP_UUID_LEN_32) { UINT8_TO_BE_STREAM (p_temp, (UUID_DESC_TYPE << 3) | SIZE_FOUR_BYTES); - UINT32_TO_BE_STREAM (p_temp, rec->uuid.uuid.uuid32); - } else if (rec->uuid.len == ESP_UUID_LEN_128) { + UINT32_TO_BE_STREAM (p_temp, p_uuid->uuid.uuid32); + } else if (p_uuid->len == ESP_UUID_LEN_128) { UINT8_TO_BE_STREAM (p_temp, (UUID_DESC_TYPE << 3) | SIZE_SIXTEEN_BYTES); - ARRAY_TO_BE_STREAM (p_temp, rec->uuid.uuid.uuid128, LEN_UUID_128); + ARRAY_TO_BE_STREAM (p_temp, p_uuid->uuid.uuid128, LEN_UUID_128); } else { SDP_DeleteRecord(sdp_handle); sdp_handle = 0; @@ -466,12 +456,12 @@ static int add_raw_sdp(const bluetooth_sdp_raw_record *rec) sdp_handle = 0; BTC_TRACE_ERROR("%s() FAILED, status = %d", __func__, status); } else { - if (rec->uuid.len == ESP_UUID_LEN_16) { - bta_sys_add_uuid(rec->uuid.uuid.uuid16); - } else if (rec->uuid.len == ESP_UUID_LEN_32) { - bta_sys_add_uuid_32(rec->uuid.uuid.uuid32); - } else if (rec->uuid.len == ESP_UUID_LEN_128) { - bta_sys_add_uuid_128((UINT8 *)&rec->uuid.uuid.uuid128); + if (p_uuid->len == ESP_UUID_LEN_16) { + bta_sys_add_uuid(p_uuid->uuid.uuid16); + } else if (p_uuid->len == ESP_UUID_LEN_32) { + bta_sys_add_uuid_32(p_uuid->uuid.uuid32); + } else if (p_uuid->len == ESP_UUID_LEN_128) { + bta_sys_add_uuid_128((UINT8 *)&p_uuid->uuid.uuid128); } BTC_TRACE_DEBUG("%s(): SDP Registered (handle 0x%08x)", __func__, sdp_handle); } @@ -943,7 +933,7 @@ static int btc_handle_create_record_event(int id) switch (record->hdr.type) { case SDP_TYPE_RAW: sdp_handle = add_raw_sdp(&record->raw); - memcpy(&service_uuid, &record->raw.uuid, sizeof(esp_bt_uuid_t)); + memcpy(&service_uuid, &record->hdr.uuid, sizeof(esp_bt_uuid_t)); break; case SDP_TYPE_MAP_MAS: sdp_handle = add_maps_sdp(&record->mas); diff --git a/docs/en/migration-guides/release-5.x/5.4/bluetooth-classic.rst b/docs/en/migration-guides/release-5.x/5.4/bluetooth-classic.rst index 2c229ad4a2..df2202b973 100644 --- a/docs/en/migration-guides/release-5.x/5.4/bluetooth-classic.rst +++ b/docs/en/migration-guides/release-5.x/5.4/bluetooth-classic.rst @@ -11,6 +11,4 @@ Bluedroid - :component_file:`/bt/host/bluedroid/api/include/api/esp_sdp_api.h` - - structure ``esp_bluetooth_sdp_hdr_overlay_t`` has been renamed to ``esp_bluetooth_sdp_hdr_t`` - - field ``uuid``, ``user1_ptr_len`` and ``user1_ptr`` in ``esp_bluetooth_sdp_hdr_overlay_t`` have been moved into ``esp_bluetooth_sdp_raw_record_t`` - - field ``user2_ptr_len`` and ``user2_ptr`` in ``esp_bluetooth_sdp_hdr_overlay_t`` have been removed + - Field ``user2_ptr_len`` and ``user2_ptr`` is deprecated in structure ``esp_bluetooth_sdp_hdr_overlay_t``, since they are not used in SDP record creation or searching. diff --git a/docs/zh_CN/migration-guides/release-5.x/5.4/bluetooth-classic.rst b/docs/zh_CN/migration-guides/release-5.x/5.4/bluetooth-classic.rst index b911fc11c5..6249c0bd29 100644 --- a/docs/zh_CN/migration-guides/release-5.x/5.4/bluetooth-classic.rst +++ b/docs/zh_CN/migration-guides/release-5.x/5.4/bluetooth-classic.rst @@ -11,6 +11,4 @@ Bluedroid - :component_file:`/bt/host/bluedroid/api/include/api/esp_sdp_api.h` - - 结构体 ``esp_bluetooth_sdp_hdr_overlay_t`` 被重命名为 ``esp_bluetooth_sdp_hdr_t`` - - 结构体 ``esp_bluetooth_sdp_hdr_overlay_t`` 中的字段 ``uuid``, ``user1_ptr_len`` 和 ``user1_ptr`` 被移动到结构体 ``esp_bluetooth_sdp_raw_record_t`` 中 - - 结构体 ``esp_bluetooth_sdp_hdr_overlay_t`` 中的字段 ``user2_ptr_len`` 和 ``user2_ptr`` 被删除 + - 结构体 ``esp_bluetooth_sdp_hdr_overlay_t`` 中的字段 ``user2_ptr_len`` 和 ``user2_ptr`` 被弃用,因为 SDP 的 API 或者事件中不会用到该字段。 diff --git a/examples/bluetooth/bluedroid/classic_bt/bt_l2cap_client/main/main.c b/examples/bluetooth/bluedroid/classic_bt/bt_l2cap_client/main/main.c index e24684d978..623f341345 100644 --- a/examples/bluetooth/bluedroid/classic_bt/bt_l2cap_client/main/main.c +++ b/examples/bluetooth/bluedroid/classic_bt/bt_l2cap_client/main/main.c @@ -340,15 +340,13 @@ static void esp_hdl_sdp_cb_evt(uint16_t event, void *p_param) ESP_LOGI(SDP_TAG, "ESP_SDP_INIT_EVT: status:%d", sdp_param->init.status); if (sdp_param->init.status == ESP_SDP_SUCCESS) { record.hdr.type = ESP_SDP_TYPE_RAW; + record.hdr.uuid.len = sizeof(UUID_UNKNOWN); + memcpy(record.hdr.uuid.uuid.uuid128, UUID_UNKNOWN, sizeof(UUID_UNKNOWN)); record.hdr.service_name_length = strlen(sdp_service_name) + 1; record.hdr.service_name = sdp_service_name; record.hdr.rfcomm_channel_number = BT_UNUSED_RFCOMM; record.hdr.l2cap_psm = BT_L2CAP_DYNMIC_PSM; record.hdr.profile_version = BT_UNKONWN_PROFILE_VERSION; - record.uuid.len = sizeof(UUID_UNKNOWN); - memcpy(record.uuid.uuid.uuid128, UUID_UNKNOWN, sizeof(UUID_UNKNOWN)); - record.user1_ptr = NULL; - record.user1_ptr_len = 0; esp_sdp_create_record((esp_bluetooth_sdp_record_t *)&record); } break; diff --git a/examples/bluetooth/bluedroid/classic_bt/bt_l2cap_server/main/main.c b/examples/bluetooth/bluedroid/classic_bt/bt_l2cap_server/main/main.c index 254f381834..5a9a6760e4 100644 --- a/examples/bluetooth/bluedroid/classic_bt/bt_l2cap_server/main/main.c +++ b/examples/bluetooth/bluedroid/classic_bt/bt_l2cap_server/main/main.c @@ -250,15 +250,13 @@ static void esp_hdl_sdp_cb_evt(uint16_t event, void *p_param) ESP_LOGI(SDP_TAG, "ESP_SDP_INIT_EVT: status:%d", sdp_param->init.status); if (sdp_param->init.status == ESP_SDP_SUCCESS) { record.hdr.type = ESP_SDP_TYPE_RAW; + record.hdr.uuid.len = sizeof(UUID_UNKNOWN); + memcpy(record.hdr.uuid.uuid.uuid128, UUID_UNKNOWN, sizeof(UUID_UNKNOWN)); record.hdr.service_name_length = strlen(sdp_service_name) + 1; record.hdr.service_name = sdp_service_name; record.hdr.rfcomm_channel_number = BT_UNUSED_RFCOMM; record.hdr.l2cap_psm = BT_L2CAP_DYNMIC_PSM; record.hdr.profile_version = BT_UNKONWN_PROFILE_VERSION; - record.uuid.len = sizeof(UUID_UNKNOWN); - memcpy(record.uuid.uuid.uuid128, UUID_UNKNOWN, sizeof(UUID_UNKNOWN)); - record.user1_ptr = NULL; - record.user1_ptr_len = 0; esp_sdp_create_record((esp_bluetooth_sdp_record_t *)&record); } break;