forked from espressif/esp-idf
Merge branch 'bugfix/remove_ble_func_discard_declaration_v5.2' into 'release/v5.2'
fix(ble/bluedroid): Remove BLE functions discard declaration (backport v5.2) See merge request espressif/esp-idf!30390
This commit is contained in:
@@ -1132,7 +1132,7 @@ int bt_mesh_gatts_service_start(struct bt_mesh_gatt_service *svc)
|
||||
|
||||
int bt_mesh_gatts_set_local_device_name(const char *name)
|
||||
{
|
||||
BTM_SetLocalDeviceName((char *)name);
|
||||
BTM_SetLocalDeviceName((char *)name, BT_DEVICE_TYPE_BLE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1481,7 +1481,7 @@ static void bt_mesh_bta_gattc_cb(tBTA_GATTC_EVT event, tBTA_GATTC *p_data)
|
||||
result = NULL;
|
||||
}
|
||||
|
||||
/* Register Notification fot Mesh Provisioning/Proxy Data Out Characteristic */
|
||||
/* Register Notification for Mesh Provisioning/Proxy Data Out Characteristic */
|
||||
status = BTA_GATTC_RegisterForNotifications(bt_mesh_gattc_if, bt_mesh_gattc_info[i].addr.val,
|
||||
bt_mesh_gattc_info[i].data_out_handle);
|
||||
if (status != BTA_GATT_OK) {
|
||||
|
@@ -397,9 +397,25 @@ esp_err_t esp_ble_gap_set_prefer_conn_params(esp_bd_addr_t bd_addr,
|
||||
|
||||
esp_err_t esp_ble_gap_set_device_name(const char *name)
|
||||
{
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
return esp_bt_dev_set_device_name(name);
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
if (!name){
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
if (strlen(name) > BTC_MAX_LOC_BD_NAME_LEN) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_ACT_SET_DEV_NAME;
|
||||
arg.set_dev_name.device_name = (char *)name;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), btc_gap_ble_arg_deep_copy, btc_gap_ble_arg_deep_free) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gap_get_device_name(void)
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -494,4 +494,40 @@ esp_err_t esp_bt_gap_set_acl_pkt_types(esp_bd_addr_t remote_bda, uint16_t pkt_ty
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_gap_bt_args_t), NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_gap_set_device_name(const char *name)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_gap_bt_args_t arg;
|
||||
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
if ((!name) || (strlen(name) > BTC_MAX_LOC_BD_NAME_LEN)) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BT;
|
||||
msg.act = BTC_GAP_BT_ACT_SET_DEV_NAME;
|
||||
arg.bt_set_dev_name.device_name = (char *)name;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_gap_bt_args_t), btc_gap_bt_arg_deep_copy,
|
||||
btc_gap_bt_arg_deep_free) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_gap_get_device_name(void)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BT;
|
||||
msg.act = BTC_GAP_BT_ACT_GET_DEV_NAME;
|
||||
|
||||
return (btc_transfer_context(&msg, NULL, 0, NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
#endif /* #if BTC_GAP_BT_INCLUDED == TRUE */
|
||||
|
@@ -70,7 +70,7 @@ esp_err_t esp_bluedroid_disable(void);
|
||||
* - ESP_OK : Succeed
|
||||
* - Other : Failed
|
||||
*/
|
||||
esp_err_t esp_bluedroid_init(void) __attribute__((deprecated("Please use esp_bluedroid_init_with_cfg")));
|
||||
esp_err_t esp_bluedroid_init(void);
|
||||
|
||||
/**
|
||||
* @brief Init and alloc the resource for bluetooth, must be prior to every bluetooth stuff.
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -105,7 +105,7 @@ typedef uint8_t esp_bt_eir_type_t;
|
||||
#define ESP_BT_ACL_PKT_TYPES_MASK_NO_2_DH5 0x1000
|
||||
#define ESP_BT_ACL_PKT_TYPES_MASK_NO_3_DH5 0x2000
|
||||
|
||||
// DM1 cann not be disabled. All options are mandatory to include DM1.
|
||||
// DM1 can not be disabled. All options are mandatory to include DM1.
|
||||
#define ESP_BT_ACL_DM1_ONLY (ESP_BT_ACL_PKT_TYPES_MASK_DM1 | 0x330e) /* 0x330e */
|
||||
#define ESP_BT_ACL_DH1_ONLY (ESP_BT_ACL_PKT_TYPES_MASK_DH1 | 0x330e) /* 0x331e */
|
||||
#define ESP_BT_ACL_DM3_ONLY (ESP_BT_ACL_PKT_TYPES_MASK_DM3 | 0x330e) /* 0x370e */
|
||||
@@ -142,7 +142,7 @@ typedef struct {
|
||||
uint8_t *p_url; /*!< URL point */
|
||||
} esp_bt_eir_data_t;
|
||||
|
||||
/// Major service class field of Class of Device, mutiple bits can be set
|
||||
/// Major service class field of Class of Device, multiple bits can be set
|
||||
typedef enum {
|
||||
ESP_BT_COD_SRVC_NONE = 0, /*!< None indicates an invalid value */
|
||||
ESP_BT_COD_SRVC_LMTD_DISCOVER = 0x1, /*!< Limited Discoverable Mode */
|
||||
@@ -266,6 +266,7 @@ typedef enum {
|
||||
ESP_BT_GAP_GET_PAGE_TO_EVT, /*!< Get page timeout event */
|
||||
ESP_BT_GAP_ACL_PKT_TYPE_CHANGED_EVT, /*!< Set ACL packet types event */
|
||||
ESP_BT_GAP_ENC_CHG_EVT, /*!< Encryption change event */
|
||||
ESP_BT_GAP_GET_DEV_NAME_CMPL_EVT, /*!< Get device name complete event */
|
||||
ESP_BT_GAP_EVT_MAX,
|
||||
} esp_bt_gap_cb_event_t;
|
||||
|
||||
@@ -475,6 +476,14 @@ typedef union {
|
||||
uint16_t handle; /*!< ACL connection handle */
|
||||
esp_bd_addr_t bda; /*!< remote bluetooth device address */
|
||||
} acl_disconn_cmpl_stat; /*!< ACL disconnection complete status parameter struct */
|
||||
|
||||
/**
|
||||
* @brief ESP_GAP_BT_GET_DEV_NAME_CMPL_EVT
|
||||
*/
|
||||
struct get_dev_name_cmpl_evt_param {
|
||||
esp_bt_status_t status; /*!< Indicate the get device name success status */
|
||||
char *name; /*!< Name of bluetooth device */
|
||||
} get_dev_name_cmpl; /*!< Get device name complete status parameter struct */
|
||||
} esp_bt_gap_cb_param_t;
|
||||
|
||||
/**
|
||||
@@ -541,7 +550,7 @@ static inline uint32_t esp_bt_gap_get_cod_format_type(uint32_t cod)
|
||||
*
|
||||
* @return
|
||||
* - true if cod is valid
|
||||
* - false otherise
|
||||
* - false otherwise
|
||||
*/
|
||||
static inline bool esp_bt_gap_is_valid_cod(uint32_t cod)
|
||||
{
|
||||
@@ -909,6 +918,26 @@ esp_err_t esp_bt_gap_get_page_timeout(void);
|
||||
*/
|
||||
esp_err_t esp_bt_gap_set_acl_pkt_types(esp_bd_addr_t remote_bda, esp_bt_acl_pkt_type_t pkt_types);
|
||||
|
||||
/**
|
||||
* @brief Set device name to the local device
|
||||
*
|
||||
* @param[in] name - device name.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*/
|
||||
esp_err_t esp_bt_gap_set_device_name(const char *name);
|
||||
|
||||
/**
|
||||
* @brief Get device name of the local device
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*/
|
||||
esp_err_t esp_bt_gap_get_device_name(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -683,9 +683,11 @@ static void bta_dm_disable_timer_cback (TIMER_LIST_ENT *p_tle)
|
||||
*******************************************************************************/
|
||||
void bta_dm_set_dev_name (tBTA_DM_MSG *p_data)
|
||||
{
|
||||
BTM_SetLocalDeviceName((char *)p_data->set_name.name);
|
||||
BTM_SetLocalDeviceName((char *)p_data->set_name.name, p_data->set_name.name_type);
|
||||
#if CLASSIC_BT_INCLUDED
|
||||
if (p_data->set_name.name_type & BT_DEVICE_TYPE_BREDR) {
|
||||
bta_dm_set_eir ((char *)p_data->set_name.name);
|
||||
}
|
||||
#endif /// CLASSIC_BT_INCLUDED
|
||||
}
|
||||
|
||||
@@ -704,7 +706,7 @@ void bta_dm_get_dev_name (tBTA_DM_MSG *p_data)
|
||||
tBTM_STATUS status;
|
||||
char *name = NULL;
|
||||
|
||||
status = BTM_ReadLocalDeviceName(&name);
|
||||
status = BTM_ReadLocalDeviceName(&name, p_data->get_name.name_type);
|
||||
if (p_data->get_name.p_cback) {
|
||||
(*p_data->get_name.p_cback)(status, name);
|
||||
}
|
||||
@@ -4151,7 +4153,7 @@ static void bta_dm_set_eir (char *local_name)
|
||||
if (p_bta_dm_eir_cfg->bta_dm_eir_included_name) {
|
||||
/* if local name is not provided, get it from controller */
|
||||
if ( local_name == NULL ) {
|
||||
if ( BTM_ReadLocalDeviceName( &local_name ) != BTM_SUCCESS ) {
|
||||
if ( BTM_ReadLocalDeviceName( &local_name, BT_DEVICE_TYPE_BREDR) != BTM_SUCCESS ) {
|
||||
APPL_TRACE_ERROR("Fail to read local device name for EIR");
|
||||
}
|
||||
}
|
||||
|
@@ -166,7 +166,7 @@ void BTA_DisableTestMode(void)
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_DmSetDeviceName(const char *p_name)
|
||||
void BTA_DmSetDeviceName(const char *p_name, tBT_DEVICE_TYPE name_type)
|
||||
{
|
||||
|
||||
tBTA_DM_API_SET_NAME *p_msg;
|
||||
@@ -176,6 +176,7 @@ void BTA_DmSetDeviceName(const char *p_name)
|
||||
/* truncate the name if needed */
|
||||
BCM_STRNCPY_S((char *)p_msg->name, p_name, BD_NAME_LEN);
|
||||
p_msg->name[BD_NAME_LEN] = '\0';
|
||||
p_msg->name_type = name_type;
|
||||
|
||||
bta_sys_sendmsg(p_msg);
|
||||
}
|
||||
@@ -191,13 +192,14 @@ void BTA_DmSetDeviceName(const char *p_name)
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_DmGetDeviceName(tBTA_GET_DEV_NAME_CBACK *p_cback)
|
||||
void BTA_DmGetDeviceName(tBTA_GET_DEV_NAME_CBACK *p_cback, tBT_DEVICE_TYPE name_type)
|
||||
{
|
||||
tBTA_DM_API_GET_NAME *p_msg;
|
||||
|
||||
if ((p_msg = (tBTA_DM_API_GET_NAME *) osi_malloc(sizeof(tBTA_DM_API_GET_NAME))) != NULL) {
|
||||
p_msg->hdr.event = BTA_DM_API_GET_NAME_EVT;
|
||||
p_msg->p_cback = p_cback;
|
||||
p_msg->name_type = name_type;
|
||||
bta_sys_sendmsg(p_msg);
|
||||
}
|
||||
}
|
||||
|
@@ -250,11 +250,13 @@ typedef struct {
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_NAME name; /* max 248 bytes name, plus must be Null terminated */
|
||||
tBT_DEVICE_TYPE name_type; /* name for BLE, name for BT or name for BTDM */
|
||||
} tBTA_DM_API_SET_NAME;
|
||||
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_GET_DEV_NAME_CBACK *p_cback;
|
||||
tBT_DEVICE_TYPE name_type;
|
||||
} tBTA_DM_API_GET_NAME;
|
||||
|
||||
#if (ESP_COEX_VSC_INCLUDED == TRUE)
|
||||
|
@@ -1720,7 +1720,7 @@ extern void BTA_DisableTestMode(void);
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_DmSetDeviceName(const char *p_name);
|
||||
extern void BTA_DmSetDeviceName(const char *p_name, tBT_DEVICE_TYPE name_type);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -1732,7 +1732,7 @@ extern void BTA_DmSetDeviceName(const char *p_name);
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_DmGetDeviceName(tBTA_GET_DEV_NAME_CBACK *p_cback);
|
||||
extern void BTA_DmGetDeviceName(tBTA_GET_DEV_NAME_CBACK *p_cback, tBT_DEVICE_TYPE name_type);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
@@ -41,7 +41,7 @@ void btc_dev_call_handler(btc_msg_t *msg)
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_DEV_ACT_SET_DEVICE_NAME:
|
||||
BTA_DmSetDeviceName(arg->set_dev_name.device_name);
|
||||
BTA_DmSetDeviceName(arg->set_dev_name.device_name, BT_DEVICE_TYPE_DUMO);
|
||||
break;
|
||||
#if (ESP_COEX_VSC_INCLUDED == TRUE)
|
||||
case BTC_DEV_ACT_CFG_COEX_STATUS:
|
||||
|
@@ -789,7 +789,7 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
|
||||
/* Set initial device name, it can be overwritten later */
|
||||
if (p_data->enable.status == BTA_SUCCESS) {
|
||||
const char *initial_device_name = "ESP32";
|
||||
BTA_DmSetDeviceName(initial_device_name);
|
||||
BTA_DmSetDeviceName(initial_device_name, BT_DEVICE_TYPE_DUMO);
|
||||
}
|
||||
btc_enable_bluetooth_evt(p_data->enable.status);
|
||||
break;
|
||||
|
@@ -1647,6 +1647,18 @@ void btc_gap_ble_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BTC_GAP_BLE_ACT_SET_DEV_NAME:{
|
||||
btc_ble_gap_args_t *src = (btc_ble_gap_args_t *)p_src;
|
||||
btc_ble_gap_args_t *dst = (btc_ble_gap_args_t *)p_dest;
|
||||
dst->set_dev_name.device_name = (char *)osi_malloc((BTC_MAX_LOC_BD_NAME_LEN + 1) * sizeof(char));
|
||||
if (dst->set_dev_name.device_name) {
|
||||
BCM_STRNCPY_S(dst->set_dev_name.device_name, src->set_dev_name.device_name, BTC_MAX_LOC_BD_NAME_LEN);
|
||||
dst->set_dev_name.device_name[BTC_MAX_LOC_BD_NAME_LEN] = '\0';
|
||||
} else {
|
||||
BTC_TRACE_ERROR("%s %d no mem\n",__func__, msg->act);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BTC_TRACE_ERROR("Unhandled deep copy %d\n", msg->act);
|
||||
break;
|
||||
@@ -1775,6 +1787,14 @@ void btc_gap_ble_arg_deep_free(btc_msg_t *msg)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BTC_GAP_BLE_ACT_SET_DEV_NAME:{
|
||||
char *p_name = ((btc_ble_gap_args_t *)msg->arg)->set_dev_name.device_name;
|
||||
if (p_name) {
|
||||
osi_free((uint8_t *)p_name);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
BTC_TRACE_DEBUG("Unhandled deep free %d\n", msg->act);
|
||||
break;
|
||||
@@ -1886,10 +1906,10 @@ void btc_gap_ble_call_handler(btc_msg_t *msg)
|
||||
break;
|
||||
#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)
|
||||
case BTC_GAP_BLE_ACT_SET_DEV_NAME:
|
||||
BTA_DmSetDeviceName(arg->set_dev_name.device_name);
|
||||
BTA_DmSetDeviceName(arg->set_dev_name.device_name, BT_DEVICE_TYPE_BLE);
|
||||
break;
|
||||
case BTC_GAP_BLE_ACT_GET_DEV_NAME:
|
||||
BTA_DmGetDeviceName(btc_gap_ble_get_dev_name_callback);
|
||||
BTA_DmGetDeviceName(btc_gap_ble_get_dev_name_callback, BT_DEVICE_TYPE_BLE);
|
||||
break;
|
||||
#if (BLE_42_FEATURE_SUPPORT == TRUE)
|
||||
case BTC_GAP_BLE_ACT_CFG_ADV_DATA_RAW:
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -853,6 +853,33 @@ static void btc_gap_bt_set_qos(btc_gap_bt_args_t *arg)
|
||||
#endif /// (BTA_DM_QOS_INCLUDED == TRUE)
|
||||
}
|
||||
|
||||
static void btc_gap_bt_get_dev_name_callback(UINT8 status, char *name)
|
||||
{
|
||||
esp_bt_gap_cb_param_t param;
|
||||
bt_status_t ret;
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
memset(¶m, 0, sizeof(esp_bt_gap_cb_param_t));
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_GAP_BT;
|
||||
msg.act = BTC_GAP_BT_GET_DEV_NAME_CMPL_EVT;
|
||||
|
||||
param.get_dev_name_cmpl.status = btc_btm_status_to_esp_status(status);
|
||||
param.get_dev_name_cmpl.name = (char *)osi_malloc(BTC_MAX_LOC_BD_NAME_LEN + 1);
|
||||
if (param.get_dev_name_cmpl.name) {
|
||||
BCM_STRNCPY_S(param.get_dev_name_cmpl.name, name, BTC_MAX_LOC_BD_NAME_LEN);
|
||||
param.get_dev_name_cmpl.name[BTC_MAX_LOC_BD_NAME_LEN] = '\0';
|
||||
} else {
|
||||
param.get_dev_name_cmpl.status = ESP_BT_STATUS_NOMEM;
|
||||
}
|
||||
|
||||
ret = btc_transfer_context(&msg, ¶m, sizeof(esp_bt_gap_cb_param_t), NULL, NULL);
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
void btc_gap_bt_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
{
|
||||
switch (msg->act) {
|
||||
@@ -872,6 +899,7 @@ void btc_gap_bt_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
case BTC_GAP_BT_ACT_SET_PAGE_TIMEOUT:
|
||||
case BTC_GAP_BT_ACT_GET_PAGE_TIMEOUT:
|
||||
case BTC_GAP_BT_ACT_SET_ACL_PKT_TYPES:
|
||||
case BTC_GAP_BT_ACT_GET_DEV_NAME:
|
||||
break;
|
||||
case BTC_GAP_BT_ACT_PASSKEY_REPLY:
|
||||
case BTC_GAP_BT_ACT_CONFIRM_REPLY:
|
||||
@@ -913,6 +941,18 @@ void btc_gap_bt_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BTC_GAP_BT_ACT_SET_DEV_NAME: {
|
||||
btc_gap_bt_args_t *src = (btc_gap_bt_args_t *)p_src;
|
||||
btc_gap_bt_args_t *dst = (btc_gap_bt_args_t *)p_dest;
|
||||
dst->bt_set_dev_name.device_name = (char *)osi_malloc((BTC_MAX_LOC_BD_NAME_LEN + 1) * sizeof(char));
|
||||
if (dst->bt_set_dev_name.device_name) {
|
||||
BCM_STRNCPY_S(dst->bt_set_dev_name.device_name, src->bt_set_dev_name.device_name, BTC_MAX_LOC_BD_NAME_LEN);
|
||||
dst->bt_set_dev_name.device_name[BTC_MAX_LOC_BD_NAME_LEN] = '\0';
|
||||
} else {
|
||||
BTC_TRACE_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BTC_TRACE_ERROR("Unhandled deep copy %d\n", msg->act);
|
||||
break;
|
||||
@@ -939,6 +979,7 @@ void btc_gap_bt_arg_deep_free(btc_msg_t *msg)
|
||||
case BTC_GAP_BT_ACT_SET_PAGE_TIMEOUT:
|
||||
case BTC_GAP_BT_ACT_GET_PAGE_TIMEOUT:
|
||||
case BTC_GAP_BT_ACT_SET_ACL_PKT_TYPES:
|
||||
case BTC_GAP_BT_ACT_GET_DEV_NAME:
|
||||
break;
|
||||
case BTC_GAP_BT_ACT_PASSKEY_REPLY:
|
||||
case BTC_GAP_BT_ACT_CONFIRM_REPLY:
|
||||
@@ -957,6 +998,13 @@ void btc_gap_bt_arg_deep_free(btc_msg_t *msg)
|
||||
osi_free(arg->config_eir.eir_data.p_url);
|
||||
}
|
||||
break;
|
||||
case BTC_GAP_BT_ACT_SET_DEV_NAME: {
|
||||
char *p_name = arg->bt_set_dev_name.device_name;
|
||||
if (p_name) {
|
||||
osi_free((uint8_t *)p_name);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BTC_TRACE_ERROR("Unhandled deep copy %d, arg: %p\n", msg->act, arg);
|
||||
break;
|
||||
@@ -1049,6 +1097,14 @@ void btc_gap_bt_call_handler(btc_msg_t *msg)
|
||||
btc_gap_set_acl_pkt_types(arg);
|
||||
break;
|
||||
}
|
||||
case BTC_GAP_BT_ACT_SET_DEV_NAME: {
|
||||
BTA_DmSetDeviceName(arg->bt_set_dev_name.device_name, BT_DEVICE_TYPE_BREDR);
|
||||
break;
|
||||
}
|
||||
case BTC_GAP_BT_ACT_GET_DEV_NAME: {
|
||||
BTA_DmGetDeviceName(btc_gap_bt_get_dev_name_callback, BT_DEVICE_TYPE_BREDR);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -1101,6 +1157,7 @@ void btc_gap_bt_cb_deep_free(btc_msg_t *msg)
|
||||
#if (BTC_DM_PM_INCLUDED == TRUE)
|
||||
case BTC_GAP_BT_MODE_CHG_EVT:
|
||||
#endif /// BTC_DM_PM_INCLUDED == TRUE
|
||||
case BTC_GAP_BT_GET_DEV_NAME_CMPL_EVT:
|
||||
break;
|
||||
default:
|
||||
BTC_TRACE_ERROR("%s: Unhandled event (%d)!\n", __FUNCTION__, msg->act);
|
||||
@@ -1192,6 +1249,10 @@ void btc_gap_bt_cb_handler(btc_msg_t *msg)
|
||||
btc_gap_bt_cb_to_app(ESP_BT_GAP_ACL_PKT_TYPE_CHANGED_EVT, (esp_bt_gap_cb_param_t *)msg->arg);
|
||||
break;
|
||||
}
|
||||
case BTC_GAP_BT_GET_DEV_NAME_CMPL_EVT: {
|
||||
btc_gap_bt_cb_to_app(ESP_BT_GAP_GET_DEV_NAME_CMPL_EVT, (esp_bt_gap_cb_param_t *)msg->arg);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BTC_TRACE_ERROR("%s: Unhandled event (%d)!\n", __FUNCTION__, msg->act);
|
||||
break;
|
||||
|
@@ -173,7 +173,7 @@ typedef union {
|
||||
//BTC_GAP_BLE_ACT_SET_DEV_NAME,
|
||||
struct set_dev_name_args {
|
||||
#define ESP_GAP_DEVICE_NAME_MAX (32)
|
||||
char device_name[ESP_GAP_DEVICE_NAME_MAX + 1];
|
||||
char *device_name;
|
||||
} set_dev_name;
|
||||
#if (BLE_42_FEATURE_SUPPORT == TRUE)
|
||||
//BTC_GAP_BLE_ACT_CFG_ADV_DATA_RAW,
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -35,6 +35,7 @@ typedef enum {
|
||||
BTC_GAP_BT_SET_PAGE_TO_EVT,
|
||||
BTC_GAP_BT_GET_PAGE_TO_EVT,
|
||||
BTC_GAP_BT_SET_ACL_PKT_TYPES_EVT,
|
||||
BTC_GAP_BT_GET_DEV_NAME_CMPL_EVT,
|
||||
}btc_gap_bt_evt_t;
|
||||
|
||||
typedef enum {
|
||||
@@ -58,6 +59,8 @@ typedef enum {
|
||||
BTC_GAP_BT_ACT_SET_PAGE_TIMEOUT,
|
||||
BTC_GAP_BT_ACT_GET_PAGE_TIMEOUT,
|
||||
BTC_GAP_BT_ACT_SET_ACL_PKT_TYPES,
|
||||
BTC_GAP_BT_ACT_SET_DEV_NAME,
|
||||
BTC_GAP_BT_ACT_GET_DEV_NAME,
|
||||
} btc_gap_bt_act_t;
|
||||
|
||||
/* btc_bt_gap_args_t */
|
||||
@@ -165,6 +168,10 @@ typedef union {
|
||||
uint16_t pkt_types;
|
||||
} set_acl_pkt_types;
|
||||
|
||||
// BTC_GAP_BT_ACT_SET_DEV_NAME
|
||||
struct bt_set_dev_name_args {
|
||||
char *device_name;
|
||||
} bt_set_dev_name;
|
||||
} btc_gap_bt_args_t;
|
||||
|
||||
void btc_gap_bt_call_handler(btc_msg_t *msg);
|
||||
|
@@ -2236,16 +2236,16 @@ UINT8 *btm_ble_build_adv_data(tBTM_BLE_AD_MASK *p_data_mask, UINT8 **p_dst,
|
||||
/* device name */
|
||||
#if BTM_MAX_LOC_BD_NAME_LEN > 0
|
||||
if (len > MIN_ADV_LENGTH && data_mask & BTM_BLE_AD_BIT_DEV_NAME) {
|
||||
if (strlen(btm_cb.cfg.bd_name) > (UINT16)(len - MIN_ADV_LENGTH)) {
|
||||
if (strlen(btm_cb.cfg.ble_bd_name) > (UINT16)(len - MIN_ADV_LENGTH)) {
|
||||
cp_len = (UINT16)(len - MIN_ADV_LENGTH);
|
||||
*p++ = cp_len + 1;
|
||||
*p++ = BTM_BLE_AD_TYPE_NAME_SHORT;
|
||||
ARRAY_TO_STREAM(p, btm_cb.cfg.bd_name, cp_len);
|
||||
ARRAY_TO_STREAM(p, btm_cb.cfg.ble_bd_name, cp_len);
|
||||
} else {
|
||||
cp_len = (UINT16)strlen(btm_cb.cfg.bd_name);
|
||||
cp_len = (UINT16)strlen(btm_cb.cfg.ble_bd_name);
|
||||
*p++ = cp_len + 1;
|
||||
*p++ = BTM_BLE_AD_TYPE_NAME_CMPL;
|
||||
ARRAY_TO_STREAM(p, btm_cb.cfg.bd_name, cp_len);
|
||||
ARRAY_TO_STREAM(p, btm_cb.cfg.ble_bd_name, cp_len);
|
||||
}
|
||||
len -= (cp_len + MIN_ADV_LENGTH);
|
||||
data_mask &= ~BTM_BLE_AD_BIT_DEV_NAME;
|
||||
|
@@ -81,7 +81,8 @@ void btm_dev_init (void)
|
||||
|
||||
/* Initialize nonzero defaults */
|
||||
#if (BTM_MAX_LOC_BD_NAME_LEN > 0)
|
||||
memset(btm_cb.cfg.bd_name, 0, sizeof(tBTM_LOC_BD_NAME));
|
||||
memset(btm_cb.cfg.ble_bd_name, 0, sizeof(tBTM_LOC_BD_NAME));
|
||||
memset(btm_cb.cfg.bredr_bd_name, 0, sizeof(tBTM_LOC_BD_NAME));
|
||||
#endif
|
||||
|
||||
btm_cb.devcb.reset_timer.param = (TIMER_PARAM_TYPE)TT_DEV_RESET;
|
||||
@@ -449,11 +450,11 @@ static void btm_decode_ext_features_page (UINT8 page_number, const BD_FEATURES p
|
||||
** Returns status of the operation
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTM_STATUS BTM_SetLocalDeviceName (char *p_name)
|
||||
tBTM_STATUS BTM_SetLocalDeviceName (char *p_name, tBT_DEVICE_TYPE name_type)
|
||||
{
|
||||
UINT8 *p;
|
||||
|
||||
if (!p_name || !p_name[0] || (strlen ((char *)p_name) > BD_NAME_LEN)) {
|
||||
if (!p_name || !p_name[0] || (strlen ((char *)p_name) > BD_NAME_LEN) || (name_type > BT_DEVICE_TYPE_DUMO)) {
|
||||
return (BTM_ILLEGAL_VALUE);
|
||||
}
|
||||
|
||||
@@ -463,16 +464,26 @@ tBTM_STATUS BTM_SetLocalDeviceName (char *p_name)
|
||||
|
||||
#if BTM_MAX_LOC_BD_NAME_LEN > 0
|
||||
/* Save the device name if local storage is enabled */
|
||||
p = (UINT8 *)btm_cb.cfg.bd_name;
|
||||
if (name_type & BT_DEVICE_TYPE_BLE) {
|
||||
p = (UINT8 *)btm_cb.cfg.ble_bd_name;
|
||||
if (p != (UINT8 *)p_name) {
|
||||
BCM_STRNCPY_S(btm_cb.cfg.bd_name, p_name, BTM_MAX_LOC_BD_NAME_LEN);
|
||||
btm_cb.cfg.bd_name[BTM_MAX_LOC_BD_NAME_LEN] = '\0';
|
||||
BCM_STRNCPY_S(btm_cb.cfg.ble_bd_name, p_name, BTM_MAX_LOC_BD_NAME_LEN);
|
||||
btm_cb.cfg.ble_bd_name[BTM_MAX_LOC_BD_NAME_LEN] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
if (name_type & BT_DEVICE_TYPE_BREDR) {
|
||||
p = (UINT8 *)btm_cb.cfg.bredr_bd_name;
|
||||
if (p != (UINT8 *)p_name) {
|
||||
BCM_STRNCPY_S(btm_cb.cfg.bredr_bd_name, p_name, BTM_MAX_LOC_BD_NAME_LEN);
|
||||
btm_cb.cfg.bredr_bd_name[BTM_MAX_LOC_BD_NAME_LEN] = '\0';
|
||||
}
|
||||
}
|
||||
#else
|
||||
p = (UINT8 *)p_name;
|
||||
#endif
|
||||
#if CLASSIC_BT_INCLUDED
|
||||
if (btsnd_hcic_change_name(p)) {
|
||||
if ((name_type & BT_DEVICE_TYPE_BREDR) && btsnd_hcic_change_name(p)) {
|
||||
return (BTM_CMD_STARTED);
|
||||
} else
|
||||
#endif
|
||||
@@ -496,10 +507,33 @@ tBTM_STATUS BTM_SetLocalDeviceName (char *p_name)
|
||||
** is returned and p_name is set to NULL
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTM_STATUS BTM_ReadLocalDeviceName (char **p_name)
|
||||
tBTM_STATUS BTM_ReadLocalDeviceName (char **p_name, tBT_DEVICE_TYPE name_type)
|
||||
{
|
||||
/*
|
||||
// name_type should be BT_DEVICE_TYPE_BLE or BT_DEVICE_TYPE_BREDR
|
||||
if (name_type > BT_DEVICE_TYPE_BREDR) {
|
||||
*p_name = NULL;
|
||||
BTM_TRACE_ERROR("name_type unknown %d", name_type);
|
||||
return (BTM_NO_RESOURCES);
|
||||
}
|
||||
*/
|
||||
|
||||
#if BTM_MAX_LOC_BD_NAME_LEN > 0
|
||||
*p_name = btm_cb.cfg.bd_name;
|
||||
if ((name_type == BT_DEVICE_TYPE_DUMO) &&
|
||||
(BCM_STRNCMP_S(btm_cb.cfg.bredr_bd_name, btm_cb.cfg.ble_bd_name, BTM_MAX_LOC_BD_NAME_LEN) != 0)) {
|
||||
*p_name = NULL;
|
||||
BTM_TRACE_ERROR("Error, BLE and BREDR have different names, return NULL\n");
|
||||
return (BTM_NO_RESOURCES);
|
||||
}
|
||||
|
||||
if (name_type & BT_DEVICE_TYPE_BLE) {
|
||||
*p_name = btm_cb.cfg.ble_bd_name;
|
||||
}
|
||||
|
||||
if (name_type & BT_DEVICE_TYPE_BREDR) {
|
||||
*p_name = btm_cb.cfg.bredr_bd_name;
|
||||
}
|
||||
|
||||
return (BTM_SUCCESS);
|
||||
#else
|
||||
*p_name = NULL;
|
||||
@@ -747,7 +781,7 @@ void btm_vsc_complete (UINT8 *p, UINT16 opcode, UINT16 evt_len,
|
||||
|
||||
/* If there was a callback address for vcs complete, call it */
|
||||
if (p_vsc_cplt_cback) {
|
||||
/* Pass paramters to the callback function */
|
||||
/* Pass parameters to the callback function */
|
||||
vcs_cplt_params.opcode = opcode; /* Number of bytes in return info */
|
||||
vcs_cplt_params.param_len = evt_len; /* Number of bytes in return info */
|
||||
vcs_cplt_params.p_param_buf = p;
|
||||
|
@@ -809,7 +809,7 @@ void btm_sec_clr_temp_auth_service (BD_ADDR bda)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Reset the temporary authorized flag so that next time (untrusted) service is accessed autorization will take place */
|
||||
/* Reset the temporary authorized flag so that next time (untrusted) service is accessed authorization will take place */
|
||||
if (p_dev_rec->last_author_service_id != BTM_SEC_NO_LAST_SERVICE_ID && p_dev_rec->p_cur_service) {
|
||||
BTM_TRACE_DEBUG ("btm_sec_clr_auth_service_by_psm [clearing device: %02x:%02x:%02x:%02x:%02x:%02x]\n",
|
||||
bda[0], bda[1], bda[2], bda[3], bda[4], bda[5]);
|
||||
@@ -1364,7 +1364,7 @@ tBTM_STATUS BTM_SetEncryption (BD_ADDR bd_addr, tBT_TRANSPORT transport, tBTM_SE
|
||||
|| (transport == BT_TRANSPORT_LE && p_dev_rec->ble_hci_handle == BTM_SEC_INVALID_HANDLE)
|
||||
#endif
|
||||
) {
|
||||
/* Connection should be up and runnning */
|
||||
/* Connection should be up and running */
|
||||
BTM_TRACE_WARNING ("Security Manager: BTM_SetEncryption not connected\n");
|
||||
|
||||
if (p_callback) {
|
||||
@@ -1790,15 +1790,15 @@ UINT16 BTM_BuildOobData(UINT8 *p_data, UINT16 max_len, BT_OCTET16 c,
|
||||
}
|
||||
#if BTM_MAX_LOC_BD_NAME_LEN > 0
|
||||
name_size = name_len;
|
||||
if (name_size > strlen(btm_cb.cfg.bd_name)) {
|
||||
if (name_size > strlen(btm_cb.cfg.bredr_bd_name)) {
|
||||
name_type = BTM_EIR_COMPLETE_LOCAL_NAME_TYPE;
|
||||
name_size = (UINT16)strlen(btm_cb.cfg.bd_name);
|
||||
name_size = (UINT16)strlen(btm_cb.cfg.bredr_bd_name);
|
||||
}
|
||||
delta = name_size + 2;
|
||||
if (max_len >= delta) {
|
||||
*p++ = name_size + 1;
|
||||
*p++ = name_type;
|
||||
ARRAY_TO_STREAM (p, btm_cb.cfg.bd_name, name_size);
|
||||
ARRAY_TO_STREAM (p, btm_cb.cfg.bredr_bd_name, name_size);
|
||||
len += delta;
|
||||
max_len -= delta;
|
||||
}
|
||||
@@ -2118,7 +2118,7 @@ tBTM_STATUS btm_sec_l2cap_access_req (BD_ADDR bd_addr, UINT16 psm, UINT16 handle
|
||||
|
||||
/* If there is no application registered with this PSM do not allow connection */
|
||||
if (!p_serv_rec) {
|
||||
BTM_TRACE_WARNING ("%s() PSM: %d no application registerd\n", __func__, psm);
|
||||
BTM_TRACE_WARNING ("%s() PSM: %d no application registered\n", __func__, psm);
|
||||
(*p_callback) (bd_addr, transport, p_ref_data, BTM_MODE_UNSUPPORTED);
|
||||
return (BTM_MODE_UNSUPPORTED);
|
||||
}
|
||||
@@ -2514,7 +2514,7 @@ tBTM_STATUS btm_sec_mx_access_request (BD_ADDR bd_addr, UINT16 psm, BOOLEAN is_o
|
||||
|
||||
if (rc == BTM_SUCCESS) {
|
||||
BTM_TRACE_EVENT("%s: allow to bypass, checking authorization\n", __FUNCTION__);
|
||||
/* the security in BTM_SEC_IN_FLAGS is fullfilled so far, check the requirements in */
|
||||
/* the security in BTM_SEC_IN_FLAGS is fulfilled so far, check the requirements in */
|
||||
/* btm_sec_execute_procedure */
|
||||
if ((is_originator && (p_serv_rec->security_flags & BTM_SEC_OUT_AUTHORIZE)) ||
|
||||
(!is_originator && (p_serv_rec->security_flags & BTM_SEC_IN_AUTHORIZE))) {
|
||||
@@ -3979,7 +3979,7 @@ void btm_sec_auth_complete (UINT16 handle, UINT8 status)
|
||||
/* or BR key is higher security than existing LE keys */
|
||||
(!(p_dev_rec->sec_flags & BTM_SEC_LE_LINK_KEY_AUTHED) &&
|
||||
(p_dev_rec->sec_flags & BTM_SEC_LINK_KEY_AUTHED)))) {
|
||||
BTM_TRACE_DEBUG ("link encrypted afer dedic bonding can use SMP_BR_CHNL\n");
|
||||
BTM_TRACE_DEBUG ("link encrypted after dedic bonding can use SMP_BR_CHNL\n");
|
||||
|
||||
if (btm_sec_is_master(p_dev_rec)) {
|
||||
// Encryption is required to start SM over BR/EDR
|
||||
@@ -4255,7 +4255,7 @@ static void btm_sec_connect_after_reject_timeout (TIMER_LIST_ENT *p_tle)
|
||||
** Function btm_sec_connected
|
||||
**
|
||||
** Description This function is when a connection to the peer device is
|
||||
** establsihed
|
||||
** established
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
@@ -5926,7 +5926,7 @@ static BOOLEAN btm_sec_check_prefetch_pin (tBTM_SEC_DEV_REC *p_dev_rec)
|
||||
**
|
||||
** Function btm_sec_auth_payload_tout
|
||||
**
|
||||
** Description Processes the HCI Autheniticated Payload Timeout Event
|
||||
** Description Processes the HCI Authenticated Payload Timeout Event
|
||||
** indicating that a packet containing a valid MIC on the
|
||||
** connection handle was not received within the programmed
|
||||
** timeout value. (Spec Default is 30 secs, but can be
|
||||
@@ -6294,7 +6294,7 @@ static BOOLEAN btm_sec_is_master(tBTM_SEC_DEV_REC *p_dev_rec)
|
||||
** Description This function is called when legacy authentication is used
|
||||
** and only remote device has completed the authentication
|
||||
**
|
||||
** Returns TRUE if aunthentication command sent successfully
|
||||
** Returns TRUE if authentication command sent successfully
|
||||
**
|
||||
*******************************************************************************/
|
||||
BOOLEAN btm_sec_legacy_authentication_mutual (tBTM_SEC_DEV_REC *p_dev_rec)
|
||||
|
@@ -715,7 +715,8 @@ struct tBTM_SEC_DEV_REC{
|
||||
*/
|
||||
typedef struct {
|
||||
#if BTM_MAX_LOC_BD_NAME_LEN > 0
|
||||
tBTM_LOC_BD_NAME bd_name; /* local Bluetooth device name */
|
||||
tBTM_LOC_BD_NAME bredr_bd_name; /* local BREDR device name */
|
||||
tBTM_LOC_BD_NAME ble_bd_name; /* local BLE device name */
|
||||
#endif
|
||||
BOOLEAN pin_type; /* TRUE if PIN type is fixed */
|
||||
UINT8 pin_code_len; /* Bonding information */
|
||||
|
@@ -65,7 +65,7 @@ static const tGATT_CBACK gap_cback = {
|
||||
**
|
||||
** Function gap_find_clcb_by_bd_addr
|
||||
**
|
||||
** Description The function searches all LCB with macthing bd address
|
||||
** Description The function searches all LCB with matching bd address
|
||||
**
|
||||
** Returns total number of clcb found.
|
||||
**
|
||||
@@ -88,7 +88,7 @@ tGAP_CLCB *gap_find_clcb_by_bd_addr(BD_ADDR bda)
|
||||
**
|
||||
** Function gap_ble_find_clcb_by_conn_id
|
||||
**
|
||||
** Description The function searches all LCB with macthing connection ID
|
||||
** Description The function searches all LCB with matching connection ID
|
||||
**
|
||||
** Returns total number of clcb found.
|
||||
**
|
||||
@@ -163,7 +163,7 @@ void gap_ble_dealloc_clcb(tGAP_CLCB *p_clcb)
|
||||
**
|
||||
** Description The function enqueue a GAP client request
|
||||
**
|
||||
** Returns TRUE is successul; FALSE otherwise
|
||||
** Returns TRUE is successful; FALSE otherwise
|
||||
**
|
||||
*******************************************************************************/
|
||||
BOOLEAN gap_ble_enqueue_request (tGAP_CLCB *p_clcb, UINT16 uuid, tGAP_BLE_CMPL_CBACK *p_cback)
|
||||
@@ -185,7 +185,7 @@ BOOLEAN gap_ble_enqueue_request (tGAP_CLCB *p_clcb, UINT16 uuid, tGAP_BLE_CMPL_C
|
||||
**
|
||||
** Description The function dequeue a GAP client request if any
|
||||
**
|
||||
** Returns TRUE is successul; FALSE otherwise
|
||||
** Returns TRUE is successful; FALSE otherwise
|
||||
**
|
||||
*******************************************************************************/
|
||||
BOOLEAN gap_ble_dequeue_request (tGAP_CLCB *p_clcb, UINT16 *p_uuid, tGAP_BLE_CMPL_CBACK **p_cback)
|
||||
@@ -221,7 +221,7 @@ tGATT_STATUS gap_read_attr_value (UINT16 handle, tGATT_VALUE *p_value, BOOLEAN i
|
||||
|
||||
switch (p_db_attr->uuid) {
|
||||
case GATT_UUID_GAP_DEVICE_NAME:
|
||||
BTM_ReadLocalDeviceName((char **)&p_dev_name);
|
||||
BTM_ReadLocalDeviceName((char **)&p_dev_name, BT_DEVICE_TYPE_BLE);
|
||||
if (strlen ((char *)p_dev_name) > GATT_MAX_ATTR_LEN) {
|
||||
p_value->len = GATT_MAX_ATTR_LEN;
|
||||
} else {
|
||||
@@ -304,7 +304,7 @@ UINT8 gap_proc_write_req( tGATTS_REQ_TYPE type, tGATT_WRITE_REQ *p_data)
|
||||
case GATT_UUID_GAP_DEVICE_NAME: {
|
||||
UINT8 *p_val = p_data->value;
|
||||
p_val[p_data->len] = '\0';
|
||||
BTM_SetLocalDeviceName((char *)p_val);
|
||||
BTM_SetLocalDeviceName((char *)p_val, BT_DEVICE_TYPE_BLE);
|
||||
return GATT_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
@@ -385,7 +385,7 @@ void gap_ble_s_attr_request_cback (UINT16 conn_id, UINT32 trans_id,
|
||||
**
|
||||
** Function btm_ble_att_db_init
|
||||
**
|
||||
** Description GAP ATT database initalization.
|
||||
** Description GAP ATT database initialization.
|
||||
**
|
||||
** Returns void.
|
||||
**
|
||||
@@ -510,7 +510,7 @@ void GAP_BleAttrDBUpdate(UINT16 attr_uuid, tGAP_BLE_ATTR_VALUE *p_value)
|
||||
break;
|
||||
|
||||
case GATT_UUID_GAP_DEVICE_NAME:
|
||||
BTM_SetLocalDeviceName((char *)p_value->p_dev_name);
|
||||
BTM_SetLocalDeviceName((char *)p_value->p_dev_name, BT_DEVICE_TYPE_BLE);
|
||||
break;
|
||||
|
||||
case GATT_UUID_GAP_CENTRAL_ADDR_RESOL:
|
||||
@@ -529,7 +529,7 @@ void GAP_BleAttrDBUpdate(UINT16 attr_uuid, tGAP_BLE_ATTR_VALUE *p_value)
|
||||
**
|
||||
** Function gap_ble_send_cl_read_request
|
||||
**
|
||||
** Description utility function to send a read request for a GAP charactersitic
|
||||
** Description utility function to send a read request for a GAP characteristic
|
||||
**
|
||||
** Returns TRUE if read started, else FALSE if GAP is busy
|
||||
**
|
||||
|
@@ -33,6 +33,8 @@ typedef int32_t INT32;
|
||||
|
||||
#define BCM_STRCPY_S(x1,x2) strcpy((x1),(x2))
|
||||
#define BCM_STRNCPY_S(x1,x2,x3) strncpy((x1),(x2),(x3))
|
||||
#define BCM_STRCMP_S(x1,x2) strcmp((x1),(x2))
|
||||
#define BCM_STRNCMP_S(x1,x2,x3) strncmp((x1),(x2),(x3))
|
||||
|
||||
/* READ WELL !!
|
||||
**
|
||||
|
@@ -470,7 +470,6 @@ typedef enum {
|
||||
#define BTM_COD_SERVICE_CLASS_LO_B 0x00E0
|
||||
#define BTM_COD_SERVICE_CLASS_MASK 0xFFE0
|
||||
|
||||
|
||||
/* BTM service definitions
|
||||
** Used for storing EIR data to bit mask
|
||||
*/
|
||||
@@ -2067,7 +2066,7 @@ BOOLEAN BTM_IsDeviceUp (void);
|
||||
**
|
||||
*******************************************************************************/
|
||||
//extern
|
||||
tBTM_STATUS BTM_SetLocalDeviceName (char *p_name);
|
||||
tBTM_STATUS BTM_SetLocalDeviceName (char *p_name, tBT_DEVICE_TYPE name_type);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -2096,7 +2095,7 @@ tBTM_STATUS BTM_SetDeviceClass (DEV_CLASS dev_class);
|
||||
**
|
||||
*******************************************************************************/
|
||||
//extern
|
||||
tBTM_STATUS BTM_ReadLocalDeviceName (char **p_name);
|
||||
tBTM_STATUS BTM_ReadLocalDeviceName (char **p_name, tBT_DEVICE_TYPE name_type);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
@@ -237,8 +237,7 @@ esp_err_t simple_ble_start(simple_ble_cfg_t *cfg)
|
||||
}
|
||||
#endif
|
||||
|
||||
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
|
||||
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
|
||||
ret = esp_bluedroid_init();
|
||||
if (ret) {
|
||||
ESP_LOGE(TAG, "%s init bluetooth failed %d", __func__, ret);
|
||||
return ret;
|
||||
|
@@ -1,15 +0,0 @@
|
||||
Bluetooth Classic
|
||||
=================
|
||||
|
||||
:link_to_translation:`zh_CN:[中文]`
|
||||
|
||||
Bluedroid
|
||||
---------
|
||||
|
||||
The following Bluedroid API have been removed:
|
||||
|
||||
- :component_file:`bt/host/bluedroid/api/include/api/esp_bt_main.h`
|
||||
|
||||
- Remove ``esp_err_t esp_bluedroid_init(void)``
|
||||
|
||||
- Bluedroid stack initialization API has been replaced by ``esp_err_t esp_bluedroid_init_with_cfg(esp_bluedroid_config_t *cfg)``. Macro ``BT_BLUEDROID_INIT_CONFIG_DEFAULT()`` provides the default configuration for the initialization. The original function can be deleted directly.
|
@@ -6,7 +6,6 @@ Migration from 5.1 to 5.2
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
bluetooth-classic
|
||||
gcc
|
||||
:SOC_IEEE802154_SUPPORTED: ieee802154
|
||||
peripherals
|
||||
|
@@ -1,15 +0,0 @@
|
||||
经典蓝牙
|
||||
=================
|
||||
|
||||
:link_to_translation:`en:[English]`
|
||||
|
||||
Bluedroid
|
||||
---------
|
||||
|
||||
以下 Bluedroid API 已被移除:
|
||||
|
||||
- :component_file:`bt/host/bluedroid/api/include/api/esp_bt_main.h`
|
||||
|
||||
- 移除 ``esp_err_t esp_bluedroid_init(void)``
|
||||
|
||||
- Bluedroid 协议栈初始化 API 已被替换为 ``esp_err_t esp_bluedroid_init_with_cfg(esp_bluedroid_config_t *cfg)``。宏 ``BT_BLUEDROID_INIT_CONFIG_DEFAULT()`` 用于提供默认的初始化参数。原来的初始化函数可以直接删除。
|
@@ -6,7 +6,6 @@
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
bluetooth-classic
|
||||
gcc
|
||||
:SOC_IEEE802154_SUPPORTED: ieee802154
|
||||
peripherals
|
||||
|
@@ -638,8 +638,8 @@ void app_main(void)
|
||||
}
|
||||
|
||||
ESP_LOGI(BLE_ANCS_TAG, "%s init bluetooth", __func__);
|
||||
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
|
||||
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
|
||||
|
||||
ret = esp_bluedroid_init();
|
||||
if (ret) {
|
||||
ESP_LOGE(BLE_ANCS_TAG, "%s init bluetooth failed: %s", __func__, esp_err_to_name(ret));
|
||||
return;
|
||||
|
@@ -658,8 +658,7 @@ void app_main(void)
|
||||
return;
|
||||
}
|
||||
|
||||
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
|
||||
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
|
||||
ret = esp_bluedroid_init();
|
||||
if (ret) {
|
||||
ESP_LOGE(EXAMPLE_TAG, "%s init bluetooth failed: %s", __func__, esp_err_to_name(ret));
|
||||
return;
|
||||
|
@@ -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
|
||||
*/
|
||||
@@ -111,7 +111,7 @@ static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t* par
|
||||
return;
|
||||
} else {
|
||||
// The received adv data is a correct eddystone frame packet.
|
||||
// Here, we get the eddystone infomation in eddystone_res, we can use the data in res to do other things.
|
||||
// Here, we get the eddystone information in eddystone_res, we can use the data in res to do other things.
|
||||
// For example, just print them:
|
||||
ESP_LOGI(DEMO_TAG, "--------Eddystone Found----------");
|
||||
esp_log_buffer_hex("EDDYSTONE_DEMO: Device address:", scan_result->scan_rst.bda, ESP_BD_ADDR_LEN);
|
||||
@@ -154,8 +154,7 @@ void esp_eddystone_appRegister(void)
|
||||
|
||||
void esp_eddystone_init(void)
|
||||
{
|
||||
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
|
||||
esp_bluedroid_init_with_cfg(&bluedroid_cfg);
|
||||
esp_bluedroid_init();
|
||||
esp_bluedroid_enable();
|
||||
esp_eddystone_appRegister();
|
||||
}
|
||||
|
@@ -216,8 +216,7 @@ void app_main(void)
|
||||
return;
|
||||
}
|
||||
|
||||
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
|
||||
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
|
||||
ret = esp_bluedroid_init();
|
||||
if (ret) {
|
||||
ESP_LOGE(HID_DEMO_TAG, "%s init bluedroid failed", __func__);
|
||||
return;
|
||||
|
@@ -156,8 +156,7 @@ void ble_ibeacon_appRegister(void)
|
||||
|
||||
void ble_ibeacon_init(void)
|
||||
{
|
||||
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
|
||||
esp_bluedroid_init_with_cfg(&bluedroid_cfg);
|
||||
esp_bluedroid_init();
|
||||
esp_bluedroid_enable();
|
||||
ble_ibeacon_appRegister();
|
||||
}
|
||||
|
@@ -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
|
||||
*/
|
||||
@@ -228,14 +228,14 @@ static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *par
|
||||
ESP_LOGE(GATTC_TAG, "Scan start failed: %s", esp_err_to_name(err));
|
||||
break;
|
||||
}
|
||||
ESP_LOGI(GATTC_TAG, "Scan start successed");
|
||||
ESP_LOGI(GATTC_TAG, "Scan start successfully");
|
||||
break;
|
||||
case ESP_GAP_BLE_SCAN_STOP_COMPLETE_EVT:
|
||||
if ((err = param->scan_stop_cmpl.status) != ESP_BT_STATUS_SUCCESS) {
|
||||
ESP_LOGE(GATTC_TAG, "Scan stop failed: %s", esp_err_to_name(err));
|
||||
break;
|
||||
}
|
||||
ESP_LOGI(GATTC_TAG, "Scan stop successed");
|
||||
ESP_LOGI(GATTC_TAG, "Scan stop successfully");
|
||||
if (is_connect == false) {
|
||||
ESP_LOGI(GATTC_TAG, "Connect to the remote device.");
|
||||
esp_ble_gattc_open(gl_profile_tab[PROFILE_APP_ID].gattc_if, scan_rst.scan_rst.bda, scan_rst.scan_rst.ble_addr_type, true);
|
||||
@@ -409,11 +409,11 @@ static void gattc_profile_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_
|
||||
|
||||
db = (esp_gattc_db_elem_t *)malloc(count*sizeof(esp_gattc_db_elem_t));
|
||||
if(db == NULL){
|
||||
ESP_LOGE(GATTC_TAG,"%s:malloc db falied",__func__);
|
||||
ESP_LOGE(GATTC_TAG,"%s:malloc db failed",__func__);
|
||||
break;
|
||||
}
|
||||
if(esp_ble_gattc_get_db(spp_gattc_if, spp_conn_id, spp_srv_start_handle, spp_srv_end_handle, db, &count) != ESP_GATT_OK){
|
||||
ESP_LOGE(GATTC_TAG,"%s:get db falied",__func__);
|
||||
ESP_LOGE(GATTC_TAG,"%s:get db failed",__func__);
|
||||
break;
|
||||
}
|
||||
if(count != SPP_IDX_NB){
|
||||
@@ -553,7 +553,7 @@ void uart_task(void *pvParameters)
|
||||
//Waiting for UART event.
|
||||
if (xQueueReceive(spp_uart_queue, (void * )&event, (TickType_t)portMAX_DELAY)) {
|
||||
switch (event.type) {
|
||||
//Event of UART receving data
|
||||
//Event of UART receiving data
|
||||
case UART_DATA:
|
||||
if (event.size && (is_connect == true) && (db != NULL) && ((db+SPP_IDX_SPP_DATA_RECV_VAL)->properties & (ESP_GATT_CHAR_PROP_BIT_WRITE_NR | ESP_GATT_CHAR_PROP_BIT_WRITE))) {
|
||||
uint8_t * temp = NULL;
|
||||
@@ -625,8 +625,8 @@ void app_main(void)
|
||||
}
|
||||
|
||||
ESP_LOGI(GATTC_TAG, "%s init bluetooth", __func__);
|
||||
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
|
||||
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
|
||||
|
||||
ret = esp_bluedroid_init();
|
||||
if (ret) {
|
||||
ESP_LOGE(GATTC_TAG, "%s init bluetooth failed: %s", __func__, esp_err_to_name(ret));
|
||||
return;
|
||||
|
@@ -686,8 +686,8 @@ void app_main(void)
|
||||
}
|
||||
|
||||
ESP_LOGI(GATTS_TABLE_TAG, "%s init bluetooth", __func__);
|
||||
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
|
||||
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
|
||||
|
||||
ret = esp_bluedroid_init();
|
||||
if (ret) {
|
||||
ESP_LOGE(GATTS_TABLE_TAG, "%s init bluetooth failed: %s", __func__, esp_err_to_name(ret));
|
||||
return;
|
||||
|
@@ -568,8 +568,7 @@ void app_main(void)
|
||||
return;
|
||||
}
|
||||
|
||||
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
|
||||
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
|
||||
ret = esp_bluedroid_init();
|
||||
if (ret) {
|
||||
ESP_LOGE(GATTC_TAG, "%s init bluetooth failed, error code = %x", __func__, ret);
|
||||
return;
|
||||
|
@@ -671,8 +671,8 @@ void app_main(void)
|
||||
ESP_LOGE(GATTS_TAG, "%s enable controller failed", __func__);
|
||||
return;
|
||||
}
|
||||
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
|
||||
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
|
||||
|
||||
ret = esp_bluedroid_init();
|
||||
if (ret) {
|
||||
ESP_LOGE(GATTS_TAG, "%s init bluetooth failed", __func__);
|
||||
return;
|
||||
|
@@ -469,8 +469,7 @@ void app_main(void)
|
||||
return;
|
||||
}
|
||||
|
||||
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
|
||||
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
|
||||
ret = esp_bluedroid_init();
|
||||
if (ret) {
|
||||
ESP_LOGE(GATTC_TAG, "%s init bluetooth failed: %s", __func__, esp_err_to_name(ret));
|
||||
return;
|
||||
|
@@ -25,7 +25,7 @@ This example is located in the examples folder of the ESP-IDF under the [bluetoo
|
||||
#include "esp_gatt_common_api.h"
|
||||
```
|
||||
|
||||
These `includes` are required for the FreeRTOS and underlaying system components to run, including the logging functionality and a library to store data in non-volatile flash memory. We are interested in `“bt.h”`, `“esp_bt_main.h”`, `"esp_gap_ble_api.h"` and `“esp_gattc_api.h”`, which expose the BLE APIs required to implement this example.
|
||||
These `includes` are required for the FreeRTOS and underlying system components to run, including the logging functionality and a library to store data in non-volatile flash memory. We are interested in `“bt.h”`, `“esp_bt_main.h”`, `"esp_gap_ble_api.h"` and `“esp_gattc_api.h”`, which expose the BLE APIs required to implement this example.
|
||||
|
||||
* `bt.h`: configures the BT controller and VHCI from the host side.
|
||||
* `esp_bt_main.h`: initializes and enables the Bluedroid stack.
|
||||
@@ -60,8 +60,7 @@ void app_main()
|
||||
return;
|
||||
}
|
||||
|
||||
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
|
||||
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
|
||||
ret = esp_bluedroid_init();
|
||||
if (ret) {
|
||||
ESP_LOGE(GATTC_TAG, "%s init bluetooth failed, error code = %x", __func__, ret);
|
||||
return;
|
||||
@@ -137,8 +136,7 @@ There are four Bluetooth modes supported:
|
||||
After the initialization of the BT controller, the Bluedroid stack, which includes the common definitions and APIs for both BT Classic and BLE, is initialized and enabled by using:
|
||||
|
||||
```c
|
||||
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
|
||||
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
|
||||
ret = esp_bluedroid_init();
|
||||
ret = esp_bluedroid_enable();
|
||||
```
|
||||
The main function ends by registering the GAP and GATT event handlers, as well as the Application Profile and set the maximum supported MTU size.
|
||||
|
@@ -545,8 +545,7 @@ void app_main(void)
|
||||
return;
|
||||
}
|
||||
|
||||
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
|
||||
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
|
||||
ret = esp_bluedroid_init();
|
||||
if (ret) {
|
||||
ESP_LOGE(GATTC_TAG, "%s init bluetooth failed: %s", __func__, esp_err_to_name(ret));
|
||||
return;
|
||||
|
@@ -539,8 +539,8 @@ void app_main(void)
|
||||
}
|
||||
|
||||
ESP_LOGI(GATTS_TABLE_TAG, "%s init bluetooth", __func__);
|
||||
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
|
||||
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
|
||||
|
||||
ret = esp_bluedroid_init();
|
||||
if (ret) {
|
||||
ESP_LOGE(GATTS_TABLE_TAG, "%s init bluetooth failed: %s", __func__, esp_err_to_name(ret));
|
||||
return;
|
||||
|
@@ -701,8 +701,8 @@ void app_main(void)
|
||||
ESP_LOGE(GATTS_TAG, "%s enable controller failed: %s", __func__, esp_err_to_name(ret));
|
||||
return;
|
||||
}
|
||||
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
|
||||
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
|
||||
|
||||
ret = esp_bluedroid_init();
|
||||
if (ret) {
|
||||
ESP_LOGE(GATTS_TAG, "%s init bluetooth failed: %s", __func__, esp_err_to_name(ret));
|
||||
return;
|
||||
|
@@ -62,8 +62,8 @@ The entry point to this example is the app_main() function:
|
||||
ESP_LOGE(GATTS_TAG, "%s enable controller failed", __func__);
|
||||
return;
|
||||
}
|
||||
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
|
||||
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
|
||||
|
||||
ret = esp_bluedroid_init();
|
||||
if (ret) {
|
||||
ESP_LOGE(GATTS_TAG, "%s init bluetooth failed", __func__);
|
||||
return;
|
||||
@@ -132,8 +132,7 @@ There are four Bluetooth modes supported:
|
||||
After the initialization of the BT controller, the Bluedroid stack, which includes the common definitions and APIs for both BT Classic and BLE, is initialized and enabled by using:
|
||||
|
||||
```c
|
||||
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
|
||||
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
|
||||
ret = esp_bluedroid_init();
|
||||
ret = esp_bluedroid_enable();
|
||||
```
|
||||
The Bluetooth stack is up and running at this point in the program flow, however the functionality of the application has not been defined yet. The functionality is defined by reacting to events such as what happens when another device tries to read or write parameters and establish a connection. The two main managers of events are the GAP and GATT event handlers. The application needs to register a callback function for each event handler in order to let the application know which functions are going to handle the GAP and GATT events:
|
||||
|
@@ -543,8 +543,7 @@ void app_main(void)
|
||||
return;
|
||||
}
|
||||
|
||||
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
|
||||
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
|
||||
ret = esp_bluedroid_init();
|
||||
if (ret) {
|
||||
ESP_LOGE(GATTS_TABLE_TAG, "%s init bluetooth failed: %s", __func__, esp_err_to_name(ret));
|
||||
return;
|
||||
|
@@ -101,8 +101,8 @@ void app_main()
|
||||
}
|
||||
|
||||
ESP_LOGI(GATTS_TABLE_TAG, "%s init bluetooth", __func__);
|
||||
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
|
||||
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
|
||||
|
||||
ret = esp_bluedroid_init();
|
||||
if (ret) {
|
||||
ESP_LOGE(GATTS_TABLE_TAG, "%s init bluetooth failed", __func__);
|
||||
return;
|
||||
|
@@ -930,8 +930,7 @@ void app_main(void)
|
||||
return;
|
||||
}
|
||||
|
||||
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
|
||||
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
|
||||
ret = esp_bluedroid_init();
|
||||
if (ret) {
|
||||
ESP_LOGE(GATTC_TAG, "%s init bluetooth failed: %s", __func__, esp_err_to_name(ret));
|
||||
return;
|
||||
|
@@ -582,8 +582,7 @@ void app_main(void)
|
||||
return;
|
||||
}
|
||||
|
||||
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
|
||||
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
|
||||
ret = esp_bluedroid_init();
|
||||
if (ret) {
|
||||
ESP_LOGE(GATTC_TAG, "%s init bluetooth failed: %s", __func__, esp_err_to_name(ret));
|
||||
return;
|
||||
|
@@ -494,8 +494,8 @@ void app_main(void)
|
||||
}
|
||||
|
||||
ESP_LOGI(GATTS_TABLE_TAG, "%s init bluetooth", __func__);
|
||||
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
|
||||
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
|
||||
|
||||
ret = esp_bluedroid_init();
|
||||
if (ret) {
|
||||
ESP_LOGE(GATTS_TABLE_TAG, "%s init bluetooth failed: %s", __func__, esp_err_to_name(ret));
|
||||
return;
|
||||
|
@@ -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
|
||||
*/
|
||||
@@ -148,7 +148,7 @@ static uint8_t raw_scan_rsp_data_coded[] = {
|
||||
};
|
||||
|
||||
static esp_ble_gap_ext_adv_t ext_adv[4] = {
|
||||
// instance, duration, peroid
|
||||
// instance, duration, period
|
||||
[0] = {0, 0, 0},
|
||||
[1] = {1, 0, 0},
|
||||
[2] = {2, 0, 0},
|
||||
@@ -213,8 +213,8 @@ void app_main(void)
|
||||
ESP_LOGE(LOG_TAG, "%s enable controller failed: %s", __func__, esp_err_to_name(ret));
|
||||
return;
|
||||
}
|
||||
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
|
||||
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
|
||||
|
||||
ret = esp_bluedroid_init();
|
||||
if (ret) {
|
||||
ESP_LOGE(LOG_TAG, "%s init bluetooth failed: %s", __func__, esp_err_to_name(ret));
|
||||
return;
|
||||
|
@@ -27,7 +27,7 @@ First, let’s take a look at the include
|
||||
#include "sdkconfig.h"
|
||||
```
|
||||
|
||||
These includes are required for the FreeRTOS and underlaying system components to run, including the logging functionality and a library to store data in non-volatile flash memory. We are interested in `"esp_bt.h"`, `"esp_bt_main.h"`, `"esp_gap_ble_api.h"` and `"esp_gatts_api.h"`, which expose the BLE APIs required to implement this example.
|
||||
These includes are required for the FreeRTOS and underlying system components to run, including the logging functionality and a library to store data in non-volatile flash memory. We are interested in `"esp_bt.h"`, `"esp_bt_main.h"`, `"esp_gap_ble_api.h"` and `"esp_gatts_api.h"`, which expose the BLE APIs required to implement this example.
|
||||
|
||||
* `esp_bt.h`: implements BT controller and VHCI configuration procedures from the host side.
|
||||
* `esp_bt_main.h`: implements initialization and enabling of the Bluedroid stack.
|
||||
@@ -65,8 +65,8 @@ void app_main(void)
|
||||
ESP_LOGE(LOG_TAG, "%s enable controller failed: %s", __func__, esp_err_to_name(ret));
|
||||
return;
|
||||
}
|
||||
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
|
||||
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
|
||||
|
||||
ret = esp_bluedroid_init();
|
||||
if (ret) {
|
||||
ESP_LOGE(LOG_TAG, "%s init bluetooth failed: %s", __func__, esp_err_to_name(ret));
|
||||
return;
|
||||
@@ -145,8 +145,7 @@ There are four Bluetooth modes supported:
|
||||
After the initialization of the BT controller, the Bluedroid stack, which includes the common definitions and APIs for both BT Classic and BLE, is initialized and enabled by using:
|
||||
|
||||
```c
|
||||
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
|
||||
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
|
||||
ret = esp_bluedroid_init();
|
||||
ret = esp_bluedroid_enable();
|
||||
```
|
||||
The Bluetooth stack is up and running at this point in the program flow, however the functionality of the application has not been defined yet. The functionality is defined by reacting to events
|
||||
@@ -174,7 +173,7 @@ typedef struct {
|
||||
uint32_t interval_min; /*!< ext adv minimum interval */
|
||||
uint32_t interval_max; /*!< ext adv maximum interval */
|
||||
esp_ble_adv_channel_t channel_map; /*!< ext adv channel map */
|
||||
esp_ble_addr_type_t own_addr_type; /*!< ext adv own addresss type */
|
||||
esp_ble_addr_type_t own_addr_type; /*!< ext adv own address type */
|
||||
esp_ble_addr_type_t peer_addr_type; /*!< ext adv peer address type */
|
||||
esp_bd_addr_t peer_addr; /*!< ext adv peer address */
|
||||
esp_ble_adv_filter_t filter_policy; /*!< ext adv filter policy */
|
||||
|
@@ -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
|
||||
*/
|
||||
@@ -90,7 +90,7 @@ static uint8_t raw_ext_adv_data_2m[] = {
|
||||
};
|
||||
|
||||
static esp_ble_gap_ext_adv_t ext_adv[1] = {
|
||||
// instance, duration, peroid
|
||||
// instance, duration, period
|
||||
[0] = {EXT_ADV_HANDLE, 0, 0},
|
||||
};
|
||||
|
||||
@@ -164,8 +164,8 @@ void app_main(void)
|
||||
ESP_LOGE(LOG_TAG, "%s enable controller failed: %s", __func__, esp_err_to_name(ret));
|
||||
return;
|
||||
}
|
||||
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
|
||||
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
|
||||
|
||||
ret = esp_bluedroid_init();
|
||||
if (ret) {
|
||||
ESP_LOGE(LOG_TAG, "%s init bluetooth failed: %s", __func__, esp_err_to_name(ret));
|
||||
return;
|
||||
|
@@ -66,8 +66,8 @@ void app_main(void)
|
||||
ESP_LOGE(LOG_TAG, "%s enable controller failed: %s", __func__, esp_err_to_name(ret));
|
||||
return;
|
||||
}
|
||||
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
|
||||
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
|
||||
|
||||
ret = esp_bluedroid_init();
|
||||
if (ret) {
|
||||
ESP_LOGE(LOG_TAG, "%s init bluetooth failed: %s", __func__, esp_err_to_name(ret));
|
||||
return;
|
||||
@@ -152,8 +152,7 @@ There are four Bluetooth modes supported:
|
||||
After the initialization of the BT controller, the Bluedroid stack, which includes the common definitions and APIs for both BT Classic and BLE, is initialized and enabled by using:
|
||||
|
||||
```c
|
||||
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
|
||||
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
|
||||
ret = esp_bluedroid_init();
|
||||
ret = esp_bluedroid_enable();
|
||||
```
|
||||
The Bluetooth stack is up and running at this point in the program flow, however the functionality of the application has not been defined yet. The functionality is defined by reacting to events such as what happens when another device tries to read or write parameters and establish a connection. The two main managers of events are the GAP and GATT event handlers. The application needs to register a callback function for each event handler in order to let the application know which functions are going to handle the GAP and GATT events:
|
||||
@@ -178,7 +177,7 @@ typedef struct {
|
||||
uint32_t interval_min; /*!< ext adv minimum interval */
|
||||
uint32_t interval_max; /*!< ext adv maximum interval */
|
||||
esp_ble_adv_channel_t channel_map; /*!< ext adv channel map */
|
||||
esp_ble_addr_type_t own_addr_type; /*!< ext adv own addresss type */
|
||||
esp_ble_addr_type_t own_addr_type; /*!< ext adv own address type */
|
||||
esp_ble_addr_type_t peer_addr_type; /*!< ext adv peer address type */
|
||||
esp_bd_addr_t peer_addr; /*!< ext adv peer address */
|
||||
esp_ble_adv_filter_t filter_policy; /*!< ext adv filter policy */
|
||||
@@ -247,7 +246,7 @@ static uint8_t periodic_adv_raw_data[] = {
|
||||
|
||||
```c
|
||||
static esp_ble_gap_ext_adv_t ext_adv[1] = {
|
||||
// instance, duration, peroid
|
||||
// instance, duration, period
|
||||
[0] = {EXT_ADV_HANDLE, 0, 0},
|
||||
};
|
||||
```
|
||||
|
@@ -159,8 +159,8 @@ void app_main(void)
|
||||
ESP_LOGE(LOG_TAG, "%s enable controller failed: %s", __func__, esp_err_to_name(ret));
|
||||
return;
|
||||
}
|
||||
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
|
||||
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
|
||||
|
||||
ret = esp_bluedroid_init();
|
||||
if (ret) {
|
||||
ESP_LOGE(LOG_TAG, "%s init bluetooth failed: %s", __func__, esp_err_to_name(ret));
|
||||
return;
|
||||
|
@@ -49,7 +49,7 @@ With this information, the scanner can synchronize with the advertiser and they
|
||||
#include "freertos/semphr.h"
|
||||
```
|
||||
|
||||
These `includes` are required for the FreeRTOS and underlaying system components to run, including the logging functionality and a library to store data in non-volatile flash memory. We are interested in `“bt.h”`, `“esp_bt_main.h”`, `"esp_gap_ble_api.h"` and `“esp_gattc_api.h”`, which expose the BLE APIs required to implement this example.
|
||||
These `includes` are required for the FreeRTOS and underlying system components to run, including the logging functionality and a library to store data in non-volatile flash memory. We are interested in `“bt.h”`, `“esp_bt_main.h”`, `"esp_gap_ble_api.h"` and `“esp_gattc_api.h”`, which expose the BLE APIs required to implement this example.
|
||||
|
||||
* `esp_bt.h`: configures the BT controller and VHCI from the host side.
|
||||
* `esp_bt_main.h`: initializes and enables the Bluedroid stack.
|
||||
@@ -86,8 +86,8 @@ void app_main(void)
|
||||
ESP_LOGE(LOG_TAG, "%s enable controller failed: %s", __func__, esp_err_to_name(ret));
|
||||
return;
|
||||
}
|
||||
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
|
||||
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
|
||||
|
||||
ret = esp_bluedroid_init();
|
||||
if (ret) {
|
||||
ESP_LOGE(LOG_TAG, "%s init bluetooth failed: %s", __func__, esp_err_to_name(ret));
|
||||
return;
|
||||
@@ -152,8 +152,7 @@ There are four Bluetooth modes supported:
|
||||
After the initialization of the BT controller, the Bluedroid stack, which includes the common definitions and APIs for both BT Classic and BLE, is initialized and enabled by using:
|
||||
|
||||
```c
|
||||
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
|
||||
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
|
||||
ret = esp_bluedroid_init();
|
||||
ret = esp_bluedroid_enable();
|
||||
```
|
||||
The main function ends by registering the GAP and GATT event handlers, as well as the Application Profile and set the maximum supported MTU size.
|
||||
@@ -190,7 +189,7 @@ The func will be called in the context of bin semaphore esp_ble_gap_set_ext_scan
|
||||
* @brief ext scan parameters
|
||||
*/
|
||||
typedef struct {
|
||||
esp_ble_addr_type_t own_addr_type; /*!< ext scan own addresss type */
|
||||
esp_ble_addr_type_t own_addr_type; /*!< ext scan own address type */
|
||||
esp_ble_scan_filter_t filter_policy; /*!< ext scan filter policy */
|
||||
esp_ble_scan_duplicate_t scan_duplicate; /*!< ext scan duplicate scan */
|
||||
esp_ble_ext_scan_cfg_mask_t cfg_mask; /*!< ext scan config mask */
|
||||
@@ -213,7 +212,7 @@ can.*/
|
||||
|
||||
uint16_t scan_window; /*!< ext scan window. The duration of the LE scan
|
||||
. LE_Scan_Window shall be less than or equal to LE_Scan_Interval*/
|
||||
//Range: 0x0004 to 0x4000 //Defaul
|
||||
//Range: 0x0004 to 0x4000 //Default
|
||||
t: 0x0010 (10 ms)
|
||||
//Time = N * 0.625 msec
|
||||
//Time Range: 2.5 msec to 10240 msec
|
||||
|
@@ -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
|
||||
*/
|
||||
@@ -257,12 +257,12 @@ static void bt_app_gap_start_up(void)
|
||||
esp_bt_gap_register_callback(bt_app_gap_cb);
|
||||
|
||||
char *dev_name = "ESP_GAP_INQRUIY";
|
||||
esp_bt_dev_set_device_name(dev_name);
|
||||
esp_bt_gap_set_device_name(dev_name);
|
||||
|
||||
/* set discoverable and connectable mode, wait to be connected */
|
||||
esp_bt_gap_set_scan_mode(ESP_BT_CONNECTABLE, ESP_BT_GENERAL_DISCOVERABLE);
|
||||
|
||||
/* inititialize device information and status */
|
||||
/* initialize device information and status */
|
||||
bt_app_gap_init();
|
||||
|
||||
/* start to discover nearby Bluetooth devices */
|
||||
@@ -291,8 +291,7 @@ void app_main(void)
|
||||
};
|
||||
esp_bluedroid_attach_hci_driver(&operations);
|
||||
|
||||
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
|
||||
if ((ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg)) != ESP_OK) {
|
||||
if ((ret = esp_bluedroid_init()) != ESP_OK) {
|
||||
ESP_LOGE(GAP_TAG, "%s initialize bluedroid failed: %s", __func__, esp_err_to_name(ret));
|
||||
return;
|
||||
}
|
||||
|
@@ -117,7 +117,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_gap_set_device_name(LOCAL_DEVICE_NAME);
|
||||
esp_bt_gap_register_callback(bt_app_gap_cb);
|
||||
|
||||
assert(esp_avrc_ct_init() == ESP_OK);
|
||||
@@ -135,6 +135,8 @@ static void bt_av_hdl_stack_evt(uint16_t event, void *p_param)
|
||||
|
||||
/* Get the default value of the delay value */
|
||||
esp_a2d_sink_get_delay_value();
|
||||
/* Get local device name */
|
||||
esp_bt_gap_get_device_name();
|
||||
|
||||
/* set discoverable and connectable mode, wait to be connected */
|
||||
esp_bt_gap_set_scan_mode(ESP_BT_CONNECTABLE, ESP_BT_GENERAL_DISCOVERABLE);
|
||||
|
@@ -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
|
||||
*/
|
||||
@@ -226,7 +226,7 @@ static void bt_app_gap_cb(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *pa
|
||||
s_a2d_state = APP_AV_STATE_CONNECTING;
|
||||
ESP_LOGI(BT_AV_TAG, "Device discovery stopped.");
|
||||
ESP_LOGI(BT_AV_TAG, "a2dp connecting to peer: %s", s_peer_bdname);
|
||||
/* connect source to peer device specificed by Bluetooth Device Address */
|
||||
/* connect source to peer device specified by Bluetooth Device Address */
|
||||
esp_a2d_source_connect(s_peer_bda);
|
||||
} else {
|
||||
/* not discovered, continue to discover */
|
||||
@@ -287,6 +287,13 @@ static void bt_app_gap_cb(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *pa
|
||||
case ESP_BT_GAP_MODE_CHG_EVT:
|
||||
ESP_LOGI(BT_AV_TAG, "ESP_BT_GAP_MODE_CHG_EVT mode: %d", param->mode_chg.mode);
|
||||
break;
|
||||
case ESP_BT_GAP_GET_DEV_NAME_CMPL_EVT:
|
||||
if (param->get_dev_name_cmpl.status == ESP_BT_STATUS_SUCCESS) {
|
||||
ESP_LOGI(BT_AV_TAG, "ESP_BT_GAP_GET_DEV_NAME_CMPL_EVT device name: %s", param->get_dev_name_cmpl.name);
|
||||
} else {
|
||||
ESP_LOGI(BT_AV_TAG, "ESP_BT_GAP_GET_DEV_NAME_CMPL_EVT failed, state: %d", param->get_dev_name_cmpl.status);
|
||||
}
|
||||
break;
|
||||
/* other */
|
||||
default: {
|
||||
ESP_LOGI(BT_AV_TAG, "event: %d", event);
|
||||
@@ -305,7 +312,7 @@ static void bt_av_hdl_stack_evt(uint16_t event, void *p_param)
|
||||
/* when stack up worked, this event comes */
|
||||
case BT_APP_STACK_UP_EVT: {
|
||||
char *dev_name = LOCAL_DEVICE_NAME;
|
||||
esp_bt_dev_set_device_name(dev_name);
|
||||
esp_bt_gap_set_device_name(dev_name);
|
||||
esp_bt_gap_register_callback(bt_app_gap_cb);
|
||||
|
||||
esp_avrc_ct_init();
|
||||
@@ -321,6 +328,7 @@ static void bt_av_hdl_stack_evt(uint16_t event, void *p_param)
|
||||
|
||||
/* Avoid the state error of s_a2d_state caused by the connection initiated by the peer device. */
|
||||
esp_bt_gap_set_scan_mode(ESP_BT_NON_CONNECTABLE, ESP_BT_NON_DISCOVERABLE);
|
||||
esp_bt_gap_get_device_name();
|
||||
|
||||
ESP_LOGI(BT_AV_TAG, "Starting device discovery...");
|
||||
s_a2d_state = APP_AV_STATE_DISCOVERING;
|
||||
@@ -398,7 +406,7 @@ static void bt_app_av_sm_hdlr(uint16_t event, void *param)
|
||||
static void bt_app_av_state_unconnected_hdlr(uint16_t event, void *param)
|
||||
{
|
||||
esp_a2d_cb_param_t *a2d = NULL;
|
||||
/* handle the events of intrest in unconnected state */
|
||||
/* handle the events of interest in unconnected state */
|
||||
switch (event) {
|
||||
case ESP_A2D_CONNECTION_STATE_EVT:
|
||||
case ESP_A2D_AUDIO_STATE_EVT:
|
||||
@@ -430,7 +438,7 @@ static void bt_app_av_state_connecting_hdlr(uint16_t event, void *param)
|
||||
{
|
||||
esp_a2d_cb_param_t *a2d = NULL;
|
||||
|
||||
/* handle the events of intrest in connecting state */
|
||||
/* handle the events of interest in connecting state */
|
||||
switch (event) {
|
||||
case ESP_A2D_CONNECTION_STATE_EVT: {
|
||||
a2d = (esp_a2d_cb_param_t *)(param);
|
||||
@@ -497,7 +505,7 @@ static void bt_app_av_media_proc(uint16_t event, void *param)
|
||||
s_intv_cnt = 0;
|
||||
s_media_state = APP_AV_MEDIA_STATE_STARTED;
|
||||
} else {
|
||||
/* not started succesfully, transfer to idle state */
|
||||
/* not started successfully, transfer to idle state */
|
||||
ESP_LOGI(BT_AV_TAG, "a2dp media start failed.");
|
||||
s_media_state = APP_AV_MEDIA_STATE_IDLE;
|
||||
}
|
||||
@@ -542,7 +550,7 @@ static void bt_app_av_state_connected_hdlr(uint16_t event, void *param)
|
||||
{
|
||||
esp_a2d_cb_param_t *a2d = NULL;
|
||||
|
||||
/* handle the events of intrest in connected state */
|
||||
/* handle the events of interest in connected state */
|
||||
switch (event) {
|
||||
case ESP_A2D_CONNECTION_STATE_EVT: {
|
||||
a2d = (esp_a2d_cb_param_t *)(param);
|
||||
@@ -560,7 +568,7 @@ static void bt_app_av_state_connected_hdlr(uint16_t event, void *param)
|
||||
break;
|
||||
}
|
||||
case ESP_A2D_AUDIO_CFG_EVT:
|
||||
// not suppposed to occur for A2DP source
|
||||
// not supposed to occur for A2DP source
|
||||
break;
|
||||
case ESP_A2D_MEDIA_CTRL_ACK_EVT:
|
||||
case BT_APP_HEART_BEAT_EVT: {
|
||||
@@ -583,7 +591,7 @@ static void bt_app_av_state_disconnecting_hdlr(uint16_t event, void *param)
|
||||
{
|
||||
esp_a2d_cb_param_t *a2d = NULL;
|
||||
|
||||
/* handle the events of intrest in disconnecing state */
|
||||
/* handle the events of interest in disconnecing state */
|
||||
switch (event) {
|
||||
case ESP_A2D_CONNECTION_STATE_EVT: {
|
||||
a2d = (esp_a2d_cb_param_t *)(param);
|
||||
@@ -676,13 +684,13 @@ static void bt_av_hdl_avrc_ct_evt(uint16_t event, void *p_param)
|
||||
}
|
||||
break;
|
||||
}
|
||||
/* when passthrough responsed, this event comes */
|
||||
/* when passthrough responded, this event comes */
|
||||
case ESP_AVRC_CT_PASSTHROUGH_RSP_EVT: {
|
||||
ESP_LOGI(BT_RC_CT_TAG, "AVRC passthrough response: key_code 0x%x, key_state %d, rsp_code %d", rc->psth_rsp.key_code,
|
||||
rc->psth_rsp.key_state, rc->psth_rsp.rsp_code);
|
||||
break;
|
||||
}
|
||||
/* when metadata responsed, this event comes */
|
||||
/* when metadata responded, this event comes */
|
||||
case ESP_AVRC_CT_METADATA_RSP_EVT: {
|
||||
ESP_LOGI(BT_RC_CT_TAG, "AVRC metadata response: attribute id 0x%x, %s", rc->meta_rsp.attr_id, rc->meta_rsp.attr_text);
|
||||
free(rc->meta_rsp.attr_text);
|
||||
@@ -708,7 +716,7 @@ static void bt_av_hdl_avrc_ct_evt(uint16_t event, void *p_param)
|
||||
bt_av_volume_changed();
|
||||
break;
|
||||
}
|
||||
/* when set absolute volume responsed, this event comes */
|
||||
/* when set absolute volume responded, this event comes */
|
||||
case ESP_AVRC_CT_SET_ABSOLUTE_VOLUME_RSP_EVT: {
|
||||
ESP_LOGI(BT_RC_CT_TAG, "Set absolute volume response: volume %d", rc->set_volume_rsp.volume);
|
||||
break;
|
||||
|
@@ -50,7 +50,7 @@ See the [Getting Started Guide](https://docs.espressif.com/projects/esp-idf/en/l
|
||||
#include "esp_gap_bt_api.h"
|
||||
```
|
||||
|
||||
These `includes` are required for the FreeRTOS and underlaying system components to run, including the logging functionality and a library to store data in non-volatile flash memory. We are interested in `bt.h`, `esp_bt_main.h`, `esp_bt_device.h` and `esp_gap_bt_api.h`, which expose the Classic Bluetooth APIs required to implement this example.
|
||||
These `includes` are required for the FreeRTOS and underlying system components to run, including the logging functionality and a library to store data in non-volatile flash memory. We are interested in `bt.h`, `esp_bt_main.h`, `esp_bt_device.h` and `esp_gap_bt_api.h`, which expose the Classic Bluetooth APIs required to implement this example.
|
||||
|
||||
* `bt.h`: configures the Bluetooth controller and VHCI from the host side.
|
||||
* `esp_bt_main.h`: initializes and enables the Bluedroid stack.
|
||||
@@ -152,7 +152,7 @@ The application function then sets the device name and sets it as discoverable a
|
||||
|
||||
```c
|
||||
char *dev_name = "ESP_GAP_INQRUIY";
|
||||
esp_bt_dev_set_device_name(dev_name);
|
||||
esp_bt_gap_set_device_name(dev_name);
|
||||
|
||||
/* set discoverable and connectable mode, wait to be connected */
|
||||
esp_bt_gap_set_scan_mode(ESP_BT_CONNECTABLE, ESP_BT_GENERAL_DISCOVERABLE);
|
||||
@@ -161,7 +161,7 @@ esp_bt_gap_set_scan_mode(ESP_BT_CONNECTABLE, ESP_BT_GENERAL_DISCOVERABLE);
|
||||
The application function then initialises the information and status of application layer and starts to discover nearby Bluetooth devices.
|
||||
|
||||
```c
|
||||
/* inititialize device information and status */
|
||||
/* initialize device information and status */
|
||||
bt_app_gap_init();
|
||||
|
||||
/* start to discover nearby Bluetooth devices */
|
||||
|
@@ -256,12 +256,12 @@ static void bt_app_gap_start_up(void)
|
||||
esp_bt_gap_register_callback(bt_app_gap_cb);
|
||||
|
||||
char *dev_name = "ESP_GAP_INQRUIY";
|
||||
esp_bt_dev_set_device_name(dev_name);
|
||||
esp_bt_gap_set_device_name(dev_name);
|
||||
|
||||
/* set discoverable and connectable mode, wait to be connected */
|
||||
esp_bt_gap_set_scan_mode(ESP_BT_CONNECTABLE, ESP_BT_GENERAL_DISCOVERABLE);
|
||||
|
||||
/* inititialize device information and status */
|
||||
/* initialize device information and status */
|
||||
bt_app_gap_init();
|
||||
|
||||
/* start to discover nearby Bluetooth devices */
|
||||
|
@@ -431,7 +431,7 @@ void app_main(void)
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "setting device name");
|
||||
esp_bt_dev_set_device_name("HID Mouse Example");
|
||||
esp_bt_gap_set_device_name("HID Mouse Example");
|
||||
|
||||
ESP_LOGI(TAG, "setting cod major, peripheral");
|
||||
esp_bt_cod_t cod;
|
||||
|
@@ -366,7 +366,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", 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_gap_set_device_name(EXAMPLE_DEVICE_NAME);
|
||||
esp_bt_gap_set_scan_mode(ESP_BT_CONNECTABLE, ESP_BT_GENERAL_DISCOVERABLE);
|
||||
esp_bt_gap_start_discovery(ESP_BT_INQ_MODE_GENERAL_INQUIRY, 10, 0);
|
||||
}
|
||||
|
@@ -34,9 +34,9 @@ Step `7` in sequence diagram is the setting of SDP and process of service discov
|
||||
- The SDP callback is registered by calling `esp_sdp_register_callback()`.
|
||||
- The `Server` initiates SDP by calling `esp_sdp_init()`, and the asynchronous callback event `ESP_SDP_INIT_EVT` is returned to indicate the initialization completion.
|
||||
- Then the `Server` creates an SDP record by calling `esp_sdp_create_record()`, and an asynchronous callback event `ESP_SDP_CREATE_RECORD_COMP_EVT` is returned to indicate the completion of the record creation.
|
||||
- The `Server` can also set the device name by calling `esp_bt_dev_set_device_name()` and make itself connectable and discoverable by calling `esp_bt_gap_set_scan_mode()`.
|
||||
- The `Server` can also set the device name by calling `esp_bt_gap_set_device_name()` and make itself connectable and discoverable by calling `esp_bt_gap_set_scan_mode()`.
|
||||
- In the client path:
|
||||
- The `Client` also calls functions `esp_sdp_register_callback()`, `esp_sdp_init()`, `esp_sdp_create_record()`, `esp_bt_dev_set_device_name()` and `esp_bt_gap_set_scan_mode()` to register SDP callback, initiate the SDP, create sdp record, set device name and set the scan mode.
|
||||
- The `Client` also calls functions `esp_sdp_register_callback()`, `esp_sdp_init()`, `esp_sdp_create_record()`, `esp_bt_gap_set_device_name()` and `esp_bt_gap_set_scan_mode()` to register SDP callback, initiate the SDP, create sdp record, set device name and set the scan mode.
|
||||
- Additionally, the `Client` calls `esp_bt_gap_start_discovery()` to start `Inquiry`. When the `Inquiry` process is completed, the asynchronous callback event `ESP_BT_GAP_DISC_RES_EVT` will be returned.
|
||||
|
||||
Once the event `ESP_BT_GAP_DISC_RES_EVT` is returned, the `Client` will try to make a L2CAP connection to the `BD Address` of `Server` by calling function `esp_bt_connect()` in step `8`.
|
||||
|
@@ -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", 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_gap_set_device_name(EXAMPLE_DEVICE_NAME);
|
||||
esp_bt_gap_set_scan_mode(ESP_BT_CONNECTABLE, ESP_BT_GENERAL_DISCOVERABLE);
|
||||
}
|
||||
break;
|
||||
|
@@ -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_gap_set_device_name(EXAMPLE_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);
|
||||
|
@@ -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
|
||||
*/
|
||||
@@ -121,7 +121,7 @@ static void esp_spp_cb(esp_spp_cb_event_t event, esp_spp_cb_param_t *param)
|
||||
case ESP_SPP_INIT_EVT:
|
||||
if (param->init.status == ESP_SPP_SUCCESS) {
|
||||
ESP_LOGI(SPP_TAG, "ESP_SPP_INIT_EVT");
|
||||
esp_bt_dev_set_device_name(EXAMPLE_DEVICE_NAME);
|
||||
esp_bt_gap_set_device_name(EXAMPLE_DEVICE_NAME);
|
||||
esp_bt_gap_set_scan_mode(ESP_BT_CONNECTABLE, ESP_BT_GENERAL_DISCOVERABLE);
|
||||
esp_bt_gap_start_discovery(inq_mode, inq_len, inq_num_rsps);
|
||||
} else {
|
||||
@@ -204,7 +204,7 @@ static void esp_spp_cb(esp_spp_cb_event_t event, esp_spp_cb_param_t *param)
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
/* Means the prevous data packet is not sent at all, need to send the whole data packet again. */
|
||||
/* Means the previous data packet is not sent at all, need to send the whole data packet again. */
|
||||
ESP_LOGE(SPP_TAG, "ESP_SPP_WRITE_EVT status:%d", param->write.status);
|
||||
}
|
||||
|
||||
@@ -309,7 +309,7 @@ static void esp_bt_gap_cb(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *pa
|
||||
break;
|
||||
case ESP_BT_GAP_KEY_NOTIF_EVT:
|
||||
ESP_LOGI(SPP_TAG, "ESP_BT_GAP_KEY_NOTIF_EVT passkey:%"PRIu32, param->key_notif.passkey);
|
||||
ESP_LOGW(SPP_TAG, "Waiting responce...");
|
||||
ESP_LOGW(SPP_TAG, "Waiting response...");
|
||||
break;
|
||||
case ESP_BT_GAP_KEY_REQ_EVT:
|
||||
ESP_LOGI(SPP_TAG, "ESP_BT_GAP_KEY_REQ_EVT Please enter passkey!");
|
||||
|
@@ -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_gap_set_device_name(EXAMPLE_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);
|
||||
|
@@ -194,7 +194,7 @@ static void esp_spp_cb(uint16_t e, void *p)
|
||||
case ESP_SPP_VFS_REGISTER_EVT:
|
||||
if (param->vfs_register.status == ESP_SPP_SUCCESS) {
|
||||
ESP_LOGI(SPP_TAG, "ESP_SPP_VFS_REGISTER_EVT");
|
||||
esp_bt_dev_set_device_name(EXAMPLE_DEVICE_NAME);
|
||||
esp_bt_gap_set_device_name(EXAMPLE_DEVICE_NAME);
|
||||
esp_bt_gap_set_scan_mode(ESP_BT_CONNECTABLE, ESP_BT_GENERAL_DISCOVERABLE);
|
||||
esp_bt_gap_start_discovery(inq_mode, inq_len, inq_num_rsps);
|
||||
} else {
|
||||
|
@@ -42,7 +42,7 @@ static void bt_hf_hdl_stack_evt(uint16_t event, void *p_param)
|
||||
{
|
||||
/* set up device name */
|
||||
char *dev_name = "ESP_HFP_AG";
|
||||
esp_bt_dev_set_device_name(dev_name);
|
||||
esp_bt_gap_set_device_name(dev_name);
|
||||
|
||||
esp_hf_ag_register_callback(bt_app_hf_cb);
|
||||
|
||||
@@ -112,7 +112,7 @@ void app_main(void)
|
||||
app_gpio_pcm_io_cfg();
|
||||
#endif
|
||||
|
||||
/* configure externel chip for acoustic echo cancellation */
|
||||
/* configure external chip for acoustic echo cancellation */
|
||||
#if ACOUSTIC_ECHO_CANCELLATION_ENABLE
|
||||
app_gpio_aec_io_cfg();
|
||||
#endif /* ACOUSTIC_ECHO_CANCELLATION_ENABLE */
|
||||
|
@@ -197,7 +197,7 @@ void app_main(void)
|
||||
app_gpio_pcm_io_cfg();
|
||||
#endif
|
||||
|
||||
/* configure externel chip for acoustic echo cancellation */
|
||||
/* configure external chip for acoustic echo cancellation */
|
||||
#if ACOUSTIC_ECHO_CANCELLATION_ENABLE
|
||||
app_gpio_aec_io_cfg();
|
||||
#endif /* ACOUSTIC_ECHO_CANCELLATION_ENABLE */
|
||||
@@ -232,7 +232,7 @@ static void bt_hf_client_hdl_stack_evt(uint16_t event, void *p_param)
|
||||
case BT_APP_EVT_STACK_UP: {
|
||||
/* set up device name */
|
||||
char *dev_name = "ESP_HFP_HF";
|
||||
esp_bt_dev_set_device_name(dev_name);
|
||||
esp_bt_gap_set_device_name(dev_name);
|
||||
|
||||
/* register GAP callback function */
|
||||
esp_bt_gap_register_callback(esp_bt_gap_cb);
|
||||
|
@@ -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
|
||||
*/
|
||||
@@ -45,7 +45,7 @@
|
||||
/* log tag */
|
||||
#define BT_BLE_COEX_TAG "BT_BLE_COEX"
|
||||
/* device name */
|
||||
#define BT_DEVICE_NAME "ESP_COEX_A2DP_DEMO"
|
||||
#define BTDM_DEVICE_NAME "ESP_COEX_BTDM_DEMO"
|
||||
#define BLE_ADV_NAME "ESP_COEX_BLE_DEMO"
|
||||
|
||||
/* BLE defines */
|
||||
@@ -669,7 +669,8 @@ 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(BT_DEVICE_NAME);
|
||||
esp_bt_gap_set_device_name(BTDM_DEVICE_NAME);
|
||||
esp_ble_gap_set_device_name(BTDM_DEVICE_NAME);
|
||||
esp_bt_gap_register_callback(bt_app_gap_cb);
|
||||
|
||||
assert(esp_avrc_ct_init() == ESP_OK);
|
||||
|
@@ -1014,8 +1014,7 @@ void app_main(void)
|
||||
return;
|
||||
}
|
||||
|
||||
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
|
||||
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
|
||||
ret = esp_bluedroid_init();
|
||||
if (ret) {
|
||||
ESP_LOGE(COEX_TAG, "%s init bluetooth failed: %s", __func__, esp_err_to_name(ret));
|
||||
return;
|
||||
|
@@ -32,8 +32,7 @@
|
||||
esp_err_t esp_blufi_host_init(void)
|
||||
{
|
||||
int ret;
|
||||
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
|
||||
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
|
||||
ret = esp_bluedroid_init();
|
||||
if (ret) {
|
||||
BLUFI_ERROR("%s init bluedroid failed: %s\n", __func__, esp_err_to_name(ret));
|
||||
return ESP_FAIL;
|
||||
|
@@ -61,8 +61,8 @@ esp_err_t bluetooth_init(void)
|
||||
ESP_LOGE(TAG, "%s enable controller failed", __func__);
|
||||
return ret;
|
||||
}
|
||||
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
|
||||
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
|
||||
|
||||
ret = esp_bluedroid_init();
|
||||
if (ret) {
|
||||
ESP_LOGE(TAG, "%s init bluetooth failed", __func__);
|
||||
return ret;
|
||||
|
@@ -173,8 +173,7 @@ This demo calls the `bluetooth_init` function to:
|
||||
After the initialization of the BT controller, the Bluedroid stack, which includes the common definitions and APIs for both BT Classic and BLE, is initialized and enabled by using:
|
||||
|
||||
```
|
||||
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
|
||||
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
|
||||
ret = esp_bluedroid_init();
|
||||
ret = esp_bluedroid_enable();
|
||||
```
|
||||
|
||||
|
@@ -901,7 +901,7 @@ void app_main(void)
|
||||
|
||||
#if CONFIG_BT_HID_DEVICE_ENABLED
|
||||
ESP_LOGI(TAG, "setting device name");
|
||||
esp_bt_dev_set_device_name(bt_hid_config.device_name);
|
||||
esp_bt_gap_set_device_name(bt_hid_config.device_name);
|
||||
ESP_LOGI(TAG, "setting cod major, peripheral");
|
||||
esp_bt_cod_t cod;
|
||||
cod.major = ESP_BT_COD_MAJOR_DEV_PERIPHERAL;
|
||||
|
@@ -36,8 +36,8 @@ esp_err_t esp_ble_helper_init(void)
|
||||
ESP_LOGE(TAG, "%s enable controller failed: %s", __func__, esp_err_to_name(err));
|
||||
return err;
|
||||
}
|
||||
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
|
||||
err = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
|
||||
|
||||
err = esp_bluedroid_init();
|
||||
if (err) {
|
||||
ESP_LOGE(TAG, "%s init bluetooth failed: %s", __func__, esp_err_to_name(err));
|
||||
return err;
|
||||
|
Reference in New Issue
Block a user