From 02cc012db563aa1d95ab1e388d5911c2e6bb5e48 Mon Sep 17 00:00:00 2001 From: chenjianhua Date: Fri, 22 Nov 2024 10:19:15 +0800 Subject: [PATCH] feat(ble/bluedroid): Support setting connection params when creating connection --- components/bt/controller/esp32/bt.c | 7 +- components/bt/controller/esp32c3/bt.c | 6 -- .../core/bluedroid_host/adapter.c | 9 +- .../bt/host/bluedroid/api/esp_gattc_api.c | 88 ++++++++++++++++++- .../bluedroid/api/include/api/esp_bt_defs.h | 19 ++++ .../bluedroid/api/include/api/esp_gatt_defs.h | 14 +-- .../bt/host/bluedroid/bta/dm/bta_dm_act.c | 5 +- .../bluedroid/bta/dm/include/bta_dm_int.h | 2 +- .../host/bluedroid/bta/gatt/bta_gattc_act.c | 27 +++++- .../host/bluedroid/bta/gatt/bta_gattc_api.c | 17 ++-- .../bta/gatt/include/bta_gattc_int.h | 24 ++++- .../bt/host/bluedroid/bta/hh/bta_hh_le.c | 6 +- .../bluedroid/bta/include/bta/bta_gatt_api.h | 19 +++- .../btc/profile/std/gatt/btc_gattc.c | 4 +- .../btc/profile/std/include/btc_gattc.h | 4 + .../bluedroid/stack/btm/include/btm_ble_int.h | 5 +- .../bt/host/bluedroid/stack/hcic/hciblecmds.c | 16 ++-- .../bt/host/bluedroid/stack/l2cap/l2c_ble.c | 32 ++++--- components/bt/include/esp32/include/esp_bt.h | 6 +- .../bt/include/esp32c3/include/esp_bt.h | 2 - components/esp_hid/src/ble_hidh.c | 3 +- .../ble/ble_ancs/main/ble_ancs_demo.c | 3 +- .../ble/ble_spp_client/main/spp_client_demo.c | 3 +- .../main/example_ble_client_throughput.c | 22 +++-- .../ble/gatt_client/main/gattc_demo.c | 3 +- .../Gatt_Client_Example_Walkthrough.md | 15 ++-- .../main/example_ble_sec_gattc_demo.c | 15 ++-- .../main/gattc_multi_connect.c | 9 +- ...nt_Multi_Connection_Example_Walkthrough.md | 45 +++++----- .../main/ble50_sec_gattc_demo.c | 18 ++-- .../main/example_ble_client_throughput.c | 25 +++--- .../gattc_gatts_coex/main/gattc_gatts_coex.c | 3 +- 32 files changed, 348 insertions(+), 128 deletions(-) diff --git a/components/bt/controller/esp32/bt.c b/components/bt/controller/esp32/bt.c index db91dc728d..6fe2154eff 100644 --- a/components/bt/controller/esp32/bt.c +++ b/components/bt/controller/esp32/bt.c @@ -1931,7 +1931,7 @@ esp_err_t esp_bredr_sco_datapath_set(esp_sco_data_path_t data_path) return ESP_OK; } -esp_err_t esp_ble_scan_dupilcate_list_flush(void) +esp_err_t esp_ble_scan_duplicate_list_flush(void) { if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_ENABLED) { return ESP_ERR_INVALID_STATE; @@ -1940,6 +1940,11 @@ esp_err_t esp_ble_scan_dupilcate_list_flush(void) return ESP_OK; } +esp_err_t esp_ble_scan_dupilcate_list_flush(void) +{ + return esp_ble_scan_duplicate_list_flush(); +} + /** * This function re-write controller's function, * As coredump can not show parameters in function which is in a .a file. diff --git a/components/bt/controller/esp32c3/bt.c b/components/bt/controller/esp32c3/bt.c index c943fb92fa..2ab73319a3 100644 --- a/components/bt/controller/esp32c3/bt.c +++ b/components/bt/controller/esp32c3/bt.c @@ -260,7 +260,6 @@ extern int API_vhci_host_register_callback(const vhci_host_callback_t *callback) extern int ble_txpwr_set(int power_type, uint16_t handle, int power_level); extern int ble_txpwr_get(int power_type, uint16_t handle); -extern uint16_t l2c_ble_link_get_tx_buf_num(void); extern void coex_pti_v2(void); extern bool btdm_deep_sleep_mem_init(void); @@ -1877,11 +1876,6 @@ int IRAM_ATTR esp_bt_h4tl_eif_io_event_notify(int event) return btdm_hci_tl_io_event_post(event); } -uint16_t esp_bt_get_tx_buf_num(void) -{ - return l2c_ble_link_get_tx_buf_num(); -} - static void coex_wifi_sleep_set_hook(bool sleep) { diff --git a/components/bt/esp_ble_mesh/core/bluedroid_host/adapter.c b/components/bt/esp_ble_mesh/core/bluedroid_host/adapter.c index 2feaaeb2da..2480494181 100644 --- a/components/bt/esp_ble_mesh/core/bluedroid_host/adapter.c +++ b/components/bt/esp_ble_mesh/core/bluedroid_host/adapter.c @@ -1198,6 +1198,7 @@ uint16_t bt_mesh_gattc_get_service_uuid(struct bt_mesh_conn *conn) int bt_mesh_gattc_conn_create(const bt_mesh_addr_t *addr, uint16_t service_uuid) { + tBTA_BLE_CONN_PARAMS conn_1m_param = {0}; uint8_t zero[6] = {0}; int i; @@ -1251,10 +1252,14 @@ int bt_mesh_gattc_conn_create(const bt_mesh_addr_t *addr, uint16_t service_uuid) * Slave_latency: 0x0 * Supervision_timeout: 1s */ - BTA_DmSetBlePrefConnParams(bt_mesh_gattc_info[i].addr.val, 0x18, 0x18, 0x00, 0x64); + conn_1m_param.interval_min = 0x18; + conn_1m_param.interval_max = 0x18; + conn_1m_param.latency = 0; + conn_1m_param.supervision_timeout = 0x64; 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); + bt_mesh_gattc_info[i].addr.type, true, BTA_GATT_TRANSPORT_LE, FALSE, BLE_ADDR_UNKNOWN_TYPE, + BTA_BLE_PHY_1M_MASK, &conn_1m_param, NULL, NULL); return 0; } diff --git a/components/bt/host/bluedroid/api/esp_gattc_api.c b/components/bt/host/bluedroid/api/esp_gattc_api.c index 4c41de97de..83481a85c6 100644 --- a/components/bt/host/bluedroid/api/esp_gattc_api.c +++ b/components/bt/host/bluedroid/api/esp_gattc_api.c @@ -72,9 +72,14 @@ esp_err_t esp_ble_gattc_enh_open(esp_gatt_if_t gattc_if, esp_ble_gatt_creat_conn { btc_msg_t msg = {0}; btc_ble_gattc_args_t arg; + const esp_ble_conn_params_t *conn_params; ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED); + if (!creat_conn_params) { + return ESP_ERR_INVALID_ARG; + } + msg.sig = BTC_SIG_API_CALL; msg.pid = BTC_PID_GATTC; msg.act = BTC_GATTC_ACT_OPEN; @@ -84,6 +89,83 @@ esp_err_t esp_ble_gattc_enh_open(esp_gatt_if_t gattc_if, esp_ble_gatt_creat_conn arg.open.is_direct = creat_conn_params->is_direct; arg.open.is_aux= creat_conn_params->is_aux; arg.open.own_addr_type = creat_conn_params->own_addr_type; + arg.open.phy_mask = creat_conn_params->phy_mask; + + // If not aux open, shouldn't set 2M and coded PHY connection params + if (!creat_conn_params->is_aux && + ((creat_conn_params->phy_mask & ESP_BLE_PHY_2M_PREF_MASK) || + (creat_conn_params->phy_mask & ESP_BLE_PHY_CODED_PREF_MASK))) { + return ESP_ERR_INVALID_ARG; + } + + if (creat_conn_params->phy_mask & ESP_BLE_PHY_1M_PREF_MASK) { + if (!creat_conn_params->phy_1m_conn_params) { + return ESP_ERR_INVALID_ARG; + } + + conn_params = creat_conn_params->phy_1m_conn_params; + if (ESP_BLE_IS_VALID_PARAM(conn_params->interval_min, ESP_BLE_CONN_INT_MIN, ESP_BLE_CONN_INT_MAX) && + ESP_BLE_IS_VALID_PARAM(conn_params->interval_max, ESP_BLE_CONN_INT_MIN, ESP_BLE_CONN_INT_MAX) && + ESP_BLE_IS_VALID_PARAM(conn_params->supervision_timeout, ESP_BLE_CONN_SUP_TOUT_MIN, ESP_BLE_CONN_SUP_TOUT_MAX) && + (conn_params->latency <= ESP_BLE_CONN_LATENCY_MAX) && + ((conn_params->supervision_timeout * 10) >= ((1 + conn_params->latency) * ((conn_params->interval_max * 5) >> 1))) && + (conn_params->interval_min <= conn_params->interval_max)) { + memcpy(&arg.open.phy_1m_conn_params, conn_params, sizeof(esp_ble_conn_params_t)); + } else { + LOG_ERROR("%s, invalid 1M PHY connection params: min_int = %d, max_int = %d, latency = %d, timeout = %d", __func__, + conn_params->interval_min, + conn_params->interval_max, + conn_params->latency, + conn_params->supervision_timeout); + return ESP_ERR_INVALID_ARG; + } + } + + if (creat_conn_params->phy_mask & ESP_BLE_PHY_2M_PREF_MASK) { + if (!creat_conn_params->phy_2m_conn_params) { + return ESP_ERR_INVALID_ARG; + } + + conn_params = creat_conn_params->phy_2m_conn_params; + if (ESP_BLE_IS_VALID_PARAM(conn_params->interval_min, ESP_BLE_CONN_INT_MIN, ESP_BLE_CONN_INT_MAX) && + ESP_BLE_IS_VALID_PARAM(conn_params->interval_max, ESP_BLE_CONN_INT_MIN, ESP_BLE_CONN_INT_MAX) && + ESP_BLE_IS_VALID_PARAM(conn_params->supervision_timeout, ESP_BLE_CONN_SUP_TOUT_MIN, ESP_BLE_CONN_SUP_TOUT_MAX) && + (conn_params->latency <= ESP_BLE_CONN_LATENCY_MAX) && + ((conn_params->supervision_timeout * 10) >= ((1 + conn_params->latency) * ((conn_params->interval_max * 5) >> 1))) && + (conn_params->interval_min <= conn_params->interval_max)) { + memcpy(&arg.open.phy_2m_conn_params, conn_params, sizeof(esp_ble_conn_params_t)); + } else { + LOG_ERROR("%s, invalid 2M PHY connection params: min_int = %d, max_int = %d, latency = %d, timeout = %d", __func__, + conn_params->interval_min, + conn_params->interval_max, + conn_params->latency, + conn_params->supervision_timeout); + return ESP_ERR_INVALID_ARG; + } + } + + if (creat_conn_params->phy_mask & ESP_BLE_PHY_CODED_PREF_MASK) { + if (!creat_conn_params->phy_coded_conn_params) { + return ESP_ERR_INVALID_ARG; + } + + conn_params = creat_conn_params->phy_coded_conn_params; + if (ESP_BLE_IS_VALID_PARAM(conn_params->interval_min, ESP_BLE_CONN_INT_MIN, ESP_BLE_CONN_INT_MAX) && + ESP_BLE_IS_VALID_PARAM(conn_params->interval_max, ESP_BLE_CONN_INT_MIN, ESP_BLE_CONN_INT_MAX) && + ESP_BLE_IS_VALID_PARAM(conn_params->supervision_timeout, ESP_BLE_CONN_SUP_TOUT_MIN, ESP_BLE_CONN_SUP_TOUT_MAX) && + (conn_params->latency <= ESP_BLE_CONN_LATENCY_MAX) && + ((conn_params->supervision_timeout * 10) >= ((1 + conn_params->latency) * ((conn_params->interval_max * 5) >> 1))) && + (conn_params->interval_min <= conn_params->interval_max)) { + memcpy(&arg.open.phy_coded_conn_params, conn_params, sizeof(esp_ble_conn_params_t)); + } else { + LOG_ERROR("%s, invalid Coded PHY connection params: min_int = %d, max_int = %d, latency = %d, timeout = %d", __func__, + conn_params->interval_min, + conn_params->interval_max, + conn_params->latency, + conn_params->supervision_timeout); + return ESP_ERR_INVALID_ARG; + } + } return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); } @@ -91,12 +173,13 @@ esp_err_t esp_ble_gattc_enh_open(esp_gatt_if_t gattc_if, esp_ble_gatt_creat_conn #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 creat_conn_params; + esp_ble_gatt_creat_conn_params_t creat_conn_params = {0}; memcpy(creat_conn_params.remote_bda, remote_bda, ESP_BD_ADDR_LEN); creat_conn_params.remote_addr_type = remote_addr_type; creat_conn_params.is_direct = is_direct; creat_conn_params.is_aux = false; creat_conn_params.own_addr_type = 0xff; //undefined, will use local value + creat_conn_params.phy_mask = 0x0; return esp_ble_gattc_enh_open(gattc_if, &creat_conn_params); } #endif // #if (BLE_42_FEATURE_SUPPORT == TRUE) @@ -104,12 +187,13 @@ esp_err_t esp_ble_gattc_open(esp_gatt_if_t gattc_if, esp_bd_addr_t remote_bda, e #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) { - esp_ble_gatt_creat_conn_params_t creat_conn_params; + esp_ble_gatt_creat_conn_params_t creat_conn_params = {0}; memcpy(creat_conn_params.remote_bda, remote_bda, ESP_BD_ADDR_LEN); creat_conn_params.remote_addr_type = remote_addr_type; creat_conn_params.is_direct = is_direct; creat_conn_params.is_aux = true; creat_conn_params.own_addr_type = 0xff; //undefined, will use local value + creat_conn_params.phy_mask = 0x0; return esp_ble_gattc_enh_open(gattc_if, &creat_conn_params); } #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) diff --git a/components/bt/host/bluedroid/api/include/api/esp_bt_defs.h b/components/bt/host/bluedroid/api/include/api/esp_bt_defs.h index f378ec0178..bd2f6dc990 100644 --- a/components/bt/host/bluedroid/api/include/api/esp_bt_defs.h +++ b/components/bt/host/bluedroid/api/include/api/esp_bt_defs.h @@ -145,6 +145,25 @@ typedef uint8_t esp_link_key[ESP_BT_OCTET16_LEN]; /* Link Key */ #define ESP_BLE_CONN_SUP_TOUT_MIN 0x000A /*!< relate to BTM_BLE_CONN_SUP_TOUT_MIN in stack/btm_ble_api.h */ #define ESP_BLE_CONN_SUP_TOUT_MAX 0x0C80 /*!< relate to ESP_BLE_CONN_SUP_TOUT_MAX in stack/btm_ble_api.h */ +#define ESP_BLE_PHY_1M_PREF_MASK (1 << 0) /*!< The Host prefers use the LE1M transmitter or receiver PHY */ +#define ESP_BLE_PHY_2M_PREF_MASK (1 << 1) /*!< The Host prefers use the LE2M transmitter or receiver PHY */ +#define ESP_BLE_PHY_CODED_PREF_MASK (1 << 2) /*!< The Host prefers use the LE CODED transmitter or receiver PHY */ +typedef uint8_t esp_ble_phy_mask_t; + +/** +* @brief create connection parameters +*/ +typedef struct { + uint16_t scan_interval; /*!< Initial scan interval, in units of 0.625ms, the range is 0x0004(2.5ms) to 0xFFFF(10.24s). */ + uint16_t scan_window; /*!< Initial scan window, in units of 0.625ms, the range is 0x0004(2.5ms) to 0xFFFF(10.24s). */ + uint16_t interval_min; /*!< Minimum connection interval, in units of 1.25ms, the range is 0x0006(7.5ms) to 0x0C80(4s). */ + uint16_t interval_max; /*!< Maximum connection interval, in units of 1.25ms, the range is 0x0006(7.5ms) to 0x0C80(4s). */ + uint16_t latency; /*!< Connection latency, the range is 0x0000(0) to 0x01F3(499). */ + uint16_t supervision_timeout; /*!< Connection supervision timeout, in units of 10ms, the range is from 0x000A(100ms) to 0x0C80(32s). */ + uint16_t min_ce_len; /*!< Minimum connection event length, in units of 0.625ms, setting to 0 for no preferred parameters. */ + uint16_t max_ce_len; /*!< Maximum connection event length, in units of 0.625ms, setting to 0 for no preferred parameters. */ +} esp_ble_conn_params_t; + /// Check the param is valid or not #define ESP_BLE_IS_VALID_PARAM(x, min, max) (((x) >= (min) && (x) <= (max)) ) diff --git a/components/bt/host/bluedroid/api/include/api/esp_gatt_defs.h b/components/bt/host/bluedroid/api/include/api/esp_gatt_defs.h index 1dfbf861a5..f6beb5eaae 100644 --- a/components/bt/host/bluedroid/api/include/api/esp_gatt_defs.h +++ b/components/bt/host/bluedroid/api/include/api/esp_gatt_defs.h @@ -684,11 +684,15 @@ typedef struct { /** @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_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_phy_mask_t phy_mask; /*!< Indicates which PHY connection parameters will be used. When is_aux is false, only the connection params for 1M PHY can be specified */ + const esp_ble_conn_params_t *phy_1m_conn_params; /*!< Connection parameters for the LE 1M PHY */ + const esp_ble_conn_params_t *phy_2m_conn_params; /*!< Connection parameters for the LE 2M PHY */ + const esp_ble_conn_params_t *phy_coded_conn_params; /*!< Connection parameters for the LE Coded PHY */ } esp_ble_gatt_creat_conn_params_t; #ifdef __cplusplus diff --git a/components/bt/host/bluedroid/bta/dm/bta_dm_act.c b/components/bt/host/bluedroid/bta/dm/bta_dm_act.c index 1fe4fa70c4..3940dc308b 100644 --- a/components/bt/host/bluedroid/bta/dm/bta_dm_act.c +++ b/components/bt/host/bluedroid/bta/dm/bta_dm_act.c @@ -6049,7 +6049,7 @@ void bta_dm_ble_gap_set_prefer_ext_conn_params(tBTA_DM_MSG *p_data) sizeof(tBTA_DM_BLE_CONN_PARAMS)); } - if (conn_params.phy_mask & BTAS_PHY_CODED_MASK) { + if (conn_params.phy_mask & BTA_PHY_CODED_MASK) { memcpy(&conn_params.phy_coded_conn_params, &p_data->ble_set_per_ext_conn_params.phy_coded_conn_params, sizeof(tBTA_DM_BLE_CONN_PARAMS)); } @@ -6673,7 +6673,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_Enh_Open(bta_dm_search_cb.client_if, bd_addr, BLE_ADDR_UNKNOWN_TYPE, TRUE, BTA_GATT_TRANSPORT_LE, FALSE, BLE_ADDR_UNKNOWN_TYPE); + 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, 0, NULL, NULL, NULL); } } diff --git a/components/bt/host/bluedroid/bta/dm/include/bta_dm_int.h b/components/bt/host/bluedroid/bta/dm/include/bta_dm_int.h index 29af35c6dc..627ab78ff5 100644 --- a/components/bt/host/bluedroid/bta/dm/include/bta_dm_int.h +++ b/components/bt/host/bluedroid/bta/dm/include/bta_dm_int.h @@ -1040,7 +1040,7 @@ typedef struct { #define BTA_PHY_1M_MASK (1 << 0) #define BTA_PHY_2M_MASK (1 << 1) -#define BTAS_PHY_CODED_MASK (1 << 2) +#define BTA_PHY_CODED_MASK (1 << 2) typedef struct { BT_HDR hdr; BD_ADDR bd_addr; diff --git a/components/bt/host/bluedroid/bta/gatt/bta_gattc_act.c b/components/bt/host/bluedroid/bta/gatt/bta_gattc_act.c index bff2121243..539d54c364 100644 --- a/components/bt/host/bluedroid/bta/gatt/bta_gattc_act.c +++ b/components/bt/host/bluedroid/bta/gatt/bta_gattc_act.c @@ -36,6 +36,7 @@ #include "osi/allocator.h" #include "osi/mutex.h" #include "bta_hh_int.h" +#include "btm_int.h" #if (defined BTA_HH_LE_INCLUDED && BTA_HH_LE_INCLUDED == TRUE) #include "bta_hh_int.h" @@ -508,6 +509,7 @@ void bta_gattc_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data) tBTA_GATTC_DATA gattc_data; BOOLEAN found_app = FALSE; tGATT_TCB *p_tcb; + tBTM_SEC_DEV_REC *p_dev_rec = NULL; if (!p_clcb || !p_data) { return; @@ -517,6 +519,25 @@ void bta_gattc_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data) if(p_tcb) { found_app = gatt_find_specific_app_in_hold_link(p_tcb, p_clcb->p_rcb->client_if); } + + if (p_data->api_conn.phy_mask) { + p_dev_rec = btm_find_or_alloc_dev(p_data->api_conn.remote_bda); + if (p_dev_rec) { + if (p_data->api_conn.is_aux) { +#if (BLE_50_FEATURE_SUPPORT == TRUE) + p_dev_rec->ext_conn_params.phy_mask = p_data->api_conn.phy_mask; + memcpy(&p_dev_rec->ext_conn_params.phy_1m_conn_params, &p_data->api_conn.phy_1m_conn_params, sizeof(tBTA_BLE_CONN_PARAMS)); + memcpy(&p_dev_rec->ext_conn_params.phy_2m_conn_params, &p_data->api_conn.phy_2m_conn_params, sizeof(tBTA_BLE_CONN_PARAMS)); + memcpy(&p_dev_rec->ext_conn_params.phy_coded_conn_params, &p_data->api_conn.phy_coded_conn_params, sizeof(tBTA_BLE_CONN_PARAMS)); +#endif + } else { + memcpy(&p_dev_rec->conn_params, &p_data->api_conn.phy_1m_conn_params, sizeof(tBTA_BLE_CONN_PARAMS)); + } + } else { + APPL_TRACE_ERROR("Unknown Device, setting rejected"); + } + } + /* open/hold a connection */ if (!GATT_Connect(p_clcb->p_rcb->client_if, p_data->api_conn.remote_bda, p_data->api_conn.remote_addr_type, TRUE, p_data->api_conn.transport, p_data->api_conn.is_aux)) { @@ -1812,8 +1833,8 @@ static void bta_gattc_enc_cmpl_cback(tGATT_IF gattc_if, BD_ADDR bda) *******************************************************************************/ void bta_gattc_process_api_refresh(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg) { - tBTA_GATTC_SERV *p_srvc_cb = bta_gattc_find_srvr_cache(p_msg->api_conn.remote_bda); - tBTA_GATTC_CLCB *p_clcb = &bta_gattc_cb.clcb[0]; + tBTA_GATTC_SERV *p_srvc_cb = bta_gattc_find_srvr_cache(p_msg->api_refresh.remote_bda); + tBTA_GATTC_CLCB *p_clcb = &bta_gattc_cb.clcb[0]; BOOLEAN found = FALSE; UINT8 i; UNUSED(p_cb); @@ -1933,7 +1954,7 @@ void bta_gattc_process_api_cache_get_addr_list(tBTA_GATTC_CB *p_cb, tBTA_GATTC_D *******************************************************************************/ void bta_gattc_process_api_cache_clean(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg) { - tBTA_GATTC_SERV *p_srvc_cb = bta_gattc_find_srvr_cache(p_msg->api_conn.remote_bda); + tBTA_GATTC_SERV *p_srvc_cb = bta_gattc_find_srvr_cache(p_msg->api_clean.remote_bda); UNUSED(p_cb); if (p_srvc_cb != NULL && p_srvc_cb->p_srvc_cache != NULL) { diff --git a/components/bt/host/bluedroid/bta/gatt/bta_gattc_api.c b/components/bt/host/bluedroid/bta/gatt/bta_gattc_api.c index 87eb48b891..57ebf8c17b 100644 --- a/components/bt/host/bluedroid/bta/gatt/bta_gattc_api.c +++ b/components/bt/host/bluedroid/bta/gatt/bta_gattc_api.c @@ -143,7 +143,9 @@ void BTA_GATTC_AppDeregister(tBTA_GATTC_IF client_if) ** *******************************************************************************/ 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) + BOOLEAN is_direct, tBTA_GATT_TRANSPORT transport, BOOLEAN is_aux, tBTA_ADDR_TYPE own_addr_type, + UINT8 phy_mask, tBTA_BLE_CONN_PARAMS *phy_1m_conn_params, tBTA_BLE_CONN_PARAMS *phy_2m_conn_params, + tBTA_BLE_CONN_PARAMS *phy_coded_conn_params) { tBTA_GATTC_API_OPEN *p_buf; @@ -156,8 +158,11 @@ void BTA_GATTC_Enh_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, tBTA_ADDR_T p_buf->is_aux = is_aux; p_buf->remote_addr_type = remote_addr_type; p_buf->own_addr_type = own_addr_type; + p_buf->phy_mask = phy_mask; memcpy(p_buf->remote_bda, remote_bda, BD_ADDR_LEN); - + memcpy(&p_buf->phy_1m_conn_params, phy_1m_conn_params, sizeof(tBTA_BLE_CONN_PARAMS)); + memcpy(&p_buf->phy_2m_conn_params, phy_2m_conn_params, sizeof(tBTA_BLE_CONN_PARAMS)); + memcpy(&p_buf->phy_coded_conn_params, phy_coded_conn_params, sizeof(tBTA_BLE_CONN_PARAMS)); bta_sys_sendmsg(p_buf); } @@ -1011,9 +1016,9 @@ void BTA_GATTC_Refresh(BD_ADDR remote_bda, bool erase_flash) if(bta_sys_is_register(BTA_ID_GATTC) == FALSE) { return; } - tBTA_GATTC_API_OPEN *p_buf; + tBTA_GATTC_API_CACHE_REFRESH *p_buf; - if ((p_buf = (tBTA_GATTC_API_OPEN *) osi_malloc(sizeof(tBTA_GATTC_API_OPEN))) != NULL) { + if ((p_buf = (tBTA_GATTC_API_CACHE_REFRESH *) osi_malloc(sizeof(tBTA_GATTC_API_CACHE_REFRESH))) != NULL) { p_buf->hdr.event = BTA_GATTC_API_REFRESH_EVT; memcpy(p_buf->remote_bda, remote_bda, BD_ADDR_LEN); @@ -1069,9 +1074,9 @@ void BTA_GATTC_Clean(BD_ADDR remote_bda) bta_gattc_cache_reset(remote_bda); #endif - tBTA_GATTC_API_OPEN *p_buf; + tBTA_GATTC_API_CACHE_CLEAN *p_buf; - if ((p_buf = (tBTA_GATTC_API_OPEN *) osi_malloc(sizeof(tBTA_GATTC_API_OPEN))) != NULL) { + if ((p_buf = (tBTA_GATTC_API_CACHE_CLEAN *) osi_malloc(sizeof(tBTA_GATTC_API_CACHE_CLEAN))) != NULL) { p_buf->hdr.event = BTA_GATTC_API_CACHE_CLEAN_EVT; memcpy(p_buf->remote_bda, remote_bda, BD_ADDR_LEN); diff --git a/components/bt/host/bluedroid/bta/gatt/include/bta_gattc_int.h b/components/bt/host/bluedroid/bta/gatt/include/bta_gattc_int.h index 6d4bd5275a..aa404e55a2 100644 --- a/components/bt/host/bluedroid/bta/gatt/include/bta_gattc_int.h +++ b/components/bt/host/bluedroid/bta/gatt/include/bta_gattc_int.h @@ -134,9 +134,19 @@ typedef struct { BOOLEAN is_aux; tBTA_TRANSPORT transport; tBTA_ADDR_TYPE own_addr_type; + UINT8 phy_mask; + tBTA_BLE_CONN_PARAMS phy_1m_conn_params; + tBTA_BLE_CONN_PARAMS phy_2m_conn_params; + tBTA_BLE_CONN_PARAMS phy_coded_conn_params; } tBTA_GATTC_API_OPEN; -typedef tBTA_GATTC_API_OPEN tBTA_GATTC_API_CANCEL_OPEN; +typedef struct { + BT_HDR hdr; + BD_ADDR remote_bda; + tBTA_ADDR_TYPE remote_addr_type; + tBTA_GATTC_IF client_if; + BOOLEAN is_direct; +} tBTA_GATTC_API_CANCEL_OPEN; typedef struct { BT_HDR hdr; @@ -203,6 +213,11 @@ typedef struct { BT_HDR hdr; } tBTA_GATTC_API_CFG_MTU; +typedef struct { + BT_HDR hdr; + BD_ADDR remote_bda; +} tBTA_GATTC_API_CACHE_REFRESH; + typedef struct { BT_HDR hdr; tBTA_GATTC_IF client_if; @@ -216,6 +231,11 @@ typedef struct { tBTA_GATTC_IF client_if; } tBTA_GATTC_API_GET_ADDR; +typedef struct { + BT_HDR hdr; + BD_ADDR remote_bda; +} tBTA_GATTC_API_CACHE_CLEAN; + typedef struct { BT_HDR hdr; BD_ADDR remote_bda; @@ -248,8 +268,10 @@ typedef union { tBTA_GATTC_API_EXEC api_exec; tBTA_GATTC_API_READ_MULTI api_read_multi; tBTA_GATTC_API_CFG_MTU api_mtu; + tBTA_GATTC_API_CACHE_REFRESH api_refresh; tBTA_GATTC_API_CACHE_ASSOC api_assoc; tBTA_GATTC_API_GET_ADDR api_get_addr; + tBTA_GATTC_API_CACHE_CLEAN api_clean; tBTA_GATTC_OP_CMPL op_cmpl; tBTA_GATTC_INT_CONN int_conn; tBTA_GATTC_ENC_CMPL enc_cmpl; diff --git a/components/bt/host/bluedroid/bta/hh/bta_hh_le.c b/components/bt/host/bluedroid/bta/hh/bta_hh_le.c index d9cb98a3da..f5697dff52 100644 --- a/components/bt/host/bluedroid/bta/hh/bta_hh_le.c +++ b/components/bt/host/bluedroid/bta/hh/bta_hh_le.c @@ -334,7 +334,8 @@ 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_Enh_Open(bta_hh_cb.gatt_if, remote_bda, BLE_ADDR_UNKNOWN_TYPE, TRUE, BTA_GATT_TRANSPORT_LE, FALSE, BLE_ADDR_UNKNOWN_TYPE); + 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, 0, NULL, NULL, NULL); } /******************************************************************************* @@ -2601,7 +2602,8 @@ 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_Enh_Open(bta_hh_cb.gatt_if, p_cb->addr, BLE_ADDR_UNKNOWN_TYPE, FALSE, BTA_GATT_TRANSPORT_LE, FALSE, BLE_ADDR_UNKNOWN_TYPE); + 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, 0, NULL, NULL); p_cb->in_bg_conn = TRUE; BTA_DmBleSetBgConnType(BTA_DM_BLE_CONN_AUTO, NULL); diff --git a/components/bt/host/bluedroid/bta/include/bta/bta_gatt_api.h b/components/bt/host/bluedroid/bta/include/bta/bta_gatt_api.h index 55c4e7074a..ebfcd14369 100644 --- a/components/bt/host/bluedroid/bta/include/bta/bta_gatt_api.h +++ b/components/bt/host/bluedroid/bta/include/bta/bta_gatt_api.h @@ -728,6 +728,21 @@ typedef struct tBTA_GATTC_SERVICE *included_service; } __attribute__((packed)) tBTA_GATTC_INCLUDED_SVC; +typedef struct { + UINT16 scan_interval; + UINT16 scan_window; + UINT16 interval_min; + UINT16 interval_max; + UINT16 latency; + UINT16 supervision_timeout; + UINT16 min_ce_len; + UINT16 max_ce_len; +} tBTA_BLE_CONN_PARAMS; + +#define BTA_BLE_PHY_1M_MASK (1 << 0) +#define BTA_BLE_PHY_2M_MASK (1 << 1) +#define BTA_BLE_PHY_CODED_MASK (1 << 2) + /***************************************************************************** ** External Function Declarations *****************************************************************************/ @@ -801,7 +816,9 @@ extern void BTA_GATTC_AppDeregister (tBTA_GATTC_IF client_if); ** *******************************************************************************/ 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); + BOOLEAN is_direct, tBTA_GATT_TRANSPORT transport, BOOLEAN is_aux, tBTA_ADDR_TYPE own_addr_type, + UINT8 phy_mask, tBTA_BLE_CONN_PARAMS *phy_1m_conn_params, tBTA_BLE_CONN_PARAMS *phy_2m_conn_params, + tBTA_BLE_CONN_PARAMS *phy_coded_conn_params); /******************************************************************************* ** diff --git a/components/bt/host/bluedroid/btc/profile/std/gatt/btc_gattc.c b/components/bt/host/bluedroid/btc/profile/std/gatt/btc_gattc.c index 94db6dc05a..86221e3c89 100644 --- a/components/bt/host/bluedroid/btc/profile/std/gatt/btc_gattc.c +++ b/components/bt/host/bluedroid/btc/profile/std/gatt/btc_gattc.c @@ -215,7 +215,9 @@ static void btc_gattc_open(btc_ble_gattc_args_t *arg) 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, arg->open.own_addr_type); + transport, arg->open.is_aux, arg->open.own_addr_type, + arg->open.phy_mask, (void *)&arg->open.phy_1m_conn_params, + (void *)&arg->open.phy_2m_conn_params, (void *)&arg->open.phy_coded_conn_params); } static void btc_gattc_close(btc_ble_gattc_args_t *arg) diff --git a/components/bt/host/bluedroid/btc/profile/std/include/btc_gattc.h b/components/bt/host/bluedroid/btc/profile/std/include/btc_gattc.h index 0a37145b9b..1c8ef828b0 100644 --- a/components/bt/host/bluedroid/btc/profile/std/include/btc_gattc.h +++ b/components/bt/host/bluedroid/btc/profile/std/include/btc_gattc.h @@ -58,6 +58,10 @@ typedef union { bool is_direct; bool is_aux; esp_ble_addr_type_t own_addr_type; + esp_ble_phy_mask_t phy_mask; + esp_ble_conn_params_t phy_1m_conn_params; + esp_ble_conn_params_t phy_2m_conn_params; + esp_ble_conn_params_t phy_coded_conn_params; } open; //BTC_GATTC_ACT_CLOSE, struct close_arg { diff --git a/components/bt/host/bluedroid/stack/btm/include/btm_ble_int.h b/components/bt/host/bluedroid/stack/btm/include/btm_ble_int.h index d81a03c0a9..b3bc06aff4 100644 --- a/components/bt/host/bluedroid/stack/btm/include/btm_ble_int.h +++ b/components/bt/host/bluedroid/stack/btm/include/btm_ble_int.h @@ -212,11 +212,14 @@ typedef struct { #define BTM_BLE_MAX_BG_CONN_DEV_NUM 10 typedef struct { + UINT16 scan_interval; + UINT16 scan_window; UINT16 min_conn_int; UINT16 max_conn_int; UINT16 slave_latency; UINT16 supervision_tout; - + UINT16 min_ce_len; + UINT16 max_ce_len; } tBTM_LE_CONN_PRAMS; diff --git a/components/bt/host/bluedroid/stack/hcic/hciblecmds.c b/components/bt/host/bluedroid/stack/hcic/hciblecmds.c index c51746b1aa..286f8e3ae5 100644 --- a/components/bt/host/bluedroid/stack/hcic/hciblecmds.c +++ b/components/bt/host/bluedroid/stack/hcic/hciblecmds.c @@ -349,8 +349,8 @@ BOOLEAN btsnd_hcic_ble_create_ll_conn (UINT16 scan_int, UINT16 scan_win, UINT16_TO_STREAM (pp, conn_latency); UINT16_TO_STREAM (pp, conn_timeout); - UINT16_TO_STREAM (pp, min_ce_len); - UINT16_TO_STREAM (pp, max_ce_len); + UINT16_TO_STREAM (pp, min_ce_len ? min_ce_len : BLE_CE_LEN_MIN); + UINT16_TO_STREAM (pp, max_ce_len ? max_ce_len : BLE_CE_LEN_MIN); btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); return (TRUE); @@ -1594,8 +1594,8 @@ BOOLEAN btsnd_hcic_ble_create_ext_conn(tHCI_CreatExtConn *p_conn) UINT16_TO_STREAM(pp, params->conn_interval_max); UINT16_TO_STREAM(pp, params->conn_latency); UINT16_TO_STREAM(pp, params->sup_timeout); - UINT16_TO_STREAM(pp, BLE_CE_LEN_MIN); - UINT16_TO_STREAM(pp, BLE_CE_LEN_MIN); + UINT16_TO_STREAM(pp, params->min_ce_len ? params->min_ce_len : BLE_CE_LEN_MIN); + UINT16_TO_STREAM(pp, params->max_ce_len ? params->max_ce_len : BLE_CE_LEN_MIN); } if (p_conn->init_phy_mask & 0x02) { @@ -1606,8 +1606,8 @@ BOOLEAN btsnd_hcic_ble_create_ext_conn(tHCI_CreatExtConn *p_conn) UINT16_TO_STREAM(pp, params->conn_interval_max); UINT16_TO_STREAM(pp, params->conn_latency); UINT16_TO_STREAM(pp, params->sup_timeout); - UINT16_TO_STREAM(pp, BLE_CE_LEN_MIN); - UINT16_TO_STREAM(pp, BLE_CE_LEN_MIN); + UINT16_TO_STREAM(pp, params->min_ce_len ? params->min_ce_len : BLE_CE_LEN_MIN); + UINT16_TO_STREAM(pp, params->max_ce_len ? params->max_ce_len : BLE_CE_LEN_MIN); } if (p_conn->init_phy_mask & 0x04) { @@ -1618,8 +1618,8 @@ BOOLEAN btsnd_hcic_ble_create_ext_conn(tHCI_CreatExtConn *p_conn) UINT16_TO_STREAM(pp, params->conn_interval_max); UINT16_TO_STREAM(pp, params->conn_latency); UINT16_TO_STREAM(pp, params->sup_timeout); - UINT16_TO_STREAM(pp, BLE_CE_LEN_MIN); - UINT16_TO_STREAM(pp, BLE_CE_LEN_MIN); + UINT16_TO_STREAM(pp, params->min_ce_len ? params->min_ce_len : BLE_CE_LEN_MIN); + UINT16_TO_STREAM(pp, params->max_ce_len ? params->max_ce_len : BLE_CE_LEN_MIN); } btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); diff --git a/components/bt/host/bluedroid/stack/l2cap/l2c_ble.c b/components/bt/host/bluedroid/stack/l2cap/l2c_ble.c index 36f91cfe08..ecb42fc321 100644 --- a/components/bt/host/bluedroid/stack/l2cap/l2c_ble.c +++ b/components/bt/host/bluedroid/stack/l2cap/l2c_ble.c @@ -902,6 +902,12 @@ BOOLEAN l2cble_init_direct_conn (tL2C_LCB *p_lcb) scan_int = (p_cb->scan_int == BTM_BLE_SCAN_PARAM_UNDEF) ? BTM_BLE_SCAN_FAST_INT : p_cb->scan_int; scan_win = (p_cb->scan_win == BTM_BLE_SCAN_PARAM_UNDEF) ? BTM_BLE_SCAN_FAST_WIN : p_cb->scan_win; + if (p_dev_rec->conn_params.scan_interval && p_dev_rec->conn_params.scan_interval != BTM_BLE_CONN_PARAM_UNDEF) { + scan_int = p_dev_rec->conn_params.scan_interval; + } + if (p_dev_rec->conn_params.scan_window && p_dev_rec->conn_params.scan_window != BTM_BLE_CONN_PARAM_UNDEF) { + scan_win = p_dev_rec->conn_params.scan_window; + } peer_addr_type = p_lcb->ble_addr_type; memcpy(peer_addr, p_lcb->remote_bd_addr, BD_ADDR_LEN); @@ -966,22 +972,24 @@ BOOLEAN l2cble_init_direct_conn (tL2C_LCB *p_lcb) } if (!p_lcb->is_aux) { - if (!btsnd_hcic_ble_create_ll_conn (scan_int,/* UINT16 scan_int */ - scan_win, /* UINT16 scan_win */ - FALSE, /* UINT8 white_list */ - peer_addr_type, /* UINT8 addr_type_peer */ - peer_addr, /* BD_ADDR bda_peer */ - own_addr_type, /* UINT8 addr_type_own */ + if (!btsnd_hcic_ble_create_ll_conn (scan_int, /* UINT16 scan_int */ + scan_win, /* UINT16 scan_win */ + FALSE, /* UINT8 white_list */ + peer_addr_type, /* UINT8 addr_type_peer */ + peer_addr, /* BD_ADDR bda_peer */ + own_addr_type, /* UINT8 addr_type_own */ (UINT16) ((p_dev_rec->conn_params.min_conn_int != BTM_BLE_CONN_PARAM_UNDEF) ? - p_dev_rec->conn_params.min_conn_int : BTM_BLE_CONN_INT_MIN_DEF), /* UINT16 conn_int_min */ + p_dev_rec->conn_params.min_conn_int : BTM_BLE_CONN_INT_MIN_DEF), /* UINT16 conn_int_min */ (UINT16) ((p_dev_rec->conn_params.max_conn_int != BTM_BLE_CONN_PARAM_UNDEF) ? - p_dev_rec->conn_params.max_conn_int : BTM_BLE_CONN_INT_MAX_DEF), /* UINT16 conn_int_max */ + p_dev_rec->conn_params.max_conn_int : BTM_BLE_CONN_INT_MAX_DEF), /* UINT16 conn_int_max */ (UINT16) ((p_dev_rec->conn_params.slave_latency != BTM_BLE_CONN_PARAM_UNDEF) ? - p_dev_rec->conn_params.slave_latency : BTM_BLE_CONN_SLAVE_LATENCY_DEF), /* UINT16 conn_latency */ + p_dev_rec->conn_params.slave_latency : BTM_BLE_CONN_SLAVE_LATENCY_DEF), /* UINT16 conn_latency */ (UINT16) ((p_dev_rec->conn_params.supervision_tout != BTM_BLE_CONN_PARAM_UNDEF) ? - p_dev_rec->conn_params.supervision_tout : BTM_BLE_CONN_TIMEOUT_DEF), /* conn_timeout */ - BLE_CE_LEN_MIN, /* UINT16 min_len */ - BLE_CE_LEN_MIN)) { /* UINT16 max_len */ + p_dev_rec->conn_params.supervision_tout : BTM_BLE_CONN_TIMEOUT_DEF), /* UINT16 conn_timeout */ + (UINT16) ((p_dev_rec->conn_params.min_ce_len != BTM_BLE_CONN_PARAM_UNDEF) ? + p_dev_rec->conn_params.min_ce_len : BLE_CE_LEN_MIN), /* UINT16 min_ce_len */ + (UINT16) ((p_dev_rec->conn_params.max_ce_len != BTM_BLE_CONN_PARAM_UNDEF) ? + p_dev_rec->conn_params.max_ce_len : BLE_CE_LEN_MIN) /* UINT16 max_ce_len */)) { l2cu_release_lcb (p_lcb); L2CAP_TRACE_ERROR("initiate direct connection fail, no resources"); return (FALSE); diff --git a/components/bt/include/esp32/include/esp_bt.h b/components/bt/include/esp32/include/esp_bt.h index be9e2cce22..8279ea2606 100644 --- a/components/bt/include/esp32/include/esp_bt.h +++ b/components/bt/include/esp32/include/esp_bt.h @@ -637,14 +637,14 @@ esp_err_t esp_bt_sleep_disable(void); * @brief Manually clear the scan duplicate list * * @note - * 1. This function name is incorrectly spelled, it will be fixed in release 5.x version. - * 2. The scan duplicate list will be automatically cleared when the maximum amount of devices in the filter is reached. - * The amount of devices in the filter can be configured in menuconfig. + * The scan duplicate list will be automatically cleared when the maximum amount of devices in the filter is reached. The amount of devices in the filter can be configured in menuconfig. * * @return * - ESP_OK: Success * - ESP_ERR_INVALID_STATE: Invalid Bluetooth Controller state */ +esp_err_t esp_ble_scan_duplicate_list_flush(void); + esp_err_t esp_ble_scan_dupilcate_list_flush(void); #ifdef __cplusplus diff --git a/components/bt/include/esp32c3/include/esp_bt.h b/components/bt/include/esp32c3/include/esp_bt.h index c2031e5b1b..bae8983b8b 100644 --- a/components/bt/include/esp32c3/include/esp_bt.h +++ b/components/bt/include/esp32c3/include/esp_bt.h @@ -570,8 +570,6 @@ esp_err_t esp_bt_controller_disable(void); */ esp_bt_controller_status_t esp_bt_controller_get_status(void); -uint16_t esp_bt_get_tx_buf_num(void); - /** @brief esp_vhci_host_callback * used for vhci call host function to notify what host need to do */ diff --git a/components/esp_hid/src/ble_hidh.c b/components/esp_hid/src/ble_hidh.c index 4e907699df..b10119ed9b 100644 --- a/components/esp_hid/src/ble_hidh.c +++ b/components/esp_hid/src/ble_hidh.c @@ -672,12 +672,13 @@ 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; - esp_ble_gatt_creat_conn_params_t creat_conn_params; + esp_ble_gatt_creat_conn_params_t creat_conn_params = {0}; memcpy(&creat_conn_params.remote_bda, dev->addr.bda, ESP_BD_ADDR_LEN); creat_conn_params.remote_addr_type = dev->ble.address_type; creat_conn_params.own_addr_type = BLE_ADDR_TYPE_PUBLIC; creat_conn_params.is_direct = true; creat_conn_params.is_aux = false; + creat_conn_params.phy_mask = 0x0; ret = esp_ble_gattc_enh_open(hid_gattc_if, &creat_conn_params); if (ret) { diff --git a/examples/bluetooth/bluedroid/ble/ble_ancs/main/ble_ancs_demo.c b/examples/bluetooth/bluedroid/ble/ble_ancs/main/ble_ancs_demo.c index 69a51ce1a1..04994799e8 100644 --- a/examples/bluetooth/bluedroid/ble/ble_ancs/main/ble_ancs_demo.c +++ b/examples/bluetooth/bluedroid/ble/ble_ancs/main/ble_ancs_demo.c @@ -563,12 +563,13 @@ static void gattc_profile_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_ //ESP_LOGI(BLE_ANCS_TAG, "ESP_GATTC_CONNECT_EVT"); memcpy(gl_profile_tab[PROFILE_A_APP_ID].remote_bda, param->connect.remote_bda, 6); // create gattc virtual connection - esp_ble_gatt_creat_conn_params_t creat_conn_params; + esp_ble_gatt_creat_conn_params_t creat_conn_params = {0}; memcpy(&creat_conn_params.remote_bda, gl_profile_tab[PROFILE_A_APP_ID].remote_bda, ESP_BD_ADDR_LEN); creat_conn_params.remote_addr_type = BLE_ADDR_TYPE_RANDOM; creat_conn_params.own_addr_type = BLE_ADDR_TYPE_RPA_PUBLIC; creat_conn_params.is_direct = true; creat_conn_params.is_aux = false; + creat_conn_params.phy_mask = 0x0; esp_ble_gattc_enh_open(gl_profile_tab[PROFILE_A_APP_ID].gattc_if, &creat_conn_params); break; diff --git a/examples/bluetooth/bluedroid/ble/ble_spp_client/main/spp_client_demo.c b/examples/bluetooth/bluedroid/ble/ble_spp_client/main/spp_client_demo.c index f14dccbf4e..306a5834eb 100644 --- a/examples/bluetooth/bluedroid/ble/ble_spp_client/main/spp_client_demo.c +++ b/examples/bluetooth/bluedroid/ble/ble_spp_client/main/spp_client_demo.c @@ -238,12 +238,13 @@ static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *par ESP_LOGI(GATTC_TAG, "Scan stop successfully"); if (is_connect == false) { ESP_LOGI(GATTC_TAG, "Connect to the remote device."); - esp_ble_gatt_creat_conn_params_t creat_conn_params; + esp_ble_gatt_creat_conn_params_t creat_conn_params = {0}; memcpy(&creat_conn_params.remote_bda, scan_rst.scan_rst.bda,ESP_BD_ADDR_LEN); creat_conn_params.remote_addr_type = scan_rst.scan_rst.ble_addr_type; creat_conn_params.own_addr_type = BLE_ADDR_TYPE_PUBLIC; creat_conn_params.is_direct = true; creat_conn_params.is_aux = false; + creat_conn_params.phy_mask = 0x0; esp_ble_gattc_enh_open(gl_profile_tab[PROFILE_APP_ID].gattc_if, &creat_conn_params); } diff --git a/examples/bluetooth/bluedroid/ble/ble_throughput/throughput_client/main/example_ble_client_throughput.c b/examples/bluetooth/bluedroid/ble/ble_throughput/throughput_client/main/example_ble_client_throughput.c index d7dc81cb00..8759479bbe 100644 --- a/examples/bluetooth/bluedroid/ble/ble_throughput/throughput_client/main/example_ble_client_throughput.c +++ b/examples/bluetooth/bluedroid/ble/ble_throughput/throughput_client/main/example_ble_client_throughput.c @@ -401,19 +401,27 @@ static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *par if (connect == false) { connect = true; ESP_LOGI(GATTC_TAG, "Connect to the remote device"); -#if(CONFIG_EXAMPLE_GATTC_WRITE_THROUGHPUT && CONFIG_EXAMPLE_GATTS_NOTIFY_THROUGHPUT) - esp_ble_gap_set_prefer_conn_params(scan_result->scan_rst.bda, 34, 34, 0, 600); -#else - esp_ble_gap_set_prefer_conn_params(scan_result->scan_rst.bda, 32, 32, 0, 600); -#endif - esp_ble_gap_stop_scanning(); - esp_ble_gatt_creat_conn_params_t creat_conn_params; + + esp_ble_conn_params_t phy_1m_conn_params = {0}; +#if(CONFIG_EXAMPLE_GATTC_WRITE_THROUGHPUT && CONFIG_EXAMPLE_GATTS_NOTIFY_THROUGHPUT) + phy_1m_conn_params.interval_max = 34; + phy_1m_conn_params.interval_max = 34; +#else + phy_1m_conn_params.interval_max = 32; + phy_1m_conn_params.interval_min = 32; +#endif + phy_1m_conn_params.latency = 0; + phy_1m_conn_params.supervision_timeout = 600; + + esp_ble_gatt_creat_conn_params_t creat_conn_params = {0}; memcpy(&creat_conn_params.remote_bda, scan_result->scan_rst.bda, ESP_BD_ADDR_LEN); creat_conn_params.remote_addr_type = scan_result->scan_rst.ble_addr_type; creat_conn_params.own_addr_type = BLE_ADDR_TYPE_PUBLIC; creat_conn_params.is_direct = true; creat_conn_params.is_aux = false; + creat_conn_params.phy_mask = ESP_BLE_PHY_1M_PREF_MASK; + creat_conn_params.phy_1m_conn_params = &phy_1m_conn_params; esp_ble_gattc_enh_open(gl_profile_tab[PROFILE_A_APP_ID].gattc_if, &creat_conn_params); } diff --git a/examples/bluetooth/bluedroid/ble/gatt_client/main/gattc_demo.c b/examples/bluetooth/bluedroid/ble/gatt_client/main/gattc_demo.c index 1820566216..9aca6ad1ab 100644 --- a/examples/bluetooth/bluedroid/ble/gatt_client/main/gattc_demo.c +++ b/examples/bluetooth/bluedroid/ble/gatt_client/main/gattc_demo.c @@ -370,12 +370,13 @@ static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *par connect = true; ESP_LOGI(GATTC_TAG, "Connect to the remote device"); esp_ble_gap_stop_scanning(); - esp_ble_gatt_creat_conn_params_t creat_conn_params; + esp_ble_gatt_creat_conn_params_t creat_conn_params = {0}; memcpy(&creat_conn_params.remote_bda, scan_result->scan_rst.bda, ESP_BD_ADDR_LEN); creat_conn_params.remote_addr_type = scan_result->scan_rst.ble_addr_type; creat_conn_params.own_addr_type = BLE_ADDR_TYPE_PUBLIC; creat_conn_params.is_direct = true; creat_conn_params.is_aux = false; + creat_conn_params.phy_mask = 0x0; esp_ble_gattc_enh_open(gl_profile_tab[PROFILE_A_APP_ID].gattc_if, &creat_conn_params); } diff --git a/examples/bluetooth/bluedroid/ble/gatt_client/tutorial/Gatt_Client_Example_Walkthrough.md b/examples/bluetooth/bluedroid/ble/gatt_client/tutorial/Gatt_Client_Example_Walkthrough.md index e4eaffd9a0..9fdd2a6ac8 100644 --- a/examples/bluetooth/bluedroid/ble/gatt_client/tutorial/Gatt_Client_Example_Walkthrough.md +++ b/examples/bluetooth/bluedroid/ble/gatt_client/tutorial/Gatt_Client_Example_Walkthrough.md @@ -372,14 +372,15 @@ We are interested in the `ESP_GAP_SEARCH_INQ_RES_EVT` event, which is called eve connect = true; ESP_LOGI(GATTC_TAG, "connect to the remote device."); esp_ble_gap_stop_scanning(); - esp_ble_gatt_creat_conn_params_t esp_ble_gatt_create_conn; - memcpy(&esp_ble_gatt_create_conn.remote_bda, scan_result->scan_rst.bda, ESP_BD_ADDR_LEN); - esp_ble_gatt_create_conn.remote_addr_type = scan_result->scan_rst.ble_addr_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; + esp_ble_gatt_creat_conn_params_t creat_conn_params = {0}; + memcpy(&creat_conn_params.remote_bda, scan_result->scan_rst.bda, ESP_BD_ADDR_LEN); + creat_conn_params.remote_addr_type = scan_result->scan_rst.ble_addr_type; + creat_conn_params.own_addr_type = BLE_ADDR_TYPE_PUBLIC; + creat_conn_params.is_direct = true; + creat_conn_params.is_aux = false; + creat_conn_params.phy_mask = 0x0; esp_ble_gattc_enh_open(gl_profile_tab[PROFILE_A_APP_ID].gattc_if, - &esp_ble_gatt_create_conn); + &creat_conn_params); } } } diff --git a/examples/bluetooth/bluedroid/ble/gatt_security_client/main/example_ble_sec_gattc_demo.c b/examples/bluetooth/bluedroid/ble/gatt_security_client/main/example_ble_sec_gattc_demo.c index 912dc5cd92..7f6fda129a 100644 --- a/examples/bluetooth/bluedroid/ble/gatt_security_client/main/example_ble_sec_gattc_demo.c +++ b/examples/bluetooth/bluedroid/ble/gatt_security_client/main/example_ble_sec_gattc_demo.c @@ -465,14 +465,15 @@ static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *par connect = true; ESP_LOGI(GATTC_TAG, "Connect to the remote device"); esp_ble_gap_stop_scanning(); - esp_ble_gatt_creat_conn_params_t esp_ble_gatt_create_conn; - memcpy(&esp_ble_gatt_create_conn.remote_bda, scan_result->scan_rst.bda, ESP_BD_ADDR_LEN); - esp_ble_gatt_create_conn.remote_addr_type = scan_result->scan_rst.ble_addr_type; - esp_ble_gatt_create_conn.own_addr_type = BLE_ADDR_TYPE_RPA_PUBLIC; - esp_ble_gatt_create_conn.is_direct = true; - esp_ble_gatt_create_conn.is_aux = false; + esp_ble_gatt_creat_conn_params_t creat_conn_params = {0}; + memcpy(&creat_conn_params.remote_bda, scan_result->scan_rst.bda, ESP_BD_ADDR_LEN); + creat_conn_params.remote_addr_type = scan_result->scan_rst.ble_addr_type; + creat_conn_params.own_addr_type = BLE_ADDR_TYPE_RPA_PUBLIC; + creat_conn_params.is_direct = true; + creat_conn_params.is_aux = false; + creat_conn_params.phy_mask = 0x0; esp_ble_gattc_enh_open(gl_profile_tab[PROFILE_A_APP_ID].gattc_if, - &esp_ble_gatt_create_conn); + &creat_conn_params); } } } diff --git a/examples/bluetooth/bluedroid/ble/gattc_multi_connect/main/gattc_multi_connect.c b/examples/bluetooth/bluedroid/ble/gattc_multi_connect/main/gattc_multi_connect.c index 66a260439c..f455aaadb7 100644 --- a/examples/bluetooth/bluedroid/ble/gattc_multi_connect/main/gattc_multi_connect.c +++ b/examples/bluetooth/bluedroid/ble/gattc_multi_connect/main/gattc_multi_connect.c @@ -817,12 +817,13 @@ static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *par conn_device_a = true; ESP_LOGI(GATTC_TAG, "Searched device %s", remote_device_name[0]); esp_ble_gap_stop_scanning(); - esp_ble_gatt_creat_conn_params_t creat_conn_params; + esp_ble_gatt_creat_conn_params_t creat_conn_params = {0}; memcpy(&creat_conn_params.remote_bda, scan_result->scan_rst.bda, ESP_BD_ADDR_LEN); creat_conn_params.remote_addr_type = scan_result->scan_rst.ble_addr_type; creat_conn_params.own_addr_type = BLE_ADDR_TYPE_PUBLIC; creat_conn_params.is_direct = true; creat_conn_params.is_aux = false; + creat_conn_params.phy_mask = 0x0; esp_ble_gattc_enh_open(gl_profile_tab[PROFILE_A_APP_ID].gattc_if, &creat_conn_params); Isconnecting = true; @@ -834,12 +835,13 @@ static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *par conn_device_b = true; ESP_LOGI(GATTC_TAG, "Searched device %s", remote_device_name[1]); esp_ble_gap_stop_scanning(); - esp_ble_gatt_creat_conn_params_t creat_conn_params; + esp_ble_gatt_creat_conn_params_t creat_conn_params = {0}; memcpy(&creat_conn_params.remote_bda, scan_result->scan_rst.bda, ESP_BD_ADDR_LEN); creat_conn_params.remote_addr_type = scan_result->scan_rst.ble_addr_type; creat_conn_params.own_addr_type = BLE_ADDR_TYPE_PUBLIC; creat_conn_params.is_direct = true; creat_conn_params.is_aux = false; + creat_conn_params.phy_mask = 0x0; esp_ble_gattc_enh_open(gl_profile_tab[PROFILE_A_APP_ID].gattc_if, &creat_conn_params); Isconnecting = true; @@ -851,12 +853,13 @@ static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *par conn_device_c = true; ESP_LOGI(GATTC_TAG, "Searched device %s", remote_device_name[2]); esp_ble_gap_stop_scanning(); - esp_ble_gatt_creat_conn_params_t creat_conn_params; + esp_ble_gatt_creat_conn_params_t creat_conn_params = {0}; memcpy(&creat_conn_params.remote_bda, scan_result->scan_rst.bda, ESP_BD_ADDR_LEN); creat_conn_params.remote_addr_type = scan_result->scan_rst.ble_addr_type; creat_conn_params.own_addr_type = BLE_ADDR_TYPE_PUBLIC; creat_conn_params.is_direct = true; creat_conn_params.is_aux = false; + creat_conn_params.phy_mask = 0x0; esp_ble_gattc_enh_open(gl_profile_tab[PROFILE_A_APP_ID].gattc_if, &creat_conn_params); Isconnecting = true; diff --git a/examples/bluetooth/bluedroid/ble/gattc_multi_connect/tutorial/Gatt_Client_Multi_Connection_Example_Walkthrough.md b/examples/bluetooth/bluedroid/ble/gattc_multi_connect/tutorial/Gatt_Client_Multi_Connection_Example_Walkthrough.md index a5b8f84277..88e14d2ed3 100644 --- a/examples/bluetooth/bluedroid/ble/gattc_multi_connect/tutorial/Gatt_Client_Multi_Connection_Example_Walkthrough.md +++ b/examples/bluetooth/bluedroid/ble/gattc_multi_connect/tutorial/Gatt_Client_Multi_Connection_Example_Walkthrough.md @@ -160,14 +160,15 @@ The scan stop triggers an ``ESP_GAP_BLE_SCAN_STOP_COMPLETE_EVT`` event which is conn_device_a = true; ESP_LOGI(GATTC_TAG, "Searched device %s", remote_device_name[0]); esp_ble_gap_stop_scanning(); - esp_ble_gatt_creat_conn_params_t esp_ble_gatt_create_conn; - memcpy(&esp_ble_gatt_create_conn.remote_bda, scan_result->scan_rst.bda, ESP_BD_ADDR_LEN); - esp_ble_gatt_create_conn.remote_addr_type = scan_result->scan_rst.ble_addr_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; + esp_ble_gatt_creat_conn_params_t creat_conn_params = {0}; + memcpy(&creat_conn_params.remote_bda, scan_result->scan_rst.bda, ESP_BD_ADDR_LEN); + creat_conn_params.remote_addr_type = scan_result->scan_rst.ble_addr_type; + creat_conn_params.own_addr_type = BLE_ADDR_TYPE_PUBLIC; + creat_conn_params.is_direct = true; + creat_conn_params.is_aux = false; + creat_conn_params.phy_mask = 0x0; esp_ble_gattc_enh_open(gl_profile_tab[PROFILE_A_APP_ID].gattc_if, - &esp_ble_gatt_create_conn); + &creat_conn_params); Isconnecting = true; } break; @@ -177,14 +178,15 @@ The scan stop triggers an ``ESP_GAP_BLE_SCAN_STOP_COMPLETE_EVT`` event which is conn_device_b = true; ESP_LOGI(GATTC_TAG, "Searched device %s", remote_device_name[1]); esp_ble_gap_stop_scanning(); - esp_ble_gatt_creat_conn_params_t esp_ble_gatt_create_conn; - memcpy(&esp_ble_gatt_create_conn.remote_bda, scan_result->scan_rst.bda, ESP_BD_ADDR_LEN); - esp_ble_gatt_create_conn.remote_addr_type = scan_result->scan_rst.ble_addr_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; + esp_ble_gatt_creat_conn_params_t creat_conn_params = {0}; + memcpy(&creat_conn_params.remote_bda, scan_result->scan_rst.bda, ESP_BD_ADDR_LEN); + creat_conn_params.remote_addr_type = scan_result->scan_rst.ble_addr_type; + creat_conn_params.own_addr_type = BLE_ADDR_TYPE_PUBLIC; + creat_conn_params.is_direct = true; + creat_conn_params.is_aux = false; + creat_conn_params.phy_mask = 0x0; esp_ble_gattc_enh_open(gl_profile_tab[PROFILE_A_APP_ID].gattc_if, - &esp_ble_gatt_create_conn); + &creat_conn_params); Isconnecting = true; } @@ -194,14 +196,15 @@ The scan stop triggers an ``ESP_GAP_BLE_SCAN_STOP_COMPLETE_EVT`` event which is conn_device_c = true; ESP_LOGI(GATTC_TAG, "Searched device %s", remote_device_name[2]); esp_ble_gap_stop_scanning(); - esp_ble_gatt_creat_conn_params_t esp_ble_gatt_create_conn; - memcpy(&esp_ble_gatt_create_conn.remote_bda, scan_result->scan_rst.bda, ESP_BD_ADDR_LEN); - esp_ble_gatt_create_conn.remote_addr_type = scan_result->scan_rst.ble_addr_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; + esp_ble_gatt_creat_conn_params_t creat_conn_params = {0}; + memcpy(&creat_conn_params.remote_bda, scan_result->scan_rst.bda, ESP_BD_ADDR_LEN); + creat_conn_params.remote_addr_type = scan_result->scan_rst.ble_addr_type; + creat_conn_params.own_addr_type = BLE_ADDR_TYPE_PUBLIC; + creat_conn_params.is_direct = true; + creat_conn_params.is_aux = false; + creat_conn_params.phy_mask = 0x0; esp_ble_gattc_enh_open(gl_profile_tab[PROFILE_A_APP_ID].gattc_if, - &esp_ble_gatt_create_conn); + &creat_conn_params); Isconnecting = true; } break; diff --git a/examples/bluetooth/bluedroid/ble_50/ble50_security_client/main/ble50_sec_gattc_demo.c b/examples/bluetooth/bluedroid/ble_50/ble50_security_client/main/ble50_sec_gattc_demo.c index 8212d365ee..720fd61924 100644 --- a/examples/bluetooth/bluedroid/ble_50/ble50_security_client/main/ble50_sec_gattc_demo.c +++ b/examples/bluetooth/bluedroid/ble_50/ble50_security_client/main/ble50_sec_gattc_demo.c @@ -65,7 +65,7 @@ static esp_ble_ext_scan_params_t ext_scan_params = { .coded_cfg = {BLE_SCAN_TYPE_ACTIVE, 40, 40}, }; -const esp_ble_gap_conn_params_t phy_1m_conn_params = { +const esp_ble_conn_params_t phy_1m_conn_params = { .scan_interval = 0x40, .scan_window = 0x40, .interval_min = 320, @@ -75,7 +75,7 @@ const esp_ble_gap_conn_params_t phy_1m_conn_params = { .min_ce_len = 0, .max_ce_len = 0, }; -const esp_ble_gap_conn_params_t phy_2m_conn_params = { +const esp_ble_conn_params_t phy_2m_conn_params = { .scan_interval = 0x40, .scan_window = 0x40, .interval_min = 320, @@ -85,7 +85,7 @@ const esp_ble_gap_conn_params_t phy_2m_conn_params = { .min_ce_len = 0, .max_ce_len = 0, }; -const esp_ble_gap_conn_params_t phy_coded_conn_params = { +const esp_ble_conn_params_t phy_coded_conn_params = { .scan_interval = 0x40, .scan_window = 0x40, .interval_min = 320, // 306-> 362Kbps @@ -500,18 +500,18 @@ static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *par ESP_LOG_BUFFER_CHAR("Adv name", adv_name, adv_name_len); ESP_LOGI(GATTC_TAG, "Stop extend scan and create aux open, primary_phy %d secondary phy %d", param->ext_adv_report.params.primary_phy, param->ext_adv_report.params.secondly_phy); - esp_ble_gap_prefer_ext_connect_params_set(param->ext_adv_report.params.addr, - ESP_BLE_GAP_PHY_1M_PREF_MASK | ESP_BLE_GAP_PHY_2M_PREF_MASK | ESP_BLE_GAP_PHY_CODED_PREF_MASK , - &phy_1m_conn_params, &phy_2m_conn_params, &phy_coded_conn_params); // create gattc virtual connection - esp_ble_gatt_creat_conn_params_t creat_conn_params; + esp_ble_gatt_creat_conn_params_t creat_conn_params = {0}; memcpy(&creat_conn_params.remote_bda, param->ext_adv_report.params.addr, ESP_BD_ADDR_LEN); creat_conn_params.remote_addr_type = param->ext_adv_report.params.addr_type; creat_conn_params.own_addr_type = BLE_ADDR_TYPE_PUBLIC; creat_conn_params.is_direct = true; creat_conn_params.is_aux = true; - esp_ble_gattc_enh_open(gl_profile_tab[PROFILE_A_APP_ID].gattc_if, - &creat_conn_params); + creat_conn_params.phy_mask = ESP_BLE_PHY_1M_PREF_MASK | ESP_BLE_PHY_2M_PREF_MASK | ESP_BLE_PHY_CODED_PREF_MASK; + creat_conn_params.phy_1m_conn_params = &phy_1m_conn_params; + creat_conn_params.phy_2m_conn_params = &phy_2m_conn_params; + creat_conn_params.phy_coded_conn_params = &phy_coded_conn_params; + esp_ble_gattc_enh_open(gl_profile_tab[PROFILE_A_APP_ID].gattc_if, &creat_conn_params); } break; diff --git a/examples/bluetooth/bluedroid/ble_50/ble50_throughput/throughput_client/main/example_ble_client_throughput.c b/examples/bluetooth/bluedroid/ble_50/ble50_throughput/throughput_client/main/example_ble_client_throughput.c index 4f651bfb84..17c9a99d82 100644 --- a/examples/bluetooth/bluedroid/ble_50/ble50_throughput/throughput_client/main/example_ble_client_throughput.c +++ b/examples/bluetooth/bluedroid/ble_50/ble50_throughput/throughput_client/main/example_ble_client_throughput.c @@ -95,7 +95,7 @@ static esp_bt_uuid_t notify_descr_uuid = { }; static esp_ble_ext_scan_params_t ext_scan_params = { - .own_addr_type = BLE_ADDR_TYPE_RPA_PUBLIC, + .own_addr_type = BLE_ADDR_TYPE_PUBLIC, .filter_policy = BLE_SCAN_FILTER_ALLOW_ALL, .scan_duplicate = BLE_SCAN_DUPLICATE_DISABLE, .cfg_mask = ESP_BLE_GAP_EXT_SCAN_CFG_CODE_MASK | ESP_BLE_GAP_EXT_SCAN_CFG_UNCODE_MASK, @@ -104,7 +104,7 @@ static esp_ble_ext_scan_params_t ext_scan_params = { }; // If the interference in the air is severe, the connection interval can be reduced. -const esp_ble_gap_conn_params_t phy_1m_conn_params = { +const esp_ble_conn_params_t phy_1m_conn_params = { .interval_max = 104, // 130ms .interval_min = 104, .latency = 0, @@ -115,7 +115,7 @@ const esp_ble_gap_conn_params_t phy_1m_conn_params = { .supervision_timeout = 600, }; -const esp_ble_gap_conn_params_t phy_2m_conn_params = { +const esp_ble_conn_params_t phy_2m_conn_params = { .interval_max = 104, // 130ms .interval_min = 104, .latency = 0, @@ -126,7 +126,7 @@ const esp_ble_gap_conn_params_t phy_2m_conn_params = { .supervision_timeout = 600, }; -const esp_ble_gap_conn_params_t phy_coded_conn_params = { +const esp_ble_conn_params_t phy_coded_conn_params = { .interval_max = 104, // 130ms .interval_min = 104, .latency = 0, @@ -441,12 +441,17 @@ static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *par ESP_LOGI(GATTC_TAG, "Device found "ESP_BD_ADDR_STR"", ESP_BD_ADDR_HEX(param->ext_adv_report.params.addr)); ESP_LOG_BUFFER_CHAR("Adv name", adv_name, adv_name_len); ESP_LOGI(GATTC_TAG, "Stop extend scan and create aux open, primary_phy %d secondary phy %d", param->ext_adv_report.params.primary_phy, param->ext_adv_report.params.secondly_phy); - esp_ble_gap_prefer_ext_connect_params_set(param->ext_adv_report.params.addr, - ESP_BLE_GAP_PHY_1M_PREF_MASK | ESP_BLE_GAP_PHY_2M_PREF_MASK | ESP_BLE_GAP_PHY_CODED_PREF_MASK, - &phy_1m_conn_params, &phy_2m_conn_params, &phy_coded_conn_params); - esp_ble_gattc_aux_open(gl_profile_tab[PROFILE_A_APP_ID].gattc_if, - param->ext_adv_report.params.addr, - param->ext_adv_report.params.addr_type, true); + esp_ble_gatt_creat_conn_params_t creat_conn_params = {0}; + memcpy(&creat_conn_params.remote_bda, param->ext_adv_report.params.addr, ESP_BD_ADDR_LEN); + creat_conn_params.remote_addr_type = param->ext_adv_report.params.addr_type; + creat_conn_params.own_addr_type = BLE_ADDR_TYPE_PUBLIC; + creat_conn_params.is_direct = true; + creat_conn_params.is_aux = true; + creat_conn_params.phy_mask = ESP_BLE_PHY_1M_PREF_MASK | ESP_BLE_PHY_2M_PREF_MASK | ESP_BLE_PHY_CODED_PREF_MASK; + creat_conn_params.phy_1m_conn_params = &phy_1m_conn_params; + creat_conn_params.phy_2m_conn_params = &phy_2m_conn_params; + creat_conn_params.phy_coded_conn_params = &phy_coded_conn_params; + esp_ble_gattc_enh_open(gl_profile_tab[PROFILE_A_APP_ID].gattc_if, &creat_conn_params); } break; } diff --git a/examples/bluetooth/bluedroid/coex/gattc_gatts_coex/main/gattc_gatts_coex.c b/examples/bluetooth/bluedroid/coex/gattc_gatts_coex/main/gattc_gatts_coex.c index ad95032844..28d63ff75b 100644 --- a/examples/bluetooth/bluedroid/coex/gattc_gatts_coex/main/gattc_gatts_coex.c +++ b/examples/bluetooth/bluedroid/coex/gattc_gatts_coex/main/gattc_gatts_coex.c @@ -307,12 +307,13 @@ static void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param // Initiate GATT connection with the remote device, // If ble physical connection is set up, ESP_GATTS_CONNECT_EVT and ESP_GATTC_CONNECT_EVT event will come - esp_ble_gatt_creat_conn_params_t creat_conn_params; + esp_ble_gatt_creat_conn_params_t creat_conn_params = {0}; memcpy(&creat_conn_params.remote_bda, scan_result->scan_rst.bda, ESP_BD_ADDR_LEN); creat_conn_params.remote_addr_type = scan_result->scan_rst.ble_addr_type; creat_conn_params.own_addr_type = BLE_ADDR_TYPE_PUBLIC; creat_conn_params.is_direct = true; creat_conn_params.is_aux = false; + creat_conn_params.phy_mask = 0x0; esp_ble_gattc_enh_open(gattc_profile_tab[GATTC_PROFILE_C_APP_ID].gattc_if, &creat_conn_params);