Skip to content

Commit

Permalink
Merge branch 'feature/add_di_api' into 'master'
Browse files Browse the repository at this point in the history
Feature/add di api

Closes IDFGH-11785

See merge request espressif/esp-idf!32872
  • Loading branch information
wmy-espressif committed Sep 6, 2024
2 parents 3864200 + be1c677 commit ca05aa5
Show file tree
Hide file tree
Showing 28 changed files with 911 additions and 422 deletions.
14 changes: 7 additions & 7 deletions components/bt/common/btc/core/btc_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
#if (BTC_L2CAP_INCLUDED == TRUE)
#include "btc_l2cap.h"
#endif /* #if (BTC_L2CAP_INCLUDED == TRUE) */
#if (BTC_SDP_INCLUDED == TRUE)
#if (BTC_SDP_COMMON_INCLUDED == TRUE)
#include "btc_sdp.h"
#endif /* #if (BTC_SDP_INCLUDED == TRUE) */
#endif /* #if (BTC_SDP_COMMON_INCLUDED == TRUE) */
#if BTC_HF_INCLUDED
#include "btc_hf_ag.h"
#endif/* #if BTC_HF_INCLUDED */
Expand Down Expand Up @@ -138,9 +138,9 @@ static const btc_func_t profile_tab[BTC_PID_NUM] = {
#if (BTC_L2CAP_INCLUDED == TRUE)
[BTC_PID_L2CAP] = {btc_l2cap_call_handler, btc_l2cap_cb_handler },
#endif /* #if (BTC_L2CAP_INCLUDED == TRUE) */
#if (BTC_SDP_INCLUDED == TRUE)
#if (BTC_SDP_COMMON_INCLUDED == TRUE)
[BTC_PID_SDP] = {btc_sdp_call_handler, btc_sdp_cb_handler },
#endif /* #if (BTC_SDP_INCLUDED == TRUE) */
#endif /* #if (BTC_SDP_COMMON_INCLUDED == TRUE) */
#if BTC_HF_INCLUDED
[BTC_PID_HF] = {btc_hf_call_handler, btc_hf_cb_handler},
#endif /* #if BTC_HF_INCLUDED */
Expand Down Expand Up @@ -295,8 +295,8 @@ static bt_status_t btc_task_post(btc_msg_t *msg, uint32_t timeout)
/**
* transfer an message to another module in the different task.
* @param msg message
* @param arg paramter
* @param arg_len length of paramter
* @param arg parameter
* @param arg_len length of parameter
* @param copy_func deep copy function
* @param free_func deep free function
* @return BT_STATUS_SUCCESS: success
Expand Down Expand Up @@ -342,7 +342,7 @@ bt_status_t btc_transfer_context(btc_msg_t *msg, void *arg, int arg_len, btc_arg
}

/**
* transfer an message to another module in tha same task.
* transfer an message to another module in the same task.
* @param msg message
* @return BT_STATUS_SUCCESS: success
* others: fail
Expand Down
9 changes: 8 additions & 1 deletion components/bt/host/bluedroid/Kconfig.in
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ config BT_L2CAP_ENABLED
This enables the Logical Link Control and Adaptation Layer Protocol.
Only supported classic bluetooth.

config BT_SDP_COMMON_ENABLED
bool "BT SDP COMMON"
depends on BT_CLASSIC_ENABLED
default n
help
This enables common SDP operation, such as SDP record creation and deletion.

menuconfig BT_HFP_ENABLE
bool "Hands Free/Handset Profile"
depends on BT_CLASSIC_ENABLED
Expand Down Expand Up @@ -148,7 +155,7 @@ menuconfig BT_HID_ENABLED
depends on BT_CLASSIC_ENABLED
default n
help
This enables the BT HID Host
This enables the BT HID functionalities

config BT_HID_HOST_ENABLED
bool "Classic BT HID Host"
Expand Down
43 changes: 36 additions & 7 deletions components/bt/host/bluedroid/api/esp_sdp_api.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand All @@ -8,12 +8,43 @@

#include "esp_bt_main.h"
#include "btc/btc_manage.h"
#include "stack/sdpdefs.h"

#include "btc_sdp.h"
#include "esp_sdp_api.h"
#include "common/bt_target.h"

#if (defined BTC_SDP_INCLUDED && BTC_SDP_INCLUDED == TRUE)
#if (defined BTC_SDP_COMMON_INCLUDED && BTC_SDP_COMMON_INCLUDED == TRUE)

static bool esp_sdp_record_integrity_check(esp_bluetooth_sdp_record_t *record)
{
bool ret = true;

if (record != NULL) {
switch (record->hdr.type) {
case ESP_SDP_TYPE_DIP_SERVER:
if (record->dip.vendor_id_source != ESP_SDP_VENDOR_ID_SRC_BT &&
record->dip.vendor_id_source != ESP_SDP_VENDOR_ID_SRC_USB) {
LOG_ERROR("Invalid vendor_id_source!\n");
ret = false;
}
break;

default:
if (record->hdr.service_name_length > ESP_SDP_SERVER_NAME_MAX ||
strlen(record->hdr.service_name) + 1 != record->hdr.service_name_length) {
LOG_ERROR("Invalid server name!\n");
ret = false;
}
break;
}
} else {
LOG_ERROR("record is NULL!\n");
ret = false;
}

return ret;
}

esp_err_t esp_sdp_register_callback(esp_sdp_cb_t callback)
{
Expand Down Expand Up @@ -85,9 +116,7 @@ esp_err_t esp_sdp_create_record(esp_bluetooth_sdp_record_t *record)
{
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);

if (record == NULL || record->hdr.service_name_length > ESP_SDP_SERVER_NAME_MAX
|| strlen(record->hdr.service_name)+1 != record->hdr.service_name_length) {
LOG_ERROR("Invalid server name!\n");
if (!esp_sdp_record_integrity_check(record)) {
return ESP_ERR_INVALID_ARG;
}

Expand All @@ -100,7 +129,7 @@ esp_err_t esp_sdp_create_record(esp_bluetooth_sdp_record_t *record)
msg.act = BTC_SDP_ACT_CREATE_RECORD;

memset(&arg, 0, sizeof(btc_sdp_args_t));
arg.creat_record.record = (bluetooth_sdp_record *)record;
arg.create_record.record = (bluetooth_sdp_record *)record;

/* Switch to BTC context */
stat = btc_transfer_context(&msg, &arg, sizeof(btc_sdp_args_t),
Expand All @@ -127,4 +156,4 @@ esp_err_t esp_sdp_remove_record(int record_handle)
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
}

#endif ///defined BTC_SDP_INCLUDED && BTC_SDP_INCLUDED == TRUE
#endif ///defined BTC_SDP_COMMON_INCLUDED && BTC_SDP_COMMON_INCLUDED == TRUE
Loading

0 comments on commit ca05aa5

Please sign in to comment.