mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-01 18:50:34 +03:00
fix(ble/bluedroid): Fixed BLE create connection fail because of invalid own address type
This commit is contained in:
committed by
chenjianhua
parent
0b2e6d68df
commit
984c023ef4
@@ -1253,8 +1253,8 @@ int bt_mesh_gattc_conn_create(const bt_mesh_addr_t *addr, uint16_t service_uuid)
|
||||
*/
|
||||
BTA_DmSetBlePrefConnParams(bt_mesh_gattc_info[i].addr.val, 0x18, 0x18, 0x00, 0x64);
|
||||
|
||||
BTA_GATTC_Open(bt_mesh_gattc_if, bt_mesh_gattc_info[i].addr.val,
|
||||
bt_mesh_gattc_info[i].addr.type, true, BTA_GATT_TRANSPORT_LE, FALSE);
|
||||
BTA_GATTC_Enh_Open(bt_mesh_gattc_if, bt_mesh_gattc_info[i].addr.val,
|
||||
bt_mesh_gattc_info[i].addr.type, true, BTA_GATT_TRANSPORT_LE, FALSE, BLE_ADDR_UNKNOWN_TYPE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1163,19 +1163,23 @@ config BT_BLE_RPA_TIMEOUT
|
||||
Default is 900 s (15 minutes). Range is 1 s to 1 hour (3600 s).
|
||||
|
||||
config BT_BLE_50_FEATURES_SUPPORTED
|
||||
bool "Enable BLE 5.0 features"
|
||||
bool "Enable BLE 5.0 features(please disable BLE 4.2 if enable BLE 5.0)"
|
||||
depends on (BT_BLE_ENABLED && ((BT_CONTROLLER_ENABLED && SOC_BLE_50_SUPPORTED) || BT_CONTROLLER_DISABLED))
|
||||
default y
|
||||
help
|
||||
Enabling this option activates BLE 5.0 features.
|
||||
This option is universally supported in chips that support BLE, except for ESP32.
|
||||
BLE 4.2 and BLE 5.0 cannot be used simultaneously.
|
||||
|
||||
|
||||
config BT_BLE_42_FEATURES_SUPPORTED
|
||||
bool "Enable BLE 4.2 features"
|
||||
bool "Enable BLE 4.2 features(please disable BLE 5.0 if enable BLE 4.2)"
|
||||
depends on (BT_BLE_ENABLED && ((BT_CONTROLLER_ENABLED && SOC_BLE_SUPPORTED) || BT_CONTROLLER_DISABLED))
|
||||
default n
|
||||
help
|
||||
This enables BLE 4.2 features.
|
||||
This option is universally supported by all ESP chips with BLE capabilities.
|
||||
BLE 4.2 and BLE 5.0 cannot be used simultaneously.
|
||||
|
||||
config BT_BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER
|
||||
bool "Enable BLE periodic advertising sync transfer feature"
|
||||
|
||||
@@ -67,8 +67,8 @@ esp_err_t esp_ble_gattc_app_unregister(esp_gatt_if_t gattc_if)
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
#if (BLE_42_FEATURE_SUPPORT == TRUE)
|
||||
esp_err_t esp_ble_gattc_open(esp_gatt_if_t gattc_if, esp_bd_addr_t remote_bda, esp_ble_addr_type_t remote_addr_type, bool is_direct)
|
||||
|
||||
esp_err_t esp_ble_gattc_enh_open(esp_gatt_if_t gattc_if, esp_ble_gatt_creat_conn_params_t esp_gatt_create_conn)
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gattc_args_t arg;
|
||||
@@ -79,34 +79,38 @@ esp_err_t esp_ble_gattc_open(esp_gatt_if_t gattc_if, esp_bd_addr_t remote_bda, e
|
||||
msg.pid = BTC_PID_GATTC;
|
||||
msg.act = BTC_GATTC_ACT_OPEN;
|
||||
arg.open.gattc_if = gattc_if;
|
||||
memcpy(arg.open.remote_bda, remote_bda, ESP_BD_ADDR_LEN);
|
||||
arg.open.remote_addr_type = remote_addr_type;
|
||||
arg.open.is_direct = is_direct;
|
||||
arg.open.is_aux = false;
|
||||
memcpy(arg.open.remote_bda, esp_gatt_create_conn.remote_bda, ESP_BD_ADDR_LEN);
|
||||
arg.open.remote_addr_type = esp_gatt_create_conn.remote_addr_type;
|
||||
arg.open.is_direct = esp_gatt_create_conn.is_direct;
|
||||
arg.open.is_aux= esp_gatt_create_conn.is_aux;
|
||||
arg.open.own_addr_type = esp_gatt_create_conn.own_addr_type;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
#if (BLE_42_FEATURE_SUPPORT == TRUE)
|
||||
esp_err_t esp_ble_gattc_open(esp_gatt_if_t gattc_if, esp_bd_addr_t remote_bda, esp_ble_addr_type_t remote_addr_type, bool is_direct)
|
||||
{
|
||||
esp_ble_gatt_creat_conn_params_t esp_gatt_create_conn;
|
||||
memcpy(esp_gatt_create_conn.remote_bda, remote_bda, ESP_BD_ADDR_LEN);
|
||||
esp_gatt_create_conn.remote_addr_type = remote_addr_type;
|
||||
esp_gatt_create_conn.is_direct = is_direct;
|
||||
esp_gatt_create_conn.is_aux = false;
|
||||
esp_gatt_create_conn.own_addr_type = 0xff; //undefined, will use local value
|
||||
return esp_ble_gattc_enh_open(gattc_if, esp_gatt_create_conn);
|
||||
}
|
||||
#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)
|
||||
|
||||
#if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
esp_err_t esp_ble_gattc_aux_open(esp_gatt_if_t gattc_if, esp_bd_addr_t remote_bda, esp_ble_addr_type_t remote_addr_type, bool is_direct)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gattc_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTC;
|
||||
msg.act = BTC_GATTC_ACT_AUX_OPEN;
|
||||
arg.open.gattc_if = gattc_if;
|
||||
memcpy(arg.open.remote_bda, remote_bda, ESP_BD_ADDR_LEN);
|
||||
arg.open.remote_addr_type = remote_addr_type;
|
||||
arg.open.is_direct = is_direct;
|
||||
arg.open.is_aux = true;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
|
||||
esp_ble_gatt_creat_conn_params_t esp_gatt_create_conn;
|
||||
memcpy(esp_gatt_create_conn.remote_bda, remote_bda, ESP_BD_ADDR_LEN);
|
||||
esp_gatt_create_conn.remote_addr_type = remote_addr_type;
|
||||
esp_gatt_create_conn.is_direct = is_direct;
|
||||
esp_gatt_create_conn.is_aux = true;
|
||||
esp_gatt_create_conn.own_addr_type = 0xff; //undefined, will use local value
|
||||
return esp_ble_gattc_enh_open(gattc_if, esp_gatt_create_conn);
|
||||
}
|
||||
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
|
||||
|
||||
@@ -682,6 +682,15 @@ typedef struct {
|
||||
esp_bt_uuid_t uuid; /*!< Included service UUID. */
|
||||
} esp_gattc_incl_svc_elem_t;
|
||||
|
||||
/** @brief Represents a creat connection element. */
|
||||
typedef struct {
|
||||
esp_bd_addr_t remote_bda; /*!< The Bluetooth address of the remote device */
|
||||
esp_ble_addr_type_t remote_addr_type; /*!< Address type of the remote device */
|
||||
bool is_direct; /*!< Direct connection or background auto connection(by now, background auto connection is not supported */
|
||||
bool is_aux; /*!< Set to true for BLE 5.0 or higher to enable auxiliary connections; set to false for BLE 4.2 or lower. */
|
||||
esp_ble_addr_type_t own_addr_type; /*!< Specifies the address type used in the connection request. Set to 0xFF if the address type is unknown. */
|
||||
} esp_ble_gatt_creat_conn_params_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -314,7 +314,20 @@ esp_err_t esp_ble_gattc_app_register(uint16_t app_id);
|
||||
*/
|
||||
esp_err_t esp_ble_gattc_app_unregister(esp_gatt_if_t gattc_if);
|
||||
|
||||
#if (BLE_42_FEATURE_SUPPORT == TRUE)
|
||||
/**
|
||||
* @brief Open a direct connection or add a background auto connection.
|
||||
* Note: Do not enable both BLE_42_FEATURE_SUPPORT and BLE_50_FEATURE_SUPPORT configuration options simultaneously.
|
||||
*
|
||||
* @param[in] gattc_if: GATT client access interface.
|
||||
* @param[in] esp_gatt_create_conn: Structure containing connection parameters.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Operation successful
|
||||
* - others: Operation failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gattc_enh_open(esp_gatt_if_t gattc_if, esp_ble_gatt_creat_conn_params_t esp_gatt_create_conn);
|
||||
|
||||
/**
|
||||
* @brief Open a direct connection or add a background auto connection
|
||||
*
|
||||
@@ -328,12 +341,14 @@ esp_err_t esp_ble_gattc_app_unregister(esp_gatt_if_t gattc_if);
|
||||
* - other: failed
|
||||
*
|
||||
*/
|
||||
#if (BLE_42_FEATURE_SUPPORT == TRUE)
|
||||
esp_err_t esp_ble_gattc_open(esp_gatt_if_t gattc_if, esp_bd_addr_t remote_bda, esp_ble_addr_type_t remote_addr_type, bool is_direct);
|
||||
#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)
|
||||
|
||||
#if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
esp_err_t esp_ble_gattc_aux_open(esp_gatt_if_t gattc_if, esp_bd_addr_t remote_bda, esp_ble_addr_type_t remote_addr_type, bool is_direct);
|
||||
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
|
||||
/**
|
||||
* @brief Close the virtual connection to the GATT server. gattc may have multiple virtual GATT server connections when multiple app_id registered,
|
||||
* this API only close one virtual GATT server connection. if there exist other virtual GATT server connections,
|
||||
|
||||
@@ -6646,7 +6646,8 @@ void btm_dm_start_gatt_discovery (BD_ADDR bd_addr)
|
||||
btm_dm_start_disc_gatt_services(bta_dm_search_cb.conn_id);
|
||||
} else {
|
||||
//TODO need to add addr_type in future
|
||||
BTA_GATTC_Open(bta_dm_search_cb.client_if, bd_addr, BLE_ADDR_UNKNOWN_TYPE, TRUE, BTA_GATT_TRANSPORT_LE, FALSE);
|
||||
BTA_GATTC_Enh_Open(bta_dm_search_cb.client_if, bd_addr, BLE_ADDR_UNKNOWN_TYPE, TRUE, BTA_GATT_TRANSPORT_LE, FALSE, BLE_ADDR_UNKNOWN_TYPE);
|
||||
|
||||
}
|
||||
}
|
||||
#endif /* #if (GATTC_INCLUDED == TRUE) */
|
||||
|
||||
@@ -70,6 +70,7 @@ static void bta_gattc_req_cback (UINT16 conn_id, UINT32 trans_id, tGATTS_REQ_TYP
|
||||
static tBTA_GATTC_FIND_SERVICE_CB bta_gattc_register_service_change_notify(UINT16 conn_id, BD_ADDR remote_bda);
|
||||
|
||||
extern void btc_gattc_congest_callback(tBTA_GATTC *param);
|
||||
extern uint32_t BTM_BleUpdateOwnType(uint8_t *own_bda_type, tBTM_START_ADV_CMPL_CBACK *cb);
|
||||
|
||||
static const tGATT_CBACK bta_gattc_cl_cback = {
|
||||
bta_gattc_conn_cback,
|
||||
@@ -336,6 +337,10 @@ void bta_gattc_process_api_open (tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg)
|
||||
UNUSED(p_cb);
|
||||
|
||||
if (p_clreg != NULL) {
|
||||
if (p_msg->api_conn.own_addr_type <= BLE_ADDR_TYPE_MAX) {
|
||||
// update own address type for creating connection
|
||||
BTM_BleUpdateOwnType(&p_msg->api_conn.own_addr_type, NULL);
|
||||
}
|
||||
if (p_msg->api_conn.is_direct) {
|
||||
if ((p_clcb = bta_gattc_find_alloc_clcb(p_msg->api_conn.client_if,
|
||||
p_msg->api_conn.remote_bda,
|
||||
|
||||
@@ -128,7 +128,7 @@ void BTA_GATTC_AppDeregister(tBTA_GATTC_IF client_if)
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_GATTC_Open
|
||||
** Function BTA_GATTC_Enh_Open
|
||||
**
|
||||
** Description Open a direct connection or add a background auto connection
|
||||
** bd address
|
||||
@@ -142,8 +142,8 @@ void BTA_GATTC_AppDeregister(tBTA_GATTC_IF client_if)
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_GATTC_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, tBTA_ADDR_TYPE remote_addr_type,
|
||||
BOOLEAN is_direct, tBTA_GATT_TRANSPORT transport, BOOLEAN is_aux)
|
||||
void BTA_GATTC_Enh_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, tBTA_ADDR_TYPE remote_addr_type,
|
||||
BOOLEAN is_direct, tBTA_GATT_TRANSPORT transport, BOOLEAN is_aux, tBTA_ADDR_TYPE own_addr_type)
|
||||
{
|
||||
tBTA_GATTC_API_OPEN *p_buf;
|
||||
|
||||
@@ -155,6 +155,7 @@ void BTA_GATTC_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, tBTA_ADDR_TYPE
|
||||
p_buf->transport = transport;
|
||||
p_buf->is_aux = is_aux;
|
||||
p_buf->remote_addr_type = remote_addr_type;
|
||||
p_buf->own_addr_type = own_addr_type;
|
||||
memcpy(p_buf->remote_bda, remote_bda, BD_ADDR_LEN);
|
||||
|
||||
|
||||
@@ -472,7 +473,7 @@ void BTA_GATTC_GetGattDb(UINT16 conn_id, UINT16 start_handle, UINT16 end_handle
|
||||
** Description This function is called to read a characteristics value
|
||||
**
|
||||
** Parameters conn_id - connection ID.
|
||||
** handle - characteritic handle to read.
|
||||
** handle - characteristic handle to read.
|
||||
**
|
||||
** Returns None
|
||||
**
|
||||
@@ -607,7 +608,7 @@ void BTA_GATTC_ReadMultipleVariable(UINT16 conn_id, tBTA_GATTC_MULTI *p_read_mul
|
||||
**
|
||||
** Parameters conn_id - connection ID.
|
||||
** s_handle - start handle.
|
||||
** e_handle - end hanle
|
||||
** e_handle - end handle
|
||||
** uuid - The attribute UUID.
|
||||
**
|
||||
** Returns None
|
||||
@@ -687,7 +688,7 @@ void BTA_GATTC_WriteCharValue ( UINT16 conn_id,
|
||||
** Description This function is called to write descriptor value.
|
||||
**
|
||||
** Parameters conn_id - connection ID
|
||||
** handle - descriptor hadle to write.
|
||||
** handle - descriptor handle to write.
|
||||
** write_type - write type.
|
||||
** p_value - the value to be written.
|
||||
**
|
||||
@@ -738,7 +739,7 @@ void BTA_GATTC_WriteCharDescr (UINT16 conn_id,
|
||||
** Description This function is called to prepare write a characteristic value.
|
||||
**
|
||||
** Parameters conn_id - connection ID.
|
||||
** p_char_id - GATT characteritic ID of the service.
|
||||
** p_char_id - GATT characteristic ID of the service.
|
||||
** offset - offset of the write value.
|
||||
** len: length of the data to be written.
|
||||
** p_value - the value to be written.
|
||||
@@ -781,7 +782,7 @@ void BTA_GATTC_PrepareWrite (UINT16 conn_id, UINT16 handle,
|
||||
** Description This function is called to prepare write a characteristic descriptor value.
|
||||
**
|
||||
** Parameters conn_id - connection ID.
|
||||
** p_char_descr_id - GATT characteritic descriptor ID of the service.
|
||||
** p_char_descr_id - GATT characteristic descriptor ID of the service.
|
||||
** offset - offset of the write value.
|
||||
** len: length of the data to be written.
|
||||
** p_value - the value to be written.
|
||||
|
||||
@@ -110,7 +110,7 @@ typedef enum {
|
||||
#define BTA_GATTC_WRITE_PREPARE GATT_WRITE_PREPARE
|
||||
#define BTA_GATTC_INVALID_HANDLE 0
|
||||
|
||||
/* internal strucutre for GATTC register API */
|
||||
/* internal structure for GATTC register API */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBT_UUID app_uuid;
|
||||
@@ -133,6 +133,7 @@ typedef struct {
|
||||
BOOLEAN is_direct;
|
||||
BOOLEAN is_aux;
|
||||
tBTA_TRANSPORT transport;
|
||||
tBTA_ADDR_TYPE own_addr_type;
|
||||
} tBTA_GATTC_API_OPEN;
|
||||
|
||||
typedef tBTA_GATTC_API_OPEN tBTA_GATTC_API_CANCEL_OPEN;
|
||||
@@ -313,7 +314,7 @@ typedef struct {
|
||||
UINT16 total_char;
|
||||
UINT16 total_attr;
|
||||
UINT8 srvc_hdl_chg; /* service handle change indication pending */
|
||||
UINT16 attr_index; /* cahce NV saving/loading attribute index */
|
||||
UINT16 attr_index; /* cache NV saving/loading attribute index */
|
||||
|
||||
UINT16 mtu;
|
||||
bool update_incl_srvc;
|
||||
|
||||
@@ -117,7 +117,7 @@ static void bta_hh_le_hid_report_dbg(tBTA_HH_DEV_CB *p_cb)
|
||||
if (p_cb->hid_srvc[i].in_use) {
|
||||
p_rpt = &p_cb->hid_srvc[i].report[0];
|
||||
|
||||
APPL_TRACE_DEBUG("\t HID serivce inst: %d", i);
|
||||
APPL_TRACE_DEBUG("\t HID service inst: %d", i);
|
||||
|
||||
for (j = 0; j < BTA_HH_LE_RPT_MAX; j ++, p_rpt++) {
|
||||
rpt_name = "Unknown";
|
||||
@@ -334,14 +334,14 @@ void bta_hh_le_open_conn(tBTA_HH_DEV_CB *p_cb, BD_ADDR remote_bda)
|
||||
bta_hh_cb.le_cb_index[BTA_HH_GET_LE_CB_IDX(p_cb->hid_handle)] = p_cb->index;
|
||||
p_cb->in_use = TRUE;
|
||||
|
||||
BTA_GATTC_Open(bta_hh_cb.gatt_if, remote_bda, BLE_ADDR_UNKNOWN_TYPE, TRUE, BTA_GATT_TRANSPORT_LE, FALSE);
|
||||
BTA_GATTC_Enh_Open(bta_hh_cb.gatt_if, remote_bda, BLE_ADDR_UNKNOWN_TYPE, TRUE, BTA_GATT_TRANSPORT_LE, FALSE, BLE_ADDR_UNKNOWN_TYPE);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hh_le_fill_16bits_gatt_id
|
||||
**
|
||||
** Description Utility function to fill a GATT ID strucure
|
||||
** Description Utility function to fill a GATT ID structure
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hh_le_fill_16bits_gatt_id(UINT8 inst_id, UINT16 uuid, tBTA_GATT_ID *p_output)
|
||||
@@ -355,7 +355,7 @@ void bta_hh_le_fill_16bits_gatt_id(UINT8 inst_id, UINT16 uuid, tBTA_GATT_ID *p_
|
||||
**
|
||||
** Function bta_hh_le_fill_16bits_srvc_id
|
||||
**
|
||||
** Description Utility function to fill a service ID strucure with a 16 bits
|
||||
** Description Utility function to fill a service ID structure with a 16 bits
|
||||
** service UUID.
|
||||
**
|
||||
*******************************************************************************/
|
||||
@@ -372,7 +372,7 @@ void bta_hh_le_fill_16bits_srvc_id(BOOLEAN is_pri, UINT8 inst_id, UINT16 srvc_uu
|
||||
**
|
||||
** Function bta_hh_le_fill_16bits_char_id
|
||||
**
|
||||
** Description Utility function to fill a char ID strucure with a 16 bits
|
||||
** Description Utility function to fill a char ID structure with a 16 bits
|
||||
** char UUID.
|
||||
**
|
||||
*******************************************************************************/
|
||||
@@ -624,7 +624,7 @@ tBTA_HH_STATUS bta_hh_le_read_char_dscrpt(tBTA_HH_DEV_CB *p_cb, UINT16 srvc_uuid
|
||||
**
|
||||
** Function bta_hh_le_read_rpt_ref_descr
|
||||
**
|
||||
** Description read report refernece descriptors in service discovery process
|
||||
** Description read report reference descriptors in service discovery process
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hh_le_read_rpt_ref_descr(tBTA_HH_DEV_CB *p_dev_cb, tBTA_HH_LE_RPT *p_rpt)
|
||||
@@ -841,7 +841,7 @@ void bta_hh_le_register_input_notif(tBTA_HH_DEV_CB *p_dev_cb, UINT8 srvc_inst,
|
||||
}
|
||||
}
|
||||
/*
|
||||
else unknow protocol mode */
|
||||
else unknown protocol mode */
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1486,7 +1486,7 @@ void bta_hh_le_gatt_disc_cmpl(tBTA_HH_DEV_CB *p_cb, tBTA_HH_STATUS status)
|
||||
{
|
||||
APPL_TRACE_DEBUG("bta_hh_le_gatt_disc_cmpl ");
|
||||
|
||||
/* if open sucessful or protocol mode not desired, keep the connection open but inform app */
|
||||
/* if open successful or protocol mode not desired, keep the connection open but inform app */
|
||||
if (status == BTA_HH_OK || status == BTA_HH_ERR_PROTO) {
|
||||
/* assign a special APP ID temp, since device type unknown */
|
||||
p_cb->app_id = BTA_HH_APP_ID_LE;
|
||||
@@ -1504,7 +1504,7 @@ void bta_hh_le_gatt_disc_cmpl(tBTA_HH_DEV_CB *p_cb, tBTA_HH_STATUS status)
|
||||
**
|
||||
** Function bta_hh_le_srvc_expl_srvc
|
||||
**
|
||||
** Description This function discover the next avaible HID service.
|
||||
** Description This function discover the next available HID service.
|
||||
**
|
||||
** Parameters:
|
||||
**
|
||||
@@ -2076,7 +2076,7 @@ void bta_hh_w4_le_read_descr_cmpl(tBTA_HH_DEV_CB *p_dev_cb, tBTA_HH_DATA *p_buf)
|
||||
**
|
||||
** Function bta_hh_w4_le_write_cmpl
|
||||
**
|
||||
** Description Write charactersitic complete event at W4_CONN st.
|
||||
** Description Write characteristic complete event at W4_CONN st.
|
||||
**
|
||||
** Parameters:
|
||||
**
|
||||
@@ -2104,7 +2104,7 @@ void bta_hh_w4_le_write_cmpl(tBTA_HH_DEV_CB *p_dev_cb, tBTA_HH_DATA *p_buf)
|
||||
**
|
||||
** Function bta_hh_le_write_cmpl
|
||||
**
|
||||
** Description Write charactersitic complete event at CONN st.
|
||||
** Description Write characteristic complete event at CONN st.
|
||||
**
|
||||
** Parameters:
|
||||
**
|
||||
@@ -2162,7 +2162,7 @@ void bta_hh_le_write_cmpl(tBTA_HH_DEV_CB *p_dev_cb, tBTA_HH_DATA *p_buf)
|
||||
**
|
||||
** Function bta_hh_le_write_char_descr_cmpl
|
||||
**
|
||||
** Description Write charactersitic descriptor complete event
|
||||
** Description Write characteristic descriptor complete event
|
||||
**
|
||||
** Parameters:
|
||||
**
|
||||
@@ -2216,7 +2216,7 @@ void bta_hh_le_write_char_descr_cmpl(tBTA_HH_DEV_CB *p_dev_cb, tBTA_HH_DATA *p_b
|
||||
**
|
||||
** Function bta_hh_le_input_rpt_notify
|
||||
**
|
||||
** Description process the notificaton event, most likely for input report.
|
||||
** Description process the notification event, most likely for input report.
|
||||
**
|
||||
** Parameters:
|
||||
**
|
||||
@@ -2357,7 +2357,7 @@ void bta_hh_gatt_close(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data)
|
||||
**
|
||||
** Function bta_hh_le_api_disc_act
|
||||
**
|
||||
** Description initaite a Close API to a remote HID device
|
||||
** Description initiate a Close API to a remote HID device
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
@@ -2601,7 +2601,7 @@ static void bta_hh_le_add_dev_bg_conn(tBTA_HH_DEV_CB *p_cb, BOOLEAN check_bond)
|
||||
if (/*p_cb->dscp_info.flag & BTA_HH_LE_NORMAL_CONN &&*/
|
||||
!p_cb->in_bg_conn && to_add) {
|
||||
/* add device into BG connection to accept remote initiated connection */
|
||||
BTA_GATTC_Open(bta_hh_cb.gatt_if, p_cb->addr, BLE_ADDR_UNKNOWN_TYPE, FALSE, BTA_GATT_TRANSPORT_LE, FALSE);
|
||||
BTA_GATTC_Enh_Open(bta_hh_cb.gatt_if, p_cb->addr, BLE_ADDR_UNKNOWN_TYPE, FALSE, BTA_GATT_TRANSPORT_LE, FALSE, BLE_ADDR_UNKNOWN_TYPE);
|
||||
p_cb->in_bg_conn = TRUE;
|
||||
|
||||
BTA_DmBleSetBgConnType(BTA_DM_BLE_CONN_AUTO, NULL);
|
||||
@@ -2682,7 +2682,7 @@ void bta_hh_le_update_scpp(tBTA_HH_DEV_CB *p_dev_cb, tBTA_HH_DATA *p_buf)
|
||||
if (!p_dev_cb->is_le_device ||
|
||||
p_dev_cb->mode != BTA_HH_PROTO_RPT_MODE ||
|
||||
p_dev_cb->scps_supported == FALSE) {
|
||||
APPL_TRACE_ERROR("Can not set ScPP scan paramter as boot host, or remote does not support ScPP ");
|
||||
APPL_TRACE_ERROR("Can not set ScPP scan parameter as boot host, or remote does not support ScPP ");
|
||||
|
||||
cback_data.handle = p_dev_cb->hid_handle;
|
||||
cback_data.status = BTA_HH_ERR;
|
||||
@@ -2908,7 +2908,7 @@ static void bta_hh_le_search_scps_chars(tBTA_HH_DEV_CB *p_cb)
|
||||
**
|
||||
** Function bta_hh_le_register_scpp_notif
|
||||
**
|
||||
** Description register scan parameter refresh notitication complete
|
||||
** Description register scan parameter refresh notification complete
|
||||
**
|
||||
**
|
||||
** Parameters:
|
||||
@@ -2919,7 +2919,7 @@ static void bta_hh_le_register_scpp_notif(tBTA_HH_DEV_CB *p_dev_cb, tBTA_GATT_ST
|
||||
UINT8 sec_flag = 0;
|
||||
tBTA_GATTC_CHAR_ID char_id;
|
||||
|
||||
/* if write scan parameter sucessful */
|
||||
/* if write scan parameter successful */
|
||||
/* if bonded and notification is not enabled, configure the client configuration */
|
||||
if (status == BTA_GATT_OK &&
|
||||
(p_dev_cb->scps_notify & BTA_HH_LE_SCPS_NOTIFY_SPT) != 0 &&
|
||||
@@ -2949,7 +2949,7 @@ static void bta_hh_le_register_scpp_notif(tBTA_HH_DEV_CB *p_dev_cb, tBTA_GATT_ST
|
||||
**
|
||||
** Function bta_hh_le_register_scpp_notif_cmpl
|
||||
**
|
||||
** Description action function to register scan parameter refresh notitication
|
||||
** Description action function to register scan parameter refresh notification
|
||||
**
|
||||
** Parameters:
|
||||
**
|
||||
|
||||
@@ -180,7 +180,7 @@ typedef UINT8 tBTA_GATT_STATUS;
|
||||
#define BTA_GATTC_ADV_VSC_EVT 34 /* ADV VSC event */
|
||||
#define BTA_GATTC_CONNECT_EVT 35 /* GATTC CONNECT event */
|
||||
#define BTA_GATTC_DISCONNECT_EVT 36 /* GATTC DISCONNECT event */
|
||||
#define BTA_GATTC_READ_MULTIPLE_EVT 37 /* GATTC Read mutiple event */
|
||||
#define BTA_GATTC_READ_MULTIPLE_EVT 37 /* GATTC Read multiple event */
|
||||
#define BTA_GATTC_QUEUE_FULL_EVT 38 /* GATTC queue full event */
|
||||
#define BTA_GATTC_ASSOC_EVT 39 /* GATTC association address event */
|
||||
#define BTA_GATTC_GET_ADDR_LIST_EVT 40 /* GATTC get address list in the cache event */
|
||||
@@ -783,9 +783,10 @@ extern void BTA_GATTC_AppRegister(tBT_UUID *p_app_uuid, tBTA_GATTC_CBACK *p_clie
|
||||
*******************************************************************************/
|
||||
extern void BTA_GATTC_AppDeregister (tBTA_GATTC_IF client_if);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_GATTC_Open
|
||||
** Function BTA_GATTC_Enh_Open
|
||||
**
|
||||
** Description Open a direct connection or add a background auto connection
|
||||
** bd address
|
||||
@@ -793,13 +794,14 @@ extern void BTA_GATTC_AppDeregister (tBTA_GATTC_IF client_if);
|
||||
** Parameters client_if: server interface.
|
||||
** remote_bda: remote device BD address.
|
||||
** remote_addr_type: remote device BD address type.
|
||||
** is_direct: direct connection or background auto connection
|
||||
** is_direct: direct connection or background auto connection.
|
||||
** own_addr_type: own address type.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_GATTC_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, tBTA_ADDR_TYPE remote_addr_type,
|
||||
BOOLEAN is_direct, tBTA_GATT_TRANSPORT transport, BOOLEAN is_aux);
|
||||
extern void BTA_GATTC_Enh_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, tBTA_ADDR_TYPE remote_addr_type,
|
||||
BOOLEAN is_direct, tBTA_GATT_TRANSPORT transport, BOOLEAN is_aux, tBTA_ADDR_TYPE own_addr_type);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -937,8 +939,8 @@ extern void BTA_GATTC_GetGattDb(UINT16 conn_id, UINT16 start_handle, UINT16 end_
|
||||
**
|
||||
** Description This function is called to read a characteristics value
|
||||
**
|
||||
** Parameters conn_id - connectino ID.
|
||||
** handle - characteritic handle to read.
|
||||
** Parameters conn_id - connection ID.
|
||||
** handle - characteristic handle to read.
|
||||
**
|
||||
** Returns None
|
||||
**
|
||||
@@ -953,7 +955,7 @@ void BTA_GATTC_ReadCharacteristic(UINT16 conn_id, UINT16 handle, tBTA_GATT_AUTH_
|
||||
**
|
||||
** Parameters conn_id - connection ID.
|
||||
** s_handle - start handle.
|
||||
** e_handle - end hanle
|
||||
** e_handle - end handle
|
||||
** uuid - The attribute UUID.
|
||||
**
|
||||
** Returns None
|
||||
@@ -1072,7 +1074,7 @@ extern tBTA_GATT_STATUS BTA_GATTC_DeregisterForNotifications (tBTA_GATTC_IF
|
||||
** Description This function is called to prepare write a characteristic value.
|
||||
**
|
||||
** Parameters conn_id - connection ID.
|
||||
** handle - GATT characteritic handle.
|
||||
** handle - GATT characteristic handle.
|
||||
** offset - offset of the write value.
|
||||
** len - length of the data to be written.
|
||||
** p_value - the value to be written.
|
||||
@@ -1094,7 +1096,7 @@ extern void BTA_GATTC_PrepareWrite (UINT16 conn_id,
|
||||
** Description This function is called to prepare write a characteristic descriptor value.
|
||||
**
|
||||
** Parameters conn_id - connection ID.
|
||||
** p_char_descr_id - GATT characteritic descriptor ID of the service.
|
||||
** p_char_descr_id - GATT characteristic descriptor ID of the service.
|
||||
** offset - offset of the write value.
|
||||
** len: length of the data to be written.
|
||||
** p_value - the value to be written.
|
||||
@@ -1238,7 +1240,7 @@ extern void BTA_GATTC_ConfigureMTU (UINT16 conn_id);
|
||||
**
|
||||
** Function BTA_GATTS_Init
|
||||
**
|
||||
** Description This function is called to initalize GATTS module
|
||||
** Description This function is called to initialize GATTS module
|
||||
**
|
||||
** Parameters None
|
||||
**
|
||||
|
||||
@@ -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
|
||||
@@ -212,9 +212,10 @@ static void btc_gattc_app_unregister(btc_ble_gattc_args_t *arg)
|
||||
static void btc_gattc_open(btc_ble_gattc_args_t *arg)
|
||||
{
|
||||
tBTA_GATT_TRANSPORT transport = BTA_GATT_TRANSPORT_LE;
|
||||
BTA_GATTC_Open(arg->open.gattc_if, arg->open.remote_bda,
|
||||
|
||||
BTA_GATTC_Enh_Open(arg->open.gattc_if, arg->open.remote_bda,
|
||||
arg->open.remote_addr_type, arg->open.is_direct,
|
||||
transport, arg->open.is_aux);
|
||||
transport, arg->open.is_aux, arg->open.own_addr_type);
|
||||
}
|
||||
|
||||
static void btc_gattc_close(btc_ble_gattc_args_t *arg)
|
||||
|
||||
@@ -57,6 +57,7 @@ typedef union {
|
||||
esp_ble_addr_type_t remote_addr_type;
|
||||
bool is_direct;
|
||||
bool is_aux;
|
||||
esp_ble_addr_type_t own_addr_type;
|
||||
} open;
|
||||
//BTC_GATTC_ACT_CLOSE,
|
||||
struct close_arg {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017-2022 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2017-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -723,10 +723,17 @@ esp_hidh_dev_t *esp_ble_hidh_dev_open(esp_bd_addr_t bda, esp_ble_addr_type_t add
|
||||
dev->ble.address_type = address_type;
|
||||
dev->ble.appearance = ESP_HID_APPEARANCE_GENERIC;
|
||||
|
||||
ret = esp_ble_gattc_open(hid_gattc_if, dev->bda, dev->ble.address_type, true);
|
||||
esp_ble_gatt_creat_conn_params_t esp_ble_gatt_create_conn;
|
||||
memcpy(&esp_ble_gatt_create_conn.remote_bda, dev->bda, ESP_BD_ADDR_LEN);
|
||||
esp_ble_gatt_create_conn.remote_addr_type = dev->ble.address_type;
|
||||
esp_ble_gatt_create_conn.own_addr_type = BLE_ADDR_TYPE_PUBLIC;
|
||||
esp_ble_gatt_create_conn.is_direct = true;
|
||||
esp_ble_gatt_create_conn.is_aux = false;
|
||||
ret = esp_ble_gattc_enh_open(hid_gattc_if,
|
||||
esp_ble_gatt_create_conn);
|
||||
if (ret) {
|
||||
esp_hidh_dev_free_inner(dev);
|
||||
ESP_LOGE(TAG, "esp_ble_gattc_open failed: %d", ret);
|
||||
ESP_LOGE(TAG, "esp_ble_gattc_enh_open failed: %d", ret);
|
||||
return NULL;
|
||||
}
|
||||
WAIT_CB();
|
||||
|
||||
Reference in New Issue
Block a user