Merge branch 'feat/add_sdkconfig_for_ci_in_bt_example' into 'master'

Feat/add sdkconfig for ci in bt example

See merge request espressif/esp-idf!32474
This commit is contained in:
Wang Meng Yang
2024-08-05 17:57:08 +08:00
38 changed files with 164 additions and 59 deletions

View File

@@ -48,4 +48,9 @@ menu "A2DP Example Configuration"
help help
GPIO number to use for I2S Data Driver. 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 endmenu

View File

@@ -26,7 +26,7 @@
#include "esp_avrc_api.h" #include "esp_avrc_api.h"
/* device name */ /* device name */
#define LOCAL_DEVICE_NAME "ESP_SPEAKER" static const char local_device_name[] = CONFIG_EXAMPLE_LOCAL_DEVICE_NAME;
/* event for stack up */ /* event for stack up */
enum { enum {
@@ -148,7 +148,7 @@ static void bt_av_hdl_stack_evt(uint16_t event, void *p_param)
switch (event) { switch (event) {
/* when do the stack up, this event comes */ /* when do the stack up, this event comes */
case BT_APP_EVT_STACK_UP: { case BT_APP_EVT_STACK_UP: {
esp_bt_gap_set_device_name(LOCAL_DEVICE_NAME); esp_bt_gap_set_device_name(local_device_name);
esp_bt_dev_register_callback(bt_app_dev_cb); esp_bt_dev_register_callback(bt_app_dev_cb);
esp_bt_gap_register_callback(bt_app_gap_cb); esp_bt_gap_register_callback(bt_app_gap_cb);

View File

@@ -0,0 +1 @@
CONFIG_EXAMPLE_LOCAL_DEVICE_NAME="${CI_PIPELINE_ID}_A2DP_SINK"

View File

@@ -6,4 +6,10 @@ menu "A2DP Example Configuration"
help help
This enables the Secure Simple Pairing. If disable this option, This enables the Secure Simple Pairing. If disable this option,
Bluedroid will only support Legacy Pairing 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 endmenu

View File

@@ -30,7 +30,6 @@
#define BT_RC_CT_TAG "RC_CT" #define BT_RC_CT_TAG "RC_CT"
/* device name */ /* device name */
#define TARGET_DEVICE_NAME "ESP_SPEAKER"
#define LOCAL_DEVICE_NAME "ESP_A2DP_SRC" #define LOCAL_DEVICE_NAME "ESP_A2DP_SRC"
/* AVRCP used transaction label */ /* 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 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 TimerHandle_t s_tmr; /* handle of heart beat timer */
static const char remote_device_name[] = CONFIG_EXAMPLE_PEER_DEVICE_NAME;
/********************************* /*********************************
* STATIC FUNCTION DEFINITIONS * 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 */ /* search for target device in its Extended Inqury Response */
if (eir) { if (eir) {
get_name_from_eir(eir, s_peer_bdname, NULL); 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); 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; s_a2d_state = APP_AV_STATE_DISCOVERED;
memcpy(s_peer_bda, param->disc_res.bda, ESP_BD_ADDR_LEN); memcpy(s_peer_bda, param->disc_res.bda, ESP_BD_ADDR_LEN);

View File

@@ -0,0 +1 @@
CONFIG_EXAMPLE_PEER_DEVICE_NAME="${CI_PIPELINE_ID}_A2DP_SINK"

View File

@@ -6,4 +6,10 @@ menu "HID Example Configuration"
help help
This enables the Secure Simple Pairing. If disable this option, This enables the Secure Simple Pairing. If disable this option,
Bluedroid will only support Legacy Pairing 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 endmenu

View File

@@ -23,6 +23,8 @@
#define REPORT_PROTOCOL_MOUSE_REPORT_SIZE (4) #define REPORT_PROTOCOL_MOUSE_REPORT_SIZE (4)
#define REPORT_BUFFER_SIZE REPORT_PROTOCOL_MOUSE_REPORT_SIZE #define REPORT_BUFFER_SIZE REPORT_PROTOCOL_MOUSE_REPORT_SIZE
static const char local_device_name[] = CONFIG_EXAMPLE_LOCAL_DEVICE_NAME;
typedef struct { typedef struct {
esp_hidd_app_param_t app_param; esp_hidd_app_param_t app_param;
esp_hidd_qos_param_t both_qos; esp_hidd_qos_param_t both_qos;
@@ -434,7 +436,7 @@ void app_main(void)
} }
ESP_LOGI(TAG, "setting device name"); ESP_LOGI(TAG, "setting device name");
esp_bt_gap_set_device_name("HID Mouse Example"); esp_bt_gap_set_device_name(local_device_name);
ESP_LOGI(TAG, "setting cod major, peripheral"); ESP_LOGI(TAG, "setting cod major, peripheral");
esp_bt_cod_t cod; esp_bt_cod_t cod;

View File

@@ -0,0 +1 @@
CONFIG_EXAMPLE_LOCAL_DEVICE_NAME="${CI_PIPELINE_ID}_HID_MOUSE_DEVICE"

View File

@@ -6,4 +6,10 @@ menu "L2CAP Example Configuration"
help help
This enables the Secure Simple Pairing. If disable this option, This enables the Secure Simple Pairing. If disable this option,
Bluedroid will only support Legacy Pairing 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 endmenu

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Unlicense OR CC0-1.0 * SPDX-License-Identifier: Unlicense OR CC0-1.0
*/ */
@@ -30,12 +30,12 @@
#define L2CAP_TAG "L2CAP_TAG" #define L2CAP_TAG "L2CAP_TAG"
#define SDP_TAG "SDP_TAG" #define SDP_TAG "SDP_TAG"
#define EXAMPLE_DEVICE_NAME "ESP_BT_L2CAP_CLIENT" #define EXAMPLE_DEVICE_NAME "ESP_BT_L2CAP_CLIENT"
#define TARGET_DEVICE_NAME "ESP_BT_L2CAP_SERVER"
#define L2CAP_DATA_LEN 100 #define L2CAP_DATA_LEN 100
#define BT_L2CAP_DYNMIC_PSM 0x1001 #define BT_L2CAP_DYNMIC_PSM 0x1001
#define BT_UNUSED_RFCOMM -1 #define BT_UNUSED_RFCOMM -1
#define BT_UNKONWN_PROFILE_VERSION 0x0102 #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 esp_bt_l2cap_cntl_flags_t sec_mask = ESP_BT_L2CAP_SEC_AUTHENTICATE;
static char *sdp_service_name = "Unknown_profile"; static char *sdp_service_name = "Unknown_profile";
static const uint8_t UUID_UNKNOWN[] = {0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10, 0x00, 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 */ /* search for target device in its Extended Inqury Response */
if (eir) { if (eir) {
get_name_from_eir(eir, peer_bdname, NULL); 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, "Found a target device, address %s, name %s", bda_str, peer_bdname);
ESP_LOGI(L2CAP_TAG, "Cancel device discovery ..."); ESP_LOGI(L2CAP_TAG, "Cancel device discovery ...");
esp_bt_gap_cancel_discovery(); esp_bt_gap_cancel_discovery();

View File

@@ -0,0 +1 @@
CONFIG_EXAMPLE_PEER_DEVICE_NAME="${CI_PIPELINE_ID}_L2CAP_SERVER"

View File

@@ -6,4 +6,10 @@ menu "L2CAP Example Configuration"
help help
This enables the Secure Simple Pairing. If disable this option, This enables the Secure Simple Pairing. If disable this option,
Bluedroid will only support Legacy Pairing 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 endmenu

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Unlicense OR CC0-1.0 * SPDX-License-Identifier: Unlicense OR CC0-1.0
*/ */
@@ -29,12 +29,12 @@
#define L2CAP_TAG "L2CAP_TAG" #define L2CAP_TAG "L2CAP_TAG"
#define SDP_TAG "SDP_TAG" #define SDP_TAG "SDP_TAG"
#define EXAMPLE_DEVICE_NAME "ESP_BT_L2CAP_SERVER"
#define L2CAP_DATA_LEN 100 #define L2CAP_DATA_LEN 100
#define BT_UNUSED_RFCOMM -1 #define BT_UNUSED_RFCOMM -1
#define BT_L2CAP_DYNMIC_PSM 0x1001 #define BT_L2CAP_DYNMIC_PSM 0x1001
#define BT_UNKONWN_PROFILE_VERSION 0x0102 #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 esp_bt_l2cap_cntl_flags_t sec_mask = ESP_BT_L2CAP_SEC_AUTHENTICATE;
static char *sdp_service_name = "Unknown_profile"; static char *sdp_service_name = "Unknown_profile";
static const uint8_t UUID_UNKNOWN[] = {0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10, 0x00, static const uint8_t UUID_UNKNOWN[] = {0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10, 0x00,
@@ -269,7 +269,7 @@ static void esp_hdl_sdp_cb_evt(uint16_t event, void *p_param)
case ESP_SDP_CREATE_RECORD_COMP_EVT: case ESP_SDP_CREATE_RECORD_COMP_EVT:
ESP_LOGI(SDP_TAG, "ESP_SDP_CREATE_RECORD_COMP_EVT: status:%d", sdp_param->create_record.status); ESP_LOGI(SDP_TAG, "ESP_SDP_CREATE_RECORD_COMP_EVT: status:%d", sdp_param->create_record.status);
if (sdp_param->create_record.status == ESP_SDP_SUCCESS) { if (sdp_param->create_record.status == ESP_SDP_SUCCESS) {
esp_bt_gap_set_device_name(EXAMPLE_DEVICE_NAME); esp_bt_gap_set_device_name(local_device_name);
esp_bt_gap_set_scan_mode(ESP_BT_CONNECTABLE, ESP_BT_GENERAL_DISCOVERABLE); esp_bt_gap_set_scan_mode(ESP_BT_CONNECTABLE, ESP_BT_GENERAL_DISCOVERABLE);
} }
break; break;

View File

@@ -0,0 +1 @@
CONFIG_EXAMPLE_LOCAL_DEVICE_NAME="${CI_PIPELINE_ID}_L2CAP_SERVER"

View File

@@ -6,4 +6,10 @@ menu "SPP Example Configuration"
help help
This enables the Secure Simple Pairing. If disable this option, This enables the Secure Simple Pairing. If disable this option,
Bluedroid will only support Legacy Pairing 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 endmenu

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Unlicense OR CC0-1.0 * SPDX-License-Identifier: Unlicense OR CC0-1.0
*/ */
@@ -25,11 +25,11 @@
#define SPP_TAG "SPP_ACCEPTOR_DEMO" #define SPP_TAG "SPP_ACCEPTOR_DEMO"
#define SPP_SERVER_NAME "SPP_SERVER" #define SPP_SERVER_NAME "SPP_SERVER"
#define EXAMPLE_DEVICE_NAME "ESP_SPP_ACCEPTOR"
#define SPP_SHOW_DATA 0 #define SPP_SHOW_DATA 0
#define SPP_SHOW_SPEED 1 #define SPP_SHOW_SPEED 1
#define SPP_SHOW_MODE SPP_SHOW_SPEED /*Choose show mode: show data or speed*/ #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 esp_spp_mode_t esp_spp_mode = ESP_SPP_MODE_CB;
static const bool esp_spp_enable_l2cap_ertm = true; 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) { 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, 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); param->start.scn);
esp_bt_gap_set_device_name(EXAMPLE_DEVICE_NAME); esp_bt_gap_set_device_name(local_device_name);
esp_bt_gap_set_scan_mode(ESP_BT_CONNECTABLE, ESP_BT_GENERAL_DISCOVERABLE); esp_bt_gap_set_scan_mode(ESP_BT_CONNECTABLE, ESP_BT_GENERAL_DISCOVERABLE);
} else { } else {
ESP_LOGE(SPP_TAG, "ESP_SPP_START_EVT status:%d", param->start.status); ESP_LOGE(SPP_TAG, "ESP_SPP_START_EVT status:%d", param->start.status);

View File

@@ -0,0 +1 @@
CONFIG_EXAMPLE_LOCAL_DEVICE_NAME="${CI_PIPELINE_ID}_SPP_ACCEPTOR"

View File

@@ -6,4 +6,10 @@ menu "SPP Example Configuration"
help help
This enables the Secure Simple Pairing. If disable this option, This enables the Secure Simple Pairing. If disable this option,
Bluedroid will only support Legacy Pairing 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 endmenu

View File

@@ -43,7 +43,8 @@ static const esp_spp_role_t role_master = ESP_SPP_ROLE_MASTER;
esp_bd_addr_t peer_bd_addr = {0}; esp_bd_addr_t peer_bd_addr = {0};
static uint8_t peer_bdname_len; static uint8_t peer_bdname_len;
static char peer_bdname[ESP_BT_GAP_MAX_BDNAME_LEN + 1]; 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 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_len = 30;
static const uint8_t inq_num_rsps = 0; static const uint8_t inq_num_rsps = 0;

View File

@@ -0,0 +1 @@
CONFIG_EXAMPLE_PEER_DEVICE_NAME="${CI_PIPELINE_ID}_SPP_ACCEPTOR"

View File

@@ -6,4 +6,10 @@ menu "SPP Example Configuration"
help help
This enables the Secure Simple Pairing. If disable this option, This enables the Secure Simple Pairing. If disable this option,
Bluedroid will only support Legacy Pairing 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 endmenu

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Unlicense OR CC0-1.0 * SPDX-License-Identifier: Unlicense OR CC0-1.0
*/ */
@@ -37,8 +37,8 @@
#define SPP_TAG "SPP_ACCEPTOR_DEMO" #define SPP_TAG "SPP_ACCEPTOR_DEMO"
#define SPP_SERVER_NAME "SPP_SERVER" #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_sec_t sec_mask = ESP_SPP_SEC_AUTHENTICATE;
static const esp_spp_role_t role_slave = ESP_SPP_ROLE_SLAVE; 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) { 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, 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); param->start.scn);
esp_bt_gap_set_device_name(EXAMPLE_DEVICE_NAME); esp_bt_gap_set_device_name(local_device_name);
esp_bt_gap_set_scan_mode(ESP_BT_CONNECTABLE, ESP_BT_GENERAL_DISCOVERABLE); esp_bt_gap_set_scan_mode(ESP_BT_CONNECTABLE, ESP_BT_GENERAL_DISCOVERABLE);
} else { } else {
ESP_LOGE(SPP_TAG, "ESP_SPP_START_EVT status:%d", param->start.status); ESP_LOGE(SPP_TAG, "ESP_SPP_START_EVT status:%d", param->start.status);

View File

@@ -0,0 +1 @@
CONFIG_EXAMPLE_LOCAL_DEVICE_NAME="${CI_PIPELINE_ID}_SPP_VFS_ACCEPTOR"

View File

@@ -6,4 +6,10 @@ menu "SPP Example Configuration"
help help
This enables the Secure Simple Pairing. If disable this option, This enables the Secure Simple Pairing. If disable this option,
Bluedroid will only support Legacy Pairing 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 endmenu

View File

@@ -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 esp_bd_addr_t peer_bd_addr;
static uint8_t peer_bdname_len; static uint8_t peer_bdname_len;
static char peer_bdname[ESP_BT_GAP_MAX_BDNAME_LEN + 1]; 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 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_len = 30;
static const uint8_t inq_num_rsps = 0; static const uint8_t inq_num_rsps = 0;

View File

@@ -0,0 +1 @@
CONFIG_EXAMPLE_PEER_DEVICE_NAME="${CI_PIPELINE_ID}_SPP_VFS_ACCEPTOR"

View File

@@ -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

View File

@@ -27,6 +27,8 @@
#define BT_HF_AG_TAG "HF_AG_DEMO_MAIN" #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 */ /* event for handler "hf_ag_hdl_stack_up */
enum { enum {
BT_APP_EVT_STACK_UP = 0, BT_APP_EVT_STACK_UP = 0,
@@ -52,9 +54,7 @@ static void bt_hf_hdl_stack_evt(uint16_t event, void *p_param)
{ {
case BT_APP_EVT_STACK_UP: case BT_APP_EVT_STACK_UP:
{ {
/* set up device name */ esp_bt_gap_set_device_name(local_device_name);
char *dev_name = "ESP_HFP_AG";
esp_bt_gap_set_device_name(dev_name);
esp_hf_ag_register_callback(bt_app_hf_cb); esp_hf_ag_register_callback(bt_app_hf_cb);

View File

@@ -0,0 +1,2 @@
CONFIG_BT_HFP_AUDIO_DATA_PATH_HCI=y
CONFIG_EXAMPLE_LOCAL_DEVICE_NAME="${CI_PIPELINE_ID}_HFP"

View File

@@ -6,4 +6,10 @@ menu "HFP Example Configuration"
help help
This enables the Secure Simple Pairing. If disable this option, This enables the Secure Simple Pairing. If disable this option,
Bluedroid will only support Legacy Pairing 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 endmenu

View File

@@ -29,8 +29,7 @@
esp_bd_addr_t peer_addr = {0}; esp_bd_addr_t peer_addr = {0};
static char peer_bdname[ESP_BT_GAP_MAX_BDNAME_LEN + 1]; static char peer_bdname[ESP_BT_GAP_MAX_BDNAME_LEN + 1];
static uint8_t peer_bdname_len; static uint8_t peer_bdname_len;
static const char remote_device_name[] = CONFIG_EXAMPLE_PEER_DEVICE_NAME;
static const char remote_device_name[] = "ESP_HFP_AG";
static char *bda2str(esp_bd_addr_t bda, char *str, size_t size) static char *bda2str(esp_bd_addr_t bda, char *str, size_t size)
{ {

View File

@@ -0,0 +1,2 @@
CONFIG_BT_HFP_AUDIO_DATA_PATH_HCI=y
CONFIG_EXAMPLE_PEER_DEVICE_NAME="${CI_PIPELINE_ID}_HFP"

View File

@@ -32,8 +32,8 @@ def test_bt_spp_only(app_path: str, dut: Tuple[IdfDut, IdfDut]) -> None:
if 'ESP_BT_GAP_KEY_REQ_EVT Please enter passkey!' in str(initiator_output): if 'ESP_BT_GAP_KEY_REQ_EVT Please enter passkey!' in str(initiator_output):
passkey = acceptor.expect(r'ESP_BT_GAP_KEY_NOTIF_EVT passkey:(\d+)').group(1).decode('utf8') passkey = acceptor.expect(r'ESP_BT_GAP_KEY_NOTIF_EVT passkey:(\d+)').group(1).decode('utf8')
initiator.write(f'spp key {passkey};') initiator.write(f'spp key {passkey};')
acceptor.expect_exact('authentication success: ESP_SPP_INITIATOR', timeout=30) acceptor.expect_exact('authentication success', timeout=30)
initiator.expect_exact('authentication success: ESP_SPP_ACCEPTOR', timeout=30) initiator.expect_exact('authentication success', timeout=30)
acceptor.expect_exact('ESP_SPP_SRV_OPEN_EVT status:0', timeout=30) acceptor.expect_exact('ESP_SPP_SRV_OPEN_EVT status:0', timeout=30)
initiator.expect_exact('ESP_SPP_OPEN_EVT', timeout=30) initiator.expect_exact('ESP_SPP_OPEN_EVT', timeout=30)
@@ -79,7 +79,7 @@ def test_bt_a2dp(app_path: str, dut: Tuple[IdfDut, IdfDut]) -> None:
source_dut = dut[1] source_dut = dut[1]
source_dut_mac = source_dut.expect(r'Bluetooth MAC: (([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2})').group(1).decode('utf8') source_dut_mac = source_dut.expect(r'Bluetooth MAC: (([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2})').group(1).decode('utf8')
sink_dut.expect_exact('A2DP PROF STATE: Init Complete', timeout=30) sink_dut.expect_exact('A2DP PROF STATE: Init Complete', timeout=30)
source_dut.expect_exact('a2dp connecting to peer: ESP_SPEAKER', timeout=30) source_dut.expect_exact('a2dp connecting to peer', timeout=30)
source_dut.expect_exact('a2dp connected', timeout=30) source_dut.expect_exact('a2dp connected', timeout=30)
source_dut.expect_exact('a2dp media start successfully', timeout=30) source_dut.expect_exact('a2dp media start successfully', timeout=30)
sink_dut.expect_exact(f'A2DP connection state: Connected, [{source_dut_mac}]', timeout=30) sink_dut.expect_exact(f'A2DP connection state: Connected, [{source_dut_mac}]', timeout=30)
@@ -93,7 +93,7 @@ def test_bt_a2dp(app_path: str, dut: Tuple[IdfDut, IdfDut]) -> None:
'count, app_path, target, config', [ 'count, app_path, target, config', [
(2, (2,
f'{os.path.join(os.path.dirname(__file__), "hfp_ag")}|{os.path.join(os.path.dirname(__file__), "hfp_hf")}', 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, indirect=True,
) )
@@ -101,7 +101,7 @@ def test_bt_hfp(app_path: str, dut: Tuple[IdfDut, IdfDut]) -> None:
hfp_ag = dut[0] hfp_ag = dut[0]
hfp_hf = dut[1] hfp_hf = dut[1]
hfp_hf.expect_exact('Found a target device name: ESP_HFP_AG', timeout=30) hfp_hf.expect_exact('Found a target device name', timeout=30)
hfp_hf.expect_exact('connection state connected', timeout=30) hfp_hf.expect_exact('connection state connected', timeout=30)
hfp_hf.expect_exact('connection state slc_connected', timeout=30) hfp_hf.expect_exact('connection state slc_connected', timeout=30)
hfp_ag.expect_exact('connection state CONNECTED', timeout=30) hfp_ag.expect_exact('connection state CONNECTED', timeout=30)

View File

@@ -14,4 +14,10 @@ menu "HID Example Configuration"
select BT_NIMBLE_HID_SERVICE select BT_NIMBLE_HID_SERVICE
help help
This enables Nimble HID Host 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 endmenu

View File

@@ -341,38 +341,39 @@ static void handle_bt_device_result(struct disc_res_param *disc_res)
uint8_t len = 0; uint8_t len = 0;
uint8_t *data = 0; uint8_t *data = 0;
data = esp_bt_gap_resolve_eir_data((uint8_t *)prop->val, ESP_BT_EIR_TYPE_CMPL_16BITS_UUID, &len); do {
if (data == NULL) { data = esp_bt_gap_resolve_eir_data((uint8_t *)prop->val, ESP_BT_EIR_TYPE_CMPL_16BITS_UUID, &len);
data = esp_bt_gap_resolve_eir_data((uint8_t *)prop->val, ESP_BT_EIR_TYPE_INCMPL_16BITS_UUID, &len); if (data == NULL) {
} data = esp_bt_gap_resolve_eir_data((uint8_t *)prop->val, ESP_BT_EIR_TYPE_INCMPL_16BITS_UUID, &len);
if (data && len == ESP_UUID_LEN_16) { }
uuid.len = ESP_UUID_LEN_16; if (data && len == ESP_UUID_LEN_16) {
uuid.uuid.uuid16 = data[0] + (data[1] << 8); uuid.len = ESP_UUID_LEN_16;
GAP_DBG_PRINTF(", "); print_uuid(&uuid); uuid.uuid.uuid16 = data[0] + (data[1] << 8);
continue; GAP_DBG_PRINTF(", "); print_uuid(&uuid);
} break;
}
data = esp_bt_gap_resolve_eir_data((uint8_t *)prop->val, ESP_BT_EIR_TYPE_CMPL_32BITS_UUID, &len); data = esp_bt_gap_resolve_eir_data((uint8_t *)prop->val, ESP_BT_EIR_TYPE_CMPL_32BITS_UUID, &len);
if (data == NULL) { if (data == NULL) {
data = esp_bt_gap_resolve_eir_data((uint8_t *)prop->val, ESP_BT_EIR_TYPE_INCMPL_32BITS_UUID, &len); data = esp_bt_gap_resolve_eir_data((uint8_t *)prop->val, ESP_BT_EIR_TYPE_INCMPL_32BITS_UUID, &len);
} }
if (data && len == ESP_UUID_LEN_32) { if (data && len == ESP_UUID_LEN_32) {
uuid.len = len; uuid.len = len;
memcpy(&uuid.uuid.uuid32, data, sizeof(uint32_t)); memcpy(&uuid.uuid.uuid32, data, sizeof(uint32_t));
GAP_DBG_PRINTF(", "); print_uuid(&uuid); GAP_DBG_PRINTF(", "); print_uuid(&uuid);
continue; break;
} }
data = esp_bt_gap_resolve_eir_data((uint8_t *)prop->val, ESP_BT_EIR_TYPE_CMPL_128BITS_UUID, &len); data = esp_bt_gap_resolve_eir_data((uint8_t *)prop->val, ESP_BT_EIR_TYPE_CMPL_128BITS_UUID, &len);
if (data == NULL) { if (data == NULL) {
data = esp_bt_gap_resolve_eir_data((uint8_t *)prop->val, ESP_BT_EIR_TYPE_INCMPL_128BITS_UUID, &len); data = esp_bt_gap_resolve_eir_data((uint8_t *)prop->val, ESP_BT_EIR_TYPE_INCMPL_128BITS_UUID, &len);
} }
if (data && len == ESP_UUID_LEN_128) { if (data && len == ESP_UUID_LEN_128) {
uuid.len = len; uuid.len = len;
memcpy(uuid.uuid.uuid128, (uint8_t *)data, len); memcpy(uuid.uuid.uuid128, (uint8_t *)data, len);
GAP_DBG_PRINTF(", "); print_uuid(&uuid); GAP_DBG_PRINTF(", "); print_uuid(&uuid);
continue; }
} } while (0);
//try to find a name //try to find a name
if (name == NULL) { if (name == NULL) {

View File

@@ -51,6 +51,10 @@
static const char *TAG = "ESP_HIDH_DEMO"; static const char *TAG = "ESP_HIDH_DEMO";
#if CONFIG_BT_HID_HOST_ENABLED
static const char * remote_device_name = CONFIG_EXAMPLE_PEER_DEVICE_NAME;
#endif // CONFIG_BT_HID_HOST_ENABLED
static char *bda2str(esp_bd_addr_t bda, char *str, size_t size) static char *bda2str(esp_bd_addr_t bda, char *str, size_t size)
{ {
if (bda == NULL || str == NULL || size < 18) { if (bda == NULL || str == NULL || size < 18) {
@@ -148,16 +152,26 @@ void hid_demo_task(void *pvParameters)
printf("] srv 0x%03x, ", r->bt.cod.service); printf("] srv 0x%03x, ", r->bt.cod.service);
print_uuid(&r->bt.uuid); print_uuid(&r->bt.uuid);
printf(", "); printf(", ");
if (strncmp(r->name, remote_device_name, strlen(remote_device_name)) == 0) {
break;
}
} }
#endif /* CONFIG_BT_HID_HOST_ENABLED */ #endif /* CONFIG_BT_HID_HOST_ENABLED */
printf("NAME: %s ", r->name ? r->name : ""); printf("NAME: %s ", r->name ? r->name : "");
printf("\n"); printf("\n");
r = r->next; 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) { if (cr) {
//open the last result //open the last result
esp_hidh_dev_open(cr->bda, cr->transport, cr->ble.addr_type); esp_hidh_dev_open(cr->bda, cr->transport, cr->ble.addr_type);
} }
#endif // CONFIG_BT_HID_HOST_ENABLED
//free the results //free the results
esp_hid_scan_results_free(results); esp_hid_scan_results_free(results);
} }

View File

@@ -0,0 +1 @@
CONFIG_EXAMPLE_PEER_DEVICE_NAME="${CI_PIPELINE_ID}_HID_MOUSE_DEVICE"