From 85ded0b5443fd8afc2a19ef03939731b96fe0b13 Mon Sep 17 00:00:00 2001 From: gongyantao Date: Wed, 31 Jul 2024 17:22:56 +0800 Subject: [PATCH] feat(bt/example): add ci sdkconfig for bt examples --- .../a2dp_sink/main/Kconfig.projbuild | 5 ++++ .../classic_bt/a2dp_sink/main/main.c | 4 ++-- .../a2dp_sink/sdkconfig.ci.defaults | 1 + .../a2dp_source/main/Kconfig.projbuild | 15 ++++++++++++ .../classic_bt/a2dp_source/main/main.c | 7 +++--- .../a2dp_source/sdkconfig.ci.defaults | 1 + .../main/Kconfig.projbuild | 15 ++++++++++++ .../bt_hid_mouse_device/main/main.c | 4 +++- .../bt_hid_mouse_device/sdkconfig.ci.defaults | 1 + .../bt_l2cap_client/main/Kconfig.projbuild | 15 ++++++++++++ .../classic_bt/bt_l2cap_client/main/main.c | 6 ++--- .../bt_l2cap_client/sdkconfig.ci.defaults | 1 + .../bt_l2cap_server/main/Kconfig.projbuild | 15 ++++++++++++ .../classic_bt/bt_l2cap_server/main/main.c | 6 ++--- .../bt_l2cap_server/sdkconfig.ci.defaults | 1 + .../bt_spp_acceptor/main/Kconfig.projbuild | 15 ++++++++++++ .../classic_bt/bt_spp_acceptor/main/main.c | 6 ++--- .../bt_spp_acceptor/sdkconfig.ci.defaults | 1 + .../bt_spp_initiator/main/Kconfig.projbuild | 15 ++++++++++++ .../classic_bt/bt_spp_initiator/main/main.c | 3 ++- .../bt_spp_initiator/sdkconfig.ci.defaults | 1 + .../main/Kconfig.projbuild | 15 ++++++++++++ .../bt_spp_vfs_acceptor/main/main.c | 6 ++--- .../bt_spp_vfs_acceptor/sdkconfig.ci.defaults | 1 + .../main/Kconfig.projbuild | 15 ++++++++++++ .../bt_spp_vfs_initiator/main/main.c | 3 ++- .../sdkconfig.ci.defaults | 1 + .../classic_bt/hfp_ag/main/Kconfig.projbuild | 7 ++++++ .../bluedroid/classic_bt/hfp_ag/main/main.c | 5 ++-- .../classic_bt/hfp_ag/sdkconfig.ci.all | 2 ++ .../classic_bt/hfp_hf/main/Kconfig.projbuild | 15 ++++++++++++ .../bluedroid/classic_bt/hfp_hf/main/main.c | 3 +-- .../classic_bt/hfp_hf/sdkconfig.ci.all | 2 ++ .../classic_bt/pytest_classic_bt_test.py | 2 +- .../esp_hid_host/main/Kconfig.projbuild | 23 +++++++++++++++++++ .../esp_hid_host/main/esp_hid_host_main.c | 14 +++++++++++ .../esp_hid_host/sdkconfig.ci.defaults | 1 + 37 files changed, 228 insertions(+), 25 deletions(-) create mode 100644 examples/bluetooth/bluedroid/classic_bt/a2dp_sink/sdkconfig.ci.defaults create mode 100644 examples/bluetooth/bluedroid/classic_bt/a2dp_source/main/Kconfig.projbuild create mode 100644 examples/bluetooth/bluedroid/classic_bt/a2dp_source/sdkconfig.ci.defaults create mode 100644 examples/bluetooth/bluedroid/classic_bt/bt_hid_mouse_device/main/Kconfig.projbuild create mode 100644 examples/bluetooth/bluedroid/classic_bt/bt_hid_mouse_device/sdkconfig.ci.defaults create mode 100644 examples/bluetooth/bluedroid/classic_bt/bt_l2cap_client/main/Kconfig.projbuild create mode 100644 examples/bluetooth/bluedroid/classic_bt/bt_l2cap_client/sdkconfig.ci.defaults create mode 100644 examples/bluetooth/bluedroid/classic_bt/bt_l2cap_server/main/Kconfig.projbuild create mode 100644 examples/bluetooth/bluedroid/classic_bt/bt_l2cap_server/sdkconfig.ci.defaults create mode 100644 examples/bluetooth/bluedroid/classic_bt/bt_spp_acceptor/main/Kconfig.projbuild create mode 100644 examples/bluetooth/bluedroid/classic_bt/bt_spp_acceptor/sdkconfig.ci.defaults create mode 100644 examples/bluetooth/bluedroid/classic_bt/bt_spp_initiator/main/Kconfig.projbuild create mode 100644 examples/bluetooth/bluedroid/classic_bt/bt_spp_initiator/sdkconfig.ci.defaults create mode 100644 examples/bluetooth/bluedroid/classic_bt/bt_spp_vfs_acceptor/main/Kconfig.projbuild create mode 100644 examples/bluetooth/bluedroid/classic_bt/bt_spp_vfs_acceptor/sdkconfig.ci.defaults create mode 100644 examples/bluetooth/bluedroid/classic_bt/bt_spp_vfs_initiator/main/Kconfig.projbuild create mode 100644 examples/bluetooth/bluedroid/classic_bt/bt_spp_vfs_initiator/sdkconfig.ci.defaults create mode 100644 examples/bluetooth/bluedroid/classic_bt/hfp_ag/main/Kconfig.projbuild create mode 100644 examples/bluetooth/bluedroid/classic_bt/hfp_ag/sdkconfig.ci.all create mode 100644 examples/bluetooth/bluedroid/classic_bt/hfp_hf/main/Kconfig.projbuild create mode 100644 examples/bluetooth/bluedroid/classic_bt/hfp_hf/sdkconfig.ci.all create mode 100644 examples/bluetooth/esp_hid_host/main/Kconfig.projbuild create mode 100644 examples/bluetooth/esp_hid_host/sdkconfig.ci.defaults diff --git a/examples/bluetooth/bluedroid/classic_bt/a2dp_sink/main/Kconfig.projbuild b/examples/bluetooth/bluedroid/classic_bt/a2dp_sink/main/Kconfig.projbuild index 73f6d669f8..47b9e2f01d 100644 --- a/examples/bluetooth/bluedroid/classic_bt/a2dp_sink/main/Kconfig.projbuild +++ b/examples/bluetooth/bluedroid/classic_bt/a2dp_sink/main/Kconfig.projbuild @@ -39,4 +39,9 @@ menu "A2DP Example Configuration" help GPIO number to use for I2S Data Driver. + config EXAMPLE_LOCAL_DEVICE_NAME + string "Local Device Name" + default "ESP_SPEAKER" + help + Use this option to set local device name. endmenu diff --git a/examples/bluetooth/bluedroid/classic_bt/a2dp_sink/main/main.c b/examples/bluetooth/bluedroid/classic_bt/a2dp_sink/main/main.c index 3b11942521..d535507918 100644 --- a/examples/bluetooth/bluedroid/classic_bt/a2dp_sink/main/main.c +++ b/examples/bluetooth/bluedroid/classic_bt/a2dp_sink/main/main.c @@ -26,7 +26,7 @@ #include "esp_avrc_api.h" /* device name */ -#define LOCAL_DEVICE_NAME "ESP_SPEAKER" +static const char local_device_name[] = CONFIG_EXAMPLE_LOCAL_DEVICE_NAME; /* event for stack up */ enum { @@ -120,7 +120,7 @@ static void bt_av_hdl_stack_evt(uint16_t event, void *p_param) switch (event) { /* when do the stack up, this event comes */ case BT_APP_EVT_STACK_UP: { - esp_bt_dev_set_device_name(LOCAL_DEVICE_NAME); + esp_bt_dev_set_device_name(local_device_name); esp_bt_gap_register_callback(bt_app_gap_cb); assert(esp_avrc_ct_init() == ESP_OK); diff --git a/examples/bluetooth/bluedroid/classic_bt/a2dp_sink/sdkconfig.ci.defaults b/examples/bluetooth/bluedroid/classic_bt/a2dp_sink/sdkconfig.ci.defaults new file mode 100644 index 0000000000..79e4f555d6 --- /dev/null +++ b/examples/bluetooth/bluedroid/classic_bt/a2dp_sink/sdkconfig.ci.defaults @@ -0,0 +1 @@ +CONFIG_EXAMPLE_LOCAL_DEVICE_NAME="${CI_PIPELINE_ID}_A2DP_SINK" diff --git a/examples/bluetooth/bluedroid/classic_bt/a2dp_source/main/Kconfig.projbuild b/examples/bluetooth/bluedroid/classic_bt/a2dp_source/main/Kconfig.projbuild new file mode 100644 index 0000000000..47ea6308ee --- /dev/null +++ b/examples/bluetooth/bluedroid/classic_bt/a2dp_source/main/Kconfig.projbuild @@ -0,0 +1,15 @@ +menu "A2DP Example Configuration" + config EXAMPLE_SSP_ENABLED + bool "Secure Simple Pairing" + depends on BT_CLASSIC_ENABLED + default y + help + This enables the Secure Simple Pairing. If disable this option, + Bluedroid will only support Legacy Pairing + + config EXAMPLE_PEER_DEVICE_NAME + string "Target Device Name" + default "ESP_SPEAKER" + help + Use this option to set target device name to connect. +endmenu diff --git a/examples/bluetooth/bluedroid/classic_bt/a2dp_source/main/main.c b/examples/bluetooth/bluedroid/classic_bt/a2dp_source/main/main.c index 4500bae801..0e3eb6c014 100644 --- a/examples/bluetooth/bluedroid/classic_bt/a2dp_source/main/main.c +++ b/examples/bluetooth/bluedroid/classic_bt/a2dp_source/main/main.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -30,7 +30,6 @@ #define BT_RC_CT_TAG "RC_CT" /* device name */ -#define TARGET_DEVICE_NAME "ESP_SPEAKER" #define LOCAL_DEVICE_NAME "ESP_A2DP_SRC" /* AVRCP used transaction label */ @@ -112,6 +111,8 @@ static uint32_t s_pkt_cnt = 0; /* count of packet static esp_avrc_rn_evt_cap_mask_t s_avrc_peer_rn_cap; /* AVRC target notification event capability bit mask */ static TimerHandle_t s_tmr; /* handle of heart beat timer */ +static const char remote_device_name[] = CONFIG_EXAMPLE_PEER_DEVICE_NAME; + /********************************* * STATIC FUNCTION DEFINITIONS ********************************/ @@ -199,7 +200,7 @@ static void filter_inquiry_scan_result(esp_bt_gap_cb_param_t *param) /* search for target device in its Extended Inqury Response */ if (eir) { get_name_from_eir(eir, s_peer_bdname, NULL); - if (strcmp((char *)s_peer_bdname, TARGET_DEVICE_NAME) == 0) { + if (strcmp((char *)s_peer_bdname, remote_device_name) == 0) { ESP_LOGI(BT_AV_TAG, "Found a target device, address %s, name %s", bda_str, s_peer_bdname); s_a2d_state = APP_AV_STATE_DISCOVERED; memcpy(s_peer_bda, param->disc_res.bda, ESP_BD_ADDR_LEN); diff --git a/examples/bluetooth/bluedroid/classic_bt/a2dp_source/sdkconfig.ci.defaults b/examples/bluetooth/bluedroid/classic_bt/a2dp_source/sdkconfig.ci.defaults new file mode 100644 index 0000000000..f1e20630cb --- /dev/null +++ b/examples/bluetooth/bluedroid/classic_bt/a2dp_source/sdkconfig.ci.defaults @@ -0,0 +1 @@ +CONFIG_EXAMPLE_PEER_DEVICE_NAME="${CI_PIPELINE_ID}_A2DP_SINK" diff --git a/examples/bluetooth/bluedroid/classic_bt/bt_hid_mouse_device/main/Kconfig.projbuild b/examples/bluetooth/bluedroid/classic_bt/bt_hid_mouse_device/main/Kconfig.projbuild new file mode 100644 index 0000000000..d7db1931a0 --- /dev/null +++ b/examples/bluetooth/bluedroid/classic_bt/bt_hid_mouse_device/main/Kconfig.projbuild @@ -0,0 +1,15 @@ +menu "HID Example Configuration" + config EXAMPLE_SSP_ENABLED + bool "Secure Simple Pairing" + depends on BT_CLASSIC_ENABLED + default y + help + This enables the Secure Simple Pairing. If disable this option, + Bluedroid will only support Legacy Pairing + + config EXAMPLE_LOCAL_DEVICE_NAME + string "Local Device Name" + default "HID Mouse Example" + help + Use this option to set local device name. +endmenu diff --git a/examples/bluetooth/bluedroid/classic_bt/bt_hid_mouse_device/main/main.c b/examples/bluetooth/bluedroid/classic_bt/bt_hid_mouse_device/main/main.c index 7342db893a..9ad994de09 100644 --- a/examples/bluetooth/bluedroid/classic_bt/bt_hid_mouse_device/main/main.c +++ b/examples/bluetooth/bluedroid/classic_bt/bt_hid_mouse_device/main/main.c @@ -23,6 +23,8 @@ #define REPORT_PROTOCOL_MOUSE_REPORT_SIZE (4) #define REPORT_BUFFER_SIZE REPORT_PROTOCOL_MOUSE_REPORT_SIZE +static const char local_device_name[] = CONFIG_EXAMPLE_LOCAL_DEVICE_NAME; + typedef struct { esp_hidd_app_param_t app_param; esp_hidd_qos_param_t both_qos; @@ -430,7 +432,7 @@ void app_main(void) } ESP_LOGI(TAG, "setting device name"); - esp_bt_dev_set_device_name("HID Mouse Example"); + esp_bt_dev_set_device_name(local_device_name); ESP_LOGI(TAG, "setting cod major, peripheral"); esp_bt_cod_t cod; diff --git a/examples/bluetooth/bluedroid/classic_bt/bt_hid_mouse_device/sdkconfig.ci.defaults b/examples/bluetooth/bluedroid/classic_bt/bt_hid_mouse_device/sdkconfig.ci.defaults new file mode 100644 index 0000000000..f6353b4b36 --- /dev/null +++ b/examples/bluetooth/bluedroid/classic_bt/bt_hid_mouse_device/sdkconfig.ci.defaults @@ -0,0 +1 @@ +CONFIG_EXAMPLE_LOCAL_DEVICE_NAME="${CI_PIPELINE_ID}_HID_MOUSE_DEVICE" diff --git a/examples/bluetooth/bluedroid/classic_bt/bt_l2cap_client/main/Kconfig.projbuild b/examples/bluetooth/bluedroid/classic_bt/bt_l2cap_client/main/Kconfig.projbuild new file mode 100644 index 0000000000..a1b665ef26 --- /dev/null +++ b/examples/bluetooth/bluedroid/classic_bt/bt_l2cap_client/main/Kconfig.projbuild @@ -0,0 +1,15 @@ +menu "L2CAP Example Configuration" + config EXAMPLE_SSP_ENABLED + bool "Secure Simple Pairing" + depends on BT_CLASSIC_ENABLED + default y + help + This enables the Secure Simple Pairing. If disable this option, + Bluedroid will only support Legacy Pairing + + config EXAMPLE_PEER_DEVICE_NAME + string "Target Device Name" + default "ESP_BT_L2CAP_SERVER" + help + Use this option to set target device name to connect. +endmenu 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 523b4e381c..9e82b10b30 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 @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -30,12 +30,12 @@ #define L2CAP_TAG "L2CAP_TAG" #define SDP_TAG "SDP_TAG" #define EXAMPLE_DEVICE_NAME "ESP_BT_L2CAP_CLIENT" -#define TARGET_DEVICE_NAME "ESP_BT_L2CAP_SERVER" #define L2CAP_DATA_LEN 100 #define BT_L2CAP_DYNMIC_PSM 0x1001 #define BT_UNUSED_RFCOMM -1 #define BT_UNKONWN_PROFILE_VERSION 0x0102 +static const char remote_device_name[] = CONFIG_EXAMPLE_PEER_DEVICE_NAME; static esp_bt_l2cap_cntl_flags_t sec_mask = ESP_BT_L2CAP_SEC_AUTHENTICATE; static char *sdp_service_name = "Unknown_profile"; static const uint8_t UUID_UNKNOWN[] = {0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10, 0x00, @@ -125,7 +125,7 @@ static void filter_inquiry_scan_result(esp_bt_gap_cb_param_t *param) /* search for target device in its Extended Inqury Response */ if (eir) { get_name_from_eir(eir, peer_bdname, NULL); - if (strcmp((char *)peer_bdname, TARGET_DEVICE_NAME) == 0) { + if (strcmp((char *)peer_bdname, remote_device_name) == 0) { ESP_LOGI(L2CAP_TAG, "Found a target device, address %s, name %s", bda_str, peer_bdname); ESP_LOGI(L2CAP_TAG, "Cancel device discovery ..."); esp_bt_gap_cancel_discovery(); diff --git a/examples/bluetooth/bluedroid/classic_bt/bt_l2cap_client/sdkconfig.ci.defaults b/examples/bluetooth/bluedroid/classic_bt/bt_l2cap_client/sdkconfig.ci.defaults new file mode 100644 index 0000000000..a21a8b5e76 --- /dev/null +++ b/examples/bluetooth/bluedroid/classic_bt/bt_l2cap_client/sdkconfig.ci.defaults @@ -0,0 +1 @@ +CONFIG_EXAMPLE_PEER_DEVICE_NAME="${CI_PIPELINE_ID}_L2CAP_SERVER" diff --git a/examples/bluetooth/bluedroid/classic_bt/bt_l2cap_server/main/Kconfig.projbuild b/examples/bluetooth/bluedroid/classic_bt/bt_l2cap_server/main/Kconfig.projbuild new file mode 100644 index 0000000000..14824fe72a --- /dev/null +++ b/examples/bluetooth/bluedroid/classic_bt/bt_l2cap_server/main/Kconfig.projbuild @@ -0,0 +1,15 @@ +menu "L2CAP Example Configuration" + config EXAMPLE_SSP_ENABLED + bool "Secure Simple Pairing" + depends on BT_CLASSIC_ENABLED + default y + help + This enables the Secure Simple Pairing. If disable this option, + Bluedroid will only support Legacy Pairing + + config EXAMPLE_LOCAL_DEVICE_NAME + string "Local Device Name" + default "ESP_BT_L2CAP_SERVER" + help + Use this option to set local device name. +endmenu 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 95ff05e63a..e6be53350d 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 @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -29,12 +29,12 @@ #define L2CAP_TAG "L2CAP_TAG" #define SDP_TAG "SDP_TAG" -#define EXAMPLE_DEVICE_NAME "ESP_BT_L2CAP_SERVER" #define L2CAP_DATA_LEN 100 #define BT_UNUSED_RFCOMM -1 #define BT_L2CAP_DYNMIC_PSM 0x1001 #define BT_UNKONWN_PROFILE_VERSION 0x0102 +static const char local_device_name[] = CONFIG_EXAMPLE_LOCAL_DEVICE_NAME; static esp_bt_l2cap_cntl_flags_t sec_mask = ESP_BT_L2CAP_SEC_AUTHENTICATE; static char *sdp_service_name = "Unknown_profile"; static const uint8_t UUID_UNKNOWN[] = {0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10, 0x00, @@ -270,7 +270,7 @@ static void esp_hdl_sdp_cb_evt(uint16_t event, void *p_param) case ESP_SDP_CREATE_RECORD_COMP_EVT: ESP_LOGI(SDP_TAG, "ESP_SDP_CREATE_RECORD_COMP_EVT: status:%d\n", sdp_param->create_record.status); if (sdp_param->create_record.status == ESP_SDP_SUCCESS) { - esp_bt_dev_set_device_name(EXAMPLE_DEVICE_NAME); + esp_bt_dev_set_device_name(local_device_name); esp_bt_gap_set_scan_mode(ESP_BT_CONNECTABLE, ESP_BT_GENERAL_DISCOVERABLE); } break; diff --git a/examples/bluetooth/bluedroid/classic_bt/bt_l2cap_server/sdkconfig.ci.defaults b/examples/bluetooth/bluedroid/classic_bt/bt_l2cap_server/sdkconfig.ci.defaults new file mode 100644 index 0000000000..205de36eb8 --- /dev/null +++ b/examples/bluetooth/bluedroid/classic_bt/bt_l2cap_server/sdkconfig.ci.defaults @@ -0,0 +1 @@ +CONFIG_EXAMPLE_LOCAL_DEVICE_NAME="${CI_PIPELINE_ID}_L2CAP_SERVER" diff --git a/examples/bluetooth/bluedroid/classic_bt/bt_spp_acceptor/main/Kconfig.projbuild b/examples/bluetooth/bluedroid/classic_bt/bt_spp_acceptor/main/Kconfig.projbuild new file mode 100644 index 0000000000..71d6c4a0ee --- /dev/null +++ b/examples/bluetooth/bluedroid/classic_bt/bt_spp_acceptor/main/Kconfig.projbuild @@ -0,0 +1,15 @@ +menu "SPP Example Configuration" + config EXAMPLE_SSP_ENABLED + bool "Secure Simple Pairing" + depends on BT_CLASSIC_ENABLED + default y + help + This enables the Secure Simple Pairing. If disable this option, + Bluedroid will only support Legacy Pairing + + config EXAMPLE_LOCAL_DEVICE_NAME + string "Local Device Name" + default "ESP_SPP_ACCEPTOR" + help + Use this option to set local device name. +endmenu diff --git a/examples/bluetooth/bluedroid/classic_bt/bt_spp_acceptor/main/main.c b/examples/bluetooth/bluedroid/classic_bt/bt_spp_acceptor/main/main.c index ecf70a8dfa..273290a738 100644 --- a/examples/bluetooth/bluedroid/classic_bt/bt_spp_acceptor/main/main.c +++ b/examples/bluetooth/bluedroid/classic_bt/bt_spp_acceptor/main/main.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -25,11 +25,11 @@ #define SPP_TAG "SPP_ACCEPTOR_DEMO" #define SPP_SERVER_NAME "SPP_SERVER" -#define EXAMPLE_DEVICE_NAME "ESP_SPP_ACCEPTOR" #define SPP_SHOW_DATA 0 #define SPP_SHOW_SPEED 1 #define SPP_SHOW_MODE SPP_SHOW_SPEED /*Choose show mode: show data or speed*/ +static const char local_device_name[] = CONFIG_EXAMPLE_LOCAL_DEVICE_NAME; static const esp_spp_mode_t esp_spp_mode = ESP_SPP_MODE_CB; static const bool esp_spp_enable_l2cap_ertm = true; @@ -90,7 +90,7 @@ static void esp_spp_cb(esp_spp_cb_event_t event, esp_spp_cb_param_t *param) if (param->start.status == ESP_SPP_SUCCESS) { ESP_LOGI(SPP_TAG, "ESP_SPP_START_EVT handle:%"PRIu32" sec_id:%d scn:%d", param->start.handle, param->start.sec_id, param->start.scn); - esp_bt_dev_set_device_name(EXAMPLE_DEVICE_NAME); + esp_bt_dev_set_device_name(local_device_name); esp_bt_gap_set_scan_mode(ESP_BT_CONNECTABLE, ESP_BT_GENERAL_DISCOVERABLE); } else { ESP_LOGE(SPP_TAG, "ESP_SPP_START_EVT status:%d", param->start.status); diff --git a/examples/bluetooth/bluedroid/classic_bt/bt_spp_acceptor/sdkconfig.ci.defaults b/examples/bluetooth/bluedroid/classic_bt/bt_spp_acceptor/sdkconfig.ci.defaults new file mode 100644 index 0000000000..1d9783ea67 --- /dev/null +++ b/examples/bluetooth/bluedroid/classic_bt/bt_spp_acceptor/sdkconfig.ci.defaults @@ -0,0 +1 @@ +CONFIG_EXAMPLE_LOCAL_DEVICE_NAME="${CI_PIPELINE_ID}_SPP_ACCEPTOR" diff --git a/examples/bluetooth/bluedroid/classic_bt/bt_spp_initiator/main/Kconfig.projbuild b/examples/bluetooth/bluedroid/classic_bt/bt_spp_initiator/main/Kconfig.projbuild new file mode 100644 index 0000000000..b942d94d38 --- /dev/null +++ b/examples/bluetooth/bluedroid/classic_bt/bt_spp_initiator/main/Kconfig.projbuild @@ -0,0 +1,15 @@ +menu "SPP Example Configuration" + config EXAMPLE_SSP_ENABLED + bool "Secure Simple Pairing" + depends on BT_CLASSIC_ENABLED + default y + help + This enables the Secure Simple Pairing. If disable this option, + Bluedroid will only support Legacy Pairing + + config EXAMPLE_PEER_DEVICE_NAME + string "Target Device Name" + default "ESP_SPP_ACCEPTOR" + help + Use this option to set target device name to connect. +endmenu diff --git a/examples/bluetooth/bluedroid/classic_bt/bt_spp_initiator/main/main.c b/examples/bluetooth/bluedroid/classic_bt/bt_spp_initiator/main/main.c index 46f8360c0f..32a3634da3 100644 --- a/examples/bluetooth/bluedroid/classic_bt/bt_spp_initiator/main/main.c +++ b/examples/bluetooth/bluedroid/classic_bt/bt_spp_initiator/main/main.c @@ -43,7 +43,8 @@ static const esp_spp_role_t role_master = ESP_SPP_ROLE_MASTER; esp_bd_addr_t peer_bd_addr = {0}; static uint8_t peer_bdname_len; static char peer_bdname[ESP_BT_GAP_MAX_BDNAME_LEN + 1]; -static const char remote_device_name[] = "ESP_SPP_ACCEPTOR"; +static const char remote_device_name[] = CONFIG_EXAMPLE_PEER_DEVICE_NAME; + static const esp_bt_inq_mode_t inq_mode = ESP_BT_INQ_MODE_GENERAL_INQUIRY; static const uint8_t inq_len = 30; static const uint8_t inq_num_rsps = 0; diff --git a/examples/bluetooth/bluedroid/classic_bt/bt_spp_initiator/sdkconfig.ci.defaults b/examples/bluetooth/bluedroid/classic_bt/bt_spp_initiator/sdkconfig.ci.defaults new file mode 100644 index 0000000000..35448fa715 --- /dev/null +++ b/examples/bluetooth/bluedroid/classic_bt/bt_spp_initiator/sdkconfig.ci.defaults @@ -0,0 +1 @@ +CONFIG_EXAMPLE_PEER_DEVICE_NAME="${CI_PIPELINE_ID}_SPP_ACCEPTOR" diff --git a/examples/bluetooth/bluedroid/classic_bt/bt_spp_vfs_acceptor/main/Kconfig.projbuild b/examples/bluetooth/bluedroid/classic_bt/bt_spp_vfs_acceptor/main/Kconfig.projbuild new file mode 100644 index 0000000000..71d6c4a0ee --- /dev/null +++ b/examples/bluetooth/bluedroid/classic_bt/bt_spp_vfs_acceptor/main/Kconfig.projbuild @@ -0,0 +1,15 @@ +menu "SPP Example Configuration" + config EXAMPLE_SSP_ENABLED + bool "Secure Simple Pairing" + depends on BT_CLASSIC_ENABLED + default y + help + This enables the Secure Simple Pairing. If disable this option, + Bluedroid will only support Legacy Pairing + + config EXAMPLE_LOCAL_DEVICE_NAME + string "Local Device Name" + default "ESP_SPP_ACCEPTOR" + help + Use this option to set local device name. +endmenu diff --git a/examples/bluetooth/bluedroid/classic_bt/bt_spp_vfs_acceptor/main/main.c b/examples/bluetooth/bluedroid/classic_bt/bt_spp_vfs_acceptor/main/main.c index 403ef58c8a..bd085b97ae 100644 --- a/examples/bluetooth/bluedroid/classic_bt/bt_spp_vfs_acceptor/main/main.c +++ b/examples/bluetooth/bluedroid/classic_bt/bt_spp_vfs_acceptor/main/main.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -37,8 +37,8 @@ #define SPP_TAG "SPP_ACCEPTOR_DEMO" #define SPP_SERVER_NAME "SPP_SERVER" -#define EXAMPLE_DEVICE_NAME "ESP_SPP_ACCEPTOR" +static const char local_device_name[] = CONFIG_EXAMPLE_LOCAL_DEVICE_NAME; static const esp_spp_sec_t sec_mask = ESP_SPP_SEC_AUTHENTICATE; static const esp_spp_role_t role_slave = ESP_SPP_ROLE_SLAVE; @@ -121,7 +121,7 @@ static void esp_spp_cb(uint16_t e, void *p) if (param->start.status == ESP_SPP_SUCCESS) { ESP_LOGI(SPP_TAG, "ESP_SPP_START_EVT handle:%"PRIu32" sec_id:%d scn:%d", param->start.handle, param->start.sec_id, param->start.scn); - esp_bt_dev_set_device_name(EXAMPLE_DEVICE_NAME); + esp_bt_dev_set_device_name(local_device_name); esp_bt_gap_set_scan_mode(ESP_BT_CONNECTABLE, ESP_BT_GENERAL_DISCOVERABLE); } else { ESP_LOGE(SPP_TAG, "ESP_SPP_START_EVT status:%d", param->start.status); diff --git a/examples/bluetooth/bluedroid/classic_bt/bt_spp_vfs_acceptor/sdkconfig.ci.defaults b/examples/bluetooth/bluedroid/classic_bt/bt_spp_vfs_acceptor/sdkconfig.ci.defaults new file mode 100644 index 0000000000..ff404573a0 --- /dev/null +++ b/examples/bluetooth/bluedroid/classic_bt/bt_spp_vfs_acceptor/sdkconfig.ci.defaults @@ -0,0 +1 @@ +CONFIG_EXAMPLE_LOCAL_DEVICE_NAME="${CI_PIPELINE_ID}_SPP_VFS_ACCEPTOR" diff --git a/examples/bluetooth/bluedroid/classic_bt/bt_spp_vfs_initiator/main/Kconfig.projbuild b/examples/bluetooth/bluedroid/classic_bt/bt_spp_vfs_initiator/main/Kconfig.projbuild new file mode 100644 index 0000000000..b942d94d38 --- /dev/null +++ b/examples/bluetooth/bluedroid/classic_bt/bt_spp_vfs_initiator/main/Kconfig.projbuild @@ -0,0 +1,15 @@ +menu "SPP Example Configuration" + config EXAMPLE_SSP_ENABLED + bool "Secure Simple Pairing" + depends on BT_CLASSIC_ENABLED + default y + help + This enables the Secure Simple Pairing. If disable this option, + Bluedroid will only support Legacy Pairing + + config EXAMPLE_PEER_DEVICE_NAME + string "Target Device Name" + default "ESP_SPP_ACCEPTOR" + help + Use this option to set target device name to connect. +endmenu diff --git a/examples/bluetooth/bluedroid/classic_bt/bt_spp_vfs_initiator/main/main.c b/examples/bluetooth/bluedroid/classic_bt/bt_spp_vfs_initiator/main/main.c index 491bfeecb6..663c0e04e9 100644 --- a/examples/bluetooth/bluedroid/classic_bt/bt_spp_vfs_initiator/main/main.c +++ b/examples/bluetooth/bluedroid/classic_bt/bt_spp_vfs_initiator/main/main.c @@ -44,7 +44,8 @@ static const esp_spp_role_t role_master = ESP_SPP_ROLE_MASTER; static esp_bd_addr_t peer_bd_addr; static uint8_t peer_bdname_len; static char peer_bdname[ESP_BT_GAP_MAX_BDNAME_LEN + 1]; -static const char remote_device_name[] = "ESP_SPP_ACCEPTOR"; +static const char remote_device_name[] = CONFIG_EXAMPLE_PEER_DEVICE_NAME; + static const esp_bt_inq_mode_t inq_mode = ESP_BT_INQ_MODE_GENERAL_INQUIRY; static const uint8_t inq_len = 30; static const uint8_t inq_num_rsps = 0; diff --git a/examples/bluetooth/bluedroid/classic_bt/bt_spp_vfs_initiator/sdkconfig.ci.defaults b/examples/bluetooth/bluedroid/classic_bt/bt_spp_vfs_initiator/sdkconfig.ci.defaults new file mode 100644 index 0000000000..41775e0f20 --- /dev/null +++ b/examples/bluetooth/bluedroid/classic_bt/bt_spp_vfs_initiator/sdkconfig.ci.defaults @@ -0,0 +1 @@ +CONFIG_EXAMPLE_PEER_DEVICE_NAME="${CI_PIPELINE_ID}_SPP_VFS_ACCEPTOR" diff --git a/examples/bluetooth/bluedroid/classic_bt/hfp_ag/main/Kconfig.projbuild b/examples/bluetooth/bluedroid/classic_bt/hfp_ag/main/Kconfig.projbuild new file mode 100644 index 0000000000..5d40e1962d --- /dev/null +++ b/examples/bluetooth/bluedroid/classic_bt/hfp_ag/main/Kconfig.projbuild @@ -0,0 +1,7 @@ +menu "HFP Example Configuration" + config EXAMPLE_LOCAL_DEVICE_NAME + string "Local Device Name" + default "ESP_HFP_AG" + help + Use this option to set local device name. +endmenu diff --git a/examples/bluetooth/bluedroid/classic_bt/hfp_ag/main/main.c b/examples/bluetooth/bluedroid/classic_bt/hfp_ag/main/main.c index 316cdc5f6f..cdf18ea21f 100644 --- a/examples/bluetooth/bluedroid/classic_bt/hfp_ag/main/main.c +++ b/examples/bluetooth/bluedroid/classic_bt/hfp_ag/main/main.c @@ -27,6 +27,8 @@ #define BT_HF_AG_TAG "HF_AG_DEMO_MAIN" +static const char local_device_name[] = CONFIG_EXAMPLE_LOCAL_DEVICE_NAME; + /* event for handler "hf_ag_hdl_stack_up */ enum { BT_APP_EVT_STACK_UP = 0, @@ -53,8 +55,7 @@ static void bt_hf_hdl_stack_evt(uint16_t event, void *p_param) case BT_APP_EVT_STACK_UP: { /* set up device name */ - char *dev_name = "ESP_HFP_AG"; - esp_bt_dev_set_device_name(dev_name); + esp_bt_dev_set_device_name(local_device_name); esp_hf_ag_register_callback(bt_app_hf_cb); diff --git a/examples/bluetooth/bluedroid/classic_bt/hfp_ag/sdkconfig.ci.all b/examples/bluetooth/bluedroid/classic_bt/hfp_ag/sdkconfig.ci.all new file mode 100644 index 0000000000..1d7593af05 --- /dev/null +++ b/examples/bluetooth/bluedroid/classic_bt/hfp_ag/sdkconfig.ci.all @@ -0,0 +1,2 @@ +CONFIG_BT_HFP_AUDIO_DATA_PATH_HCI=y +CONFIG_EXAMPLE_LOCAL_DEVICE_NAME="${CI_PIPELINE_ID}_HFP" diff --git a/examples/bluetooth/bluedroid/classic_bt/hfp_hf/main/Kconfig.projbuild b/examples/bluetooth/bluedroid/classic_bt/hfp_hf/main/Kconfig.projbuild new file mode 100644 index 0000000000..65e04f08e6 --- /dev/null +++ b/examples/bluetooth/bluedroid/classic_bt/hfp_hf/main/Kconfig.projbuild @@ -0,0 +1,15 @@ +menu "HFP Example Configuration" + config EXAMPLE_SSP_ENABLED + bool "Secure Simple Pairing" + depends on BT_CLASSIC_ENABLED + default y + help + This enables the Secure Simple Pairing. If disable this option, + Bluedroid will only support Legacy Pairing + + config EXAMPLE_PEER_DEVICE_NAME + string "Target Device Name" + default "ESP_HFP_AG" + help + Use this option to set target device name to connect. +endmenu diff --git a/examples/bluetooth/bluedroid/classic_bt/hfp_hf/main/main.c b/examples/bluetooth/bluedroid/classic_bt/hfp_hf/main/main.c index 7a00ed1390..3793e0cadd 100644 --- a/examples/bluetooth/bluedroid/classic_bt/hfp_hf/main/main.c +++ b/examples/bluetooth/bluedroid/classic_bt/hfp_hf/main/main.c @@ -29,8 +29,7 @@ esp_bd_addr_t peer_addr = {0}; static char peer_bdname[ESP_BT_GAP_MAX_BDNAME_LEN + 1]; static uint8_t peer_bdname_len; - -static const char remote_device_name[] = "ESP_HFP_AG"; +static const char remote_device_name[] = CONFIG_EXAMPLE_PEER_DEVICE_NAME; static char *bda2str(esp_bd_addr_t bda, char *str, size_t size) { diff --git a/examples/bluetooth/bluedroid/classic_bt/hfp_hf/sdkconfig.ci.all b/examples/bluetooth/bluedroid/classic_bt/hfp_hf/sdkconfig.ci.all new file mode 100644 index 0000000000..94fafd42ea --- /dev/null +++ b/examples/bluetooth/bluedroid/classic_bt/hfp_hf/sdkconfig.ci.all @@ -0,0 +1,2 @@ +CONFIG_BT_HFP_AUDIO_DATA_PATH_HCI=y +CONFIG_EXAMPLE_PEER_DEVICE_NAME="${CI_PIPELINE_ID}_HFP" diff --git a/examples/bluetooth/bluedroid/classic_bt/pytest_classic_bt_test.py b/examples/bluetooth/bluedroid/classic_bt/pytest_classic_bt_test.py index 990b24a0b2..07aa12a941 100644 --- a/examples/bluetooth/bluedroid/classic_bt/pytest_classic_bt_test.py +++ b/examples/bluetooth/bluedroid/classic_bt/pytest_classic_bt_test.py @@ -93,7 +93,7 @@ def test_bt_a2dp(app_path: str, dut: Tuple[IdfDut, IdfDut]) -> None: 'count, app_path, target, config', [ (2, f'{os.path.join(os.path.dirname(__file__), "hfp_ag")}|{os.path.join(os.path.dirname(__file__), "hfp_hf")}', - 'esp32|esp32', 'vohci'), + 'esp32|esp32', 'all'), ], indirect=True, ) diff --git a/examples/bluetooth/esp_hid_host/main/Kconfig.projbuild b/examples/bluetooth/esp_hid_host/main/Kconfig.projbuild new file mode 100644 index 0000000000..c72314895f --- /dev/null +++ b/examples/bluetooth/esp_hid_host/main/Kconfig.projbuild @@ -0,0 +1,23 @@ +menu "HID Example Configuration" + config EXAMPLE_SSP_ENABLED + bool "Secure Simple Pairing" + depends on BT_CLASSIC_ENABLED + default y + help + This enables the Secure Simple Pairing. If disable this option, + Bluedroid will only support Legacy Pairing + + config EXAMPLE_HID_HOST_ENABLED + bool "Enable Example HID Host" + depends on BT_NIMBLE_ENABLED + default y + select BT_NIMBLE_HID_SERVICE + help + This enables Nimble HID Host + + config EXAMPLE_PEER_DEVICE_NAME + string "Target Device Name" + default "HID Mouse Example" + help + Use this option to set target device name to connect. +endmenu diff --git a/examples/bluetooth/esp_hid_host/main/esp_hid_host_main.c b/examples/bluetooth/esp_hid_host/main/esp_hid_host_main.c index 9bda5091f8..fe95e59c4f 100644 --- a/examples/bluetooth/esp_hid_host/main/esp_hid_host_main.c +++ b/examples/bluetooth/esp_hid_host/main/esp_hid_host_main.c @@ -27,6 +27,10 @@ #include "esp_hidh.h" #include "esp_hid_gap.h" +#if CONFIG_BT_HID_HOST_ENABLED +static const char *remote_device_name = CONFIG_EXAMPLE_PEER_DEVICE_NAME; +#endif // CONFIG_BT_HID_HOST_ENABLED + static const char *TAG = "ESP_HIDH_DEMO"; static char *bda2str(esp_bd_addr_t bda, char *str, size_t size) @@ -119,16 +123,26 @@ void hid_demo_task(void *pvParameters) printf("] srv 0x%03x, ", r->bt.cod.service); print_uuid(&r->bt.uuid); printf(", "); + if (strncmp(r->name, remote_device_name, strlen(remote_device_name)) == 0) { + break; + } } #endif /* CONFIG_BT_HID_HOST_ENABLED */ printf("NAME: %s ", r->name ? r->name : ""); printf("\n"); r = r->next; } + +#if CONFIG_BT_HID_HOST_ENABLED + if (cr && strncmp(cr->name, remote_device_name, strlen(remote_device_name)) == 0) { + esp_hidh_dev_open(cr->bda, cr->transport, cr->ble.addr_type); + } +#else if (cr) { //open the last result esp_hidh_dev_open(cr->bda, cr->transport, cr->ble.addr_type); } +#endif // CONFIG_BT_HID_HOST_ENABLED //free the results esp_hid_scan_results_free(results); } diff --git a/examples/bluetooth/esp_hid_host/sdkconfig.ci.defaults b/examples/bluetooth/esp_hid_host/sdkconfig.ci.defaults new file mode 100644 index 0000000000..97b876adff --- /dev/null +++ b/examples/bluetooth/esp_hid_host/sdkconfig.ci.defaults @@ -0,0 +1 @@ +CONFIG_EXAMPLE_PEER_DEVICE_NAME="${CI_PIPELINE_ID}_HID_MOUSE_DEVICE"