From cb8b4df798e33a736fbfe7162faf6dbc6f6a3fe1 Mon Sep 17 00:00:00 2001 From: zhiweijian Date: Mon, 23 Jun 2025 17:33:21 +0800 Subject: [PATCH] feat(ble/bluedroid): Supported BLE bluedroid host pawr connection --- .../core/bluedroid_host/adapter.c | 2 + .../bt/host/bluedroid/api/esp_gattc_api.c | 107 +++++++++++++++++- .../bluedroid/api/include/api/esp_gatt_defs.h | 15 ++- .../bt/host/bluedroid/bta/dm/bta_dm_act.c | 2 +- .../host/bluedroid/bta/gatt/bta_gattc_act.c | 15 ++- .../host/bluedroid/bta/gatt/bta_gattc_api.c | 6 + .../host/bluedroid/bta/gatt/bta_gatts_act.c | 2 +- .../bta/gatt/include/bta_gattc_int.h | 5 + .../bt/host/bluedroid/bta/hh/bta_hh_le.c | 2 +- .../bluedroid/bta/include/bta/bta_gatt_api.h | 1 + .../bt/host/bluedroid/bta/jv/bta_jv_act.c | 2 +- .../btc/profile/std/gatt/btc_gattc.c | 11 +- .../btc/profile/std/include/btc_gattc.h | 3 + .../host/bluedroid/stack/btm/btm_ble_bgconn.c | 2 +- .../bluedroid/stack/btm/include/btm_int.h | 3 + .../bt/host/bluedroid/stack/gap/gap_ble.c | 2 +- .../bt/host/bluedroid/stack/gatt/gatt_api.c | 5 +- .../bt/host/bluedroid/stack/gatt/gatt_attr.c | 14 +-- .../bt/host/bluedroid/stack/gatt/gatt_main.c | 12 +- .../bluedroid/stack/gatt/include/gatt_int.h | 4 +- .../bt/host/bluedroid/stack/hcic/hciblecmds.c | 76 +++++++++++++ .../bluedroid/stack/include/stack/gatt_api.h | 3 +- .../bluedroid/stack/include/stack/hcidefs.h | 1 + .../bluedroid/stack/include/stack/hcimsgs.h | 8 ++ .../bluedroid/stack/include/stack/l2c_api.h | 13 ++- .../bluedroid/stack/l2cap/include/l2c_int.h | 5 + .../bt/host/bluedroid/stack/l2cap/l2c_api.c | 8 +- .../bt/host/bluedroid/stack/l2cap/l2c_ble.c | 20 +++- .../bt/host/bluedroid/stack/smp/smp_api.c | 4 +- 29 files changed, 312 insertions(+), 41 deletions(-) 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 e31d4186e7..a322c0ab86 100644 --- a/components/bt/esp_ble_mesh/core/bluedroid_host/adapter.c +++ b/components/bt/esp_ble_mesh/core/bluedroid_host/adapter.c @@ -1874,6 +1874,7 @@ int bt_mesh_gattc_conn_create(const bt_mesh_addr_t *addr, uint16_t service_uuid) 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, TRUE, BLE_ADDR_UNKNOWN_TYPE, + false, 0xFF, 0xFF, BTA_BLE_PHY_1M_MASK, &conn_1m_param, NULL, NULL); #else /* CONFIG_BLE_MESH_USE_BLE_50 */ /* Min_interval: 15ms @@ -1889,6 +1890,7 @@ int bt_mesh_gattc_conn_create(const bt_mesh_addr_t *addr, uint16_t service_uuid) 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, + false, 0xFF, 0xFF, BTA_BLE_PHY_1M_MASK, &conn_1m_param, NULL, NULL); #endif /* CONFIG_BLE_MESH_USE_BLE_50 */ diff --git a/components/bt/host/bluedroid/api/esp_gattc_api.c b/components/bt/host/bluedroid/api/esp_gattc_api.c index 83481a85c6..e483e05123 100644 --- a/components/bt/host/bluedroid/api/esp_gattc_api.c +++ b/components/bt/host/bluedroid/api/esp_gattc_api.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -88,6 +88,11 @@ esp_err_t esp_ble_gattc_enh_open(esp_gatt_if_t gattc_if, esp_ble_gatt_creat_conn arg.open.remote_addr_type = creat_conn_params->remote_addr_type; arg.open.is_direct = creat_conn_params->is_direct; arg.open.is_aux= creat_conn_params->is_aux; +#if (BT_BLE_FEAT_PAWR_EN == TRUE) + arg.open.is_pawr_synced = false; + arg.open.adv_handle = 0xFF; + arg.open.subevent = 0xFF; +#endif // (BT_BLE_FEAT_PAWR_EN == TRUE) arg.open.own_addr_type = creat_conn_params->own_addr_type; arg.open.phy_mask = creat_conn_params->phy_mask; @@ -198,6 +203,106 @@ esp_err_t esp_ble_gattc_aux_open(esp_gatt_if_t gattc_if, esp_bd_addr_t remote_bd } #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) +#if (BT_BLE_FEAT_PAWR_EN == TRUE) +esp_err_t esp_ble_gattc_aux_open_with_pawr_synced(esp_gatt_if_t gattc_if, esp_ble_gatt_pawr_conn_params_t *pawr_conn_params) +{ + 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 (!pawr_conn_params) { + return ESP_ERR_INVALID_ARG; + } + + msg.sig = BTC_SIG_API_CALL; + msg.pid = BTC_PID_GATTC; + msg.act = BTC_GATTC_ACT_OPEN; + arg.open.gattc_if = gattc_if; + memcpy(arg.open.remote_bda, pawr_conn_params->remote_bda, ESP_BD_ADDR_LEN); + arg.open.remote_addr_type = pawr_conn_params->remote_addr_type; + arg.open.is_direct = true; + arg.open.is_aux = true; + arg.open.is_pawr_synced = true; + arg.open.adv_handle = pawr_conn_params->adv_handle; + arg.open.subevent = pawr_conn_params->subevent; + arg.open.own_addr_type = pawr_conn_params->own_addr_type; + arg.open.phy_mask = pawr_conn_params->phy_mask; + + if (pawr_conn_params->phy_mask & ESP_BLE_PHY_1M_PREF_MASK) { + if (!pawr_conn_params->phy_1m_conn_params) { + return ESP_ERR_INVALID_ARG; + } + + conn_params = pawr_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 (pawr_conn_params->phy_mask & ESP_BLE_PHY_2M_PREF_MASK) { + if (!pawr_conn_params->phy_2m_conn_params) { + return ESP_ERR_INVALID_ARG; + } + + conn_params = pawr_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 (pawr_conn_params->phy_mask & ESP_BLE_PHY_CODED_PREF_MASK) { + if (!pawr_conn_params->phy_coded_conn_params) { + return ESP_ERR_INVALID_ARG; + } + + conn_params = pawr_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); +} +#endif // #if (BT_BLE_FEAT_PAWR_EN == TRUE) + esp_err_t esp_ble_gattc_close (esp_gatt_if_t gattc_if, uint16_t conn_id) { btc_msg_t msg = {0}; 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 e8cc134ca7..dcbfe2f6eb 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 @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -695,6 +695,19 @@ typedef struct { const esp_ble_conn_params_t *phy_coded_conn_params; /*!< Connection parameters for the LE Coded PHY */ } esp_ble_gatt_creat_conn_params_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 */ + 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. */ + uint8_t adv_handle; /*!< Advertising_Handle identifying the periodic advertising train. Range: 0x00 to 0xEF or 0xFF */ + uint8_t subevent; /*!< Subevent where the connection request is to be sent. Range: 0x00 to 0x7F or 0xFF */ + 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_pawr_conn_params_t; + #ifdef __cplusplus } #endif 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 61cf413af4..ab17a88b12 100644 --- a/components/bt/host/bluedroid/bta/dm/bta_dm_act.c +++ b/components/bt/host/bluedroid/bta/dm/bta_dm_act.c @@ -6961,7 +6961,7 @@ void btm_dm_start_gatt_discovery (BD_ADDR bd_addr) } 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, 0, NULL, NULL, NULL); + BTA_GATT_TRANSPORT_LE, FALSE, BLE_ADDR_UNKNOWN_TYPE, false, 0xFF, 0xFF, 0, NULL, NULL, NULL); } } 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 06c565dc2d..c85c00c3fb 100644 --- a/components/bt/host/bluedroid/bta/gatt/bta_gattc_act.c +++ b/components/bt/host/bluedroid/bta/gatt/bta_gattc_act.c @@ -511,6 +511,10 @@ void bta_gattc_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data) tGATT_TCB *p_tcb; tBTM_SEC_DEV_REC *p_dev_rec = NULL; + BOOLEAN is_pawr_synced = FALSE; + UINT8 adv_handle = 0xFF; + UINT8 subevent = 0xFF; + if (!p_clcb || !p_data) { return; } @@ -545,10 +549,15 @@ void bta_gattc_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data) APPL_TRACE_ERROR("Unknown Device, setting rejected"); } } - +#if (BT_BLE_FEAT_PAWR_EN == TRUE) + is_pawr_synced = p_data->api_conn.is_pawr_synced; + adv_handle = p_data->api_conn.adv_handle; + subevent = p_data->api_conn.subevent; +#endif // (BT_BLE_FEAT_PAWR_EN == TRUE) /* 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)) { + TRUE, p_data->api_conn.transport, p_data->api_conn.is_aux, is_pawr_synced, + adv_handle, subevent)) { APPL_TRACE_ERROR("Connection open failure"); bta_gattc_sm_execute(p_clcb, BTA_GATTC_INT_OPEN_FAIL_EVT, p_data); @@ -585,7 +594,7 @@ void bta_gattc_init_bk_conn(tBTA_GATTC_API_OPEN *p_data, tBTA_GATTC_RCB *p_clreg /* always call open to hold a connection */ if (!GATT_Connect(p_data->client_if, p_data->remote_bda, p_data->remote_addr_type, FALSE, - p_data->transport, p_data->is_aux)) { + p_data->transport, p_data->is_aux, FALSE, 0xFF, 0xFF)) { #if (!CONFIG_BT_STACK_NO_LOG) uint8_t *bda = (uint8_t *)p_data->remote_bda; #endif 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 8ac0ec4c96..69738647ba 100644 --- a/components/bt/host/bluedroid/bta/gatt/bta_gattc_api.c +++ b/components/bt/host/bluedroid/bta/gatt/bta_gattc_api.c @@ -144,6 +144,7 @@ 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_pawr_synced, UINT8 adv_handle, UINT8 subevent, 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) { @@ -156,6 +157,11 @@ void BTA_GATTC_Enh_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, tBTA_ADDR_T p_buf->is_direct = is_direct; p_buf->transport = transport; p_buf->is_aux = is_aux; +#if (BT_BLE_FEAT_PAWR_EN == TRUE) + p_buf->is_pawr_synced = is_pawr_synced; + p_buf->adv_handle = adv_handle; + p_buf->subevent = subevent; +#endif // (BT_BLE_FEAT_PAWR_EN == TRUE) p_buf->remote_addr_type = remote_addr_type; p_buf->own_addr_type = own_addr_type; p_buf->phy_mask = phy_mask; diff --git a/components/bt/host/bluedroid/bta/gatt/bta_gatts_act.c b/components/bt/host/bluedroid/bta/gatt/bta_gatts_act.c index 692c59c660..37c9a67527 100644 --- a/components/bt/host/bluedroid/bta/gatt/bta_gatts_act.c +++ b/components/bt/host/bluedroid/bta/gatt/bta_gatts_act.c @@ -757,7 +757,7 @@ void bta_gatts_open (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg) if ((p_rcb = bta_gatts_find_app_rcb_by_app_if(p_msg->api_open.server_if)) != NULL) { /* should always get the connection ID */ if (GATT_Connect(p_rcb->gatt_if, p_msg->api_open.remote_bda, BLE_ADDR_UNKNOWN_TYPE, - p_msg->api_open.is_direct, p_msg->api_open.transport, FALSE)) { + p_msg->api_open.is_direct, p_msg->api_open.transport, FALSE, FALSE, 0xFF, 0xFF)) { status = BTA_GATT_OK; if (GATT_GetConnIdIfConnected(p_rcb->gatt_if, p_msg->api_open.remote_bda, 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 cb877fcfc2..ac42de6973 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 @@ -130,6 +130,11 @@ typedef struct { tBTA_GATTC_IF client_if; BOOLEAN is_direct; BOOLEAN is_aux; +#if (BT_BLE_FEAT_PAWR_EN == TRUE) + BOOLEAN is_pawr_synced; + UINT8 adv_handle; + UINT8 subevent; +#endif // (BT_BLE_FEAT_PAWR_EN == TRUE) tBTA_TRANSPORT transport; tBTA_ADDR_TYPE own_addr_type; UINT8 phy_mask; 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 f5697dff52..ae150a3c94 100644 --- a/components/bt/host/bluedroid/bta/hh/bta_hh_le.c +++ b/components/bt/host/bluedroid/bta/hh/bta_hh_le.c @@ -2603,7 +2603,7 @@ static void bta_hh_le_add_dev_bg_conn(tBTA_HH_DEV_CB *p_cb, BOOLEAN check_bond) !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, 0, NULL, NULL); + BTA_GATT_TRANSPORT_LE, FALSE, BLE_ADDR_UNKNOWN_TYPE, false, 0xFF, 0xFF, 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 0208edd954..7c2a4c154c 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 @@ -819,6 +819,7 @@ 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_pawr_synced, UINT8 adv_handle, UINT8 subevent, 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/bta/jv/bta_jv_act.c b/components/bt/host/bluedroid/bta/jv/bta_jv_act.c index 17eba5edd6..88bd0eb842 100644 --- a/components/bt/host/bluedroid/bta/jv/bta_jv_act.c +++ b/components/bt/host/bluedroid/bta/jv/bta_jv_act.c @@ -2923,7 +2923,7 @@ void bta_jv_l2cap_connect_le(tBTA_JV_MSG *p_data) id = t->id; t->init_called = FALSE; - if (L2CA_ConnectFixedChnl(t->chan, t->remote_addr, BLE_ADDR_UNKNOWN_TYPE, FALSE)) { + if (L2CA_ConnectFixedChnl(t->chan, t->remote_addr, BLE_ADDR_UNKNOWN_TYPE, FALSE, FALSE, 0xFF, 0xFF)) { evt.l2c_cl_init.status = BTA_JV_SUCCESS; evt.l2c_cl_init.handle = id; 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 e8f7444368..9928a7ab2e 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 @@ -213,12 +213,21 @@ 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; - +#if (BT_BLE_FEAT_PAWR_EN == TRUE) + 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, + arg->open.is_pawr_synced, arg->open.adv_handle, arg->open.subevent, + 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); +#else 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, + false, 0xff, 0xff, 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); +#endif // (BT_BLE_FEAT_PAWR_EN == TRUE) } 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 1c8ef828b0..7580b7f17c 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,9 @@ typedef union { bool is_direct; bool is_aux; esp_ble_addr_type_t own_addr_type; + bool is_pawr_synced; + uint8_t adv_handle; + uint8_t subevent; 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; diff --git a/components/bt/host/bluedroid/stack/btm/btm_ble_bgconn.c b/components/bt/host/bluedroid/stack/btm/btm_ble_bgconn.c index 1210a26458..b418bd70f7 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_ble_bgconn.c +++ b/components/bt/host/bluedroid/stack/btm/btm_ble_bgconn.c @@ -671,7 +671,7 @@ void btm_ble_initiate_select_conn(BD_ADDR bda) BTM_TRACE_EVENT ("btm_ble_initiate_select_conn"); /* use direct connection procedure to initiate connection */ - if (!L2CA_ConnectFixedChnl(L2CAP_ATT_CID, bda, BLE_ADDR_UNKNOWN_TYPE, FALSE)) { + if (!L2CA_ConnectFixedChnl(L2CAP_ATT_CID, bda, BLE_ADDR_UNKNOWN_TYPE, FALSE, FALSE, 0xFF, 0xFF)) { BTM_TRACE_ERROR("btm_ble_initiate_select_conn failed"); } } diff --git a/components/bt/host/bluedroid/stack/btm/include/btm_int.h b/components/bt/host/bluedroid/stack/btm/include/btm_int.h index d5b69c6818..e23b086368 100644 --- a/components/bt/host/bluedroid/stack/btm/include/btm_int.h +++ b/components/bt/host/bluedroid/stack/btm/include/btm_int.h @@ -702,6 +702,9 @@ struct tBTM_SEC_DEV_REC{ #if (BLE_50_FEATURE_SUPPORT == TRUE) tBTM_EXT_CONN_PARAMS ext_conn_params; #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) + BOOLEAN is_pawr_synced; + UINT8 adv_handle; + UINT8 subevent; #endif // btla-specific ++ diff --git a/components/bt/host/bluedroid/stack/gap/gap_ble.c b/components/bt/host/bluedroid/stack/gap/gap_ble.c index e3549fbbb7..e295cfe7be 100644 --- a/components/bt/host/bluedroid/stack/gap/gap_ble.c +++ b/components/bt/host/bluedroid/stack/gap/gap_ble.c @@ -751,7 +751,7 @@ BOOLEAN gap_ble_accept_cl_operation(BD_ADDR peer_bda, UINT16 uuid, tGAP_BLE_CMPL } /* hold the link here */ - if (!GATT_Connect(gap_cb.gatt_if, p_clcb->bda, BLE_ADDR_UNKNOWN_TYPE, TRUE, BT_TRANSPORT_LE, FALSE)) { + if (!GATT_Connect(gap_cb.gatt_if, p_clcb->bda, BLE_ADDR_UNKNOWN_TYPE, TRUE, BT_TRANSPORT_LE, FALSE, FALSE, 0xFF, 0xFF)) { return started; } diff --git a/components/bt/host/bluedroid/stack/gatt/gatt_api.c b/components/bt/host/bluedroid/stack/gatt/gatt_api.c index 51e46e2274..db7952e95a 100644 --- a/components/bt/host/bluedroid/stack/gatt/gatt_api.c +++ b/components/bt/host/bluedroid/stack/gatt/gatt_api.c @@ -1453,7 +1453,8 @@ void GATT_StartIf (tGATT_IF gatt_if) ** *******************************************************************************/ BOOLEAN GATT_Connect (tGATT_IF gatt_if, BD_ADDR bd_addr, tBLE_ADDR_TYPE bd_addr_type, - BOOLEAN is_direct, tBT_TRANSPORT transport, BOOLEAN is_aux) + BOOLEAN is_direct, tBT_TRANSPORT transport, BOOLEAN is_aux, + BOOLEAN is_pawr_synced, UINT8 adv_handle, UINT8 subevent) { tGATT_REG *p_reg; BOOLEAN status = FALSE; @@ -1467,7 +1468,7 @@ BOOLEAN GATT_Connect (tGATT_IF gatt_if, BD_ADDR bd_addr, tBLE_ADDR_TYPE bd_addr_ } if (is_direct) { - status = gatt_act_connect (p_reg, bd_addr, bd_addr_type, transport, is_aux); + status = gatt_act_connect (p_reg, bd_addr, bd_addr_type, transport, is_aux, is_pawr_synced, adv_handle, subevent); } else { #if (tGATT_BG_CONN_DEV == TRUE) if (transport == BT_TRANSPORT_LE) { diff --git a/components/bt/host/bluedroid/stack/gatt/gatt_attr.c b/components/bt/host/bluedroid/stack/gatt/gatt_attr.c index 3ab573426a..27e80d605d 100644 --- a/components/bt/host/bluedroid/stack/gatt/gatt_attr.c +++ b/components/bt/host/bluedroid/stack/gatt/gatt_attr.c @@ -98,7 +98,7 @@ UINT16 gatt_profile_find_conn_id_by_bd_addr(BD_ADDR remote_bda) ** ** Description find clcb by Connection ID ** -** Returns Pointer to the found link conenction control block. +** Returns Pointer to the found link connection control block. ** *******************************************************************************/ static tGATT_PROFILE_CLCB *gatt_profile_find_clcb_by_conn_id(UINT16 conn_id) @@ -119,9 +119,9 @@ static tGATT_PROFILE_CLCB *gatt_profile_find_clcb_by_conn_id(UINT16 conn_id) ** ** Function gatt_profile_find_clcb_by_bd_addr ** -** Description The function searches all LCBs with macthing bd address. +** Description The function searches all LCBs with matching bd address. ** -** Returns Pointer to the found link conenction control block. +** Returns Pointer to the found link connection control block. ** *******************************************************************************/ static tGATT_PROFILE_CLCB *gatt_profile_find_clcb_by_bd_addr(BD_ADDR bda, tBT_TRANSPORT transport) @@ -148,7 +148,7 @@ static tGATT_PROFILE_CLCB *gatt_profile_find_clcb_by_bd_addr(BD_ADDR bda, tBT_TR ** Returns NULL if not found. Otherwise pointer to the connection link block. ** *******************************************************************************/ -tGATT_PROFILE_CLCB *gatt_profile_clcb_alloc (UINT16 conn_id, BD_ADDR bda, tBT_TRANSPORT tranport) +tGATT_PROFILE_CLCB *gatt_profile_clcb_alloc (UINT16 conn_id, BD_ADDR bda, tBT_TRANSPORT transport) { UINT8 i_clcb = 0; tGATT_PROFILE_CLCB *p_clcb = NULL; @@ -158,7 +158,7 @@ tGATT_PROFILE_CLCB *gatt_profile_clcb_alloc (UINT16 conn_id, BD_ADDR bda, tBT_TR p_clcb->in_use = TRUE; p_clcb->conn_id = conn_id; p_clcb->connected = TRUE; - p_clcb->transport = tranport; + p_clcb->transport = transport; memcpy (p_clcb->bda, bda, BD_ADDR_LEN); break; } @@ -435,7 +435,7 @@ static void gatt_connect_cback (tGATT_IF gatt_if, BD_ADDR bda, UINT16 conn_id, ** ** Function gatt_profile_db_init ** -** Description Initializa the GATT profile attribute database. +** Description Initialize the GATT profile attribute database. ** *******************************************************************************/ void gatt_profile_db_init (void) @@ -684,7 +684,7 @@ void GATT_ConfigServiceChangeCCC (BD_ADDR remote_bda, BOOLEAN enable, tBT_TRANSP p_clcb->connected = TRUE; } /* hold the link here */ - GATT_Connect(gatt_cb.gatt_if, remote_bda, BLE_ADDR_UNKNOWN_TYPE, TRUE, transport, FALSE); + GATT_Connect(gatt_cb.gatt_if, remote_bda, BLE_ADDR_UNKNOWN_TYPE, TRUE, transport, FALSE, FALSE, 0xFF, 0xFF); p_clcb->ccc_stage = GATT_SVC_CHANGED_CONNECTING; if (!p_clcb->connected) { diff --git a/components/bt/host/bluedroid/stack/gatt/gatt_main.c b/components/bt/host/bluedroid/stack/gatt/gatt_main.c index 0783255d0b..f92a2c392b 100644 --- a/components/bt/host/bluedroid/stack/gatt/gatt_main.c +++ b/components/bt/host/bluedroid/stack/gatt/gatt_main.c @@ -220,7 +220,8 @@ void gatt_free(void) ** Returns TRUE if connection is started, otherwise return FALSE. ** *******************************************************************************/ -BOOLEAN gatt_connect (BD_ADDR rem_bda, tBLE_ADDR_TYPE bd_addr_type, tGATT_TCB *p_tcb, tBT_TRANSPORT transport, BOOLEAN is_aux) +BOOLEAN gatt_connect (BD_ADDR rem_bda, tBLE_ADDR_TYPE bd_addr_type, tGATT_TCB *p_tcb, tBT_TRANSPORT transport, BOOLEAN is_aux, + BOOLEAN is_pawr_synced, UINT8 adv_handle, UINT8 subevent) { BOOLEAN gatt_ret = FALSE; @@ -230,7 +231,7 @@ BOOLEAN gatt_connect (BD_ADDR rem_bda, tBLE_ADDR_TYPE bd_addr_type, tGATT_TCB *p if (transport == BT_TRANSPORT_LE) { p_tcb->att_lcid = L2CAP_ATT_CID; - gatt_ret = L2CA_ConnectFixedChnl (L2CAP_ATT_CID, rem_bda, bd_addr_type, is_aux); + gatt_ret = L2CA_ConnectFixedChnl (L2CAP_ATT_CID, rem_bda, bd_addr_type, is_aux, is_pawr_synced, adv_handle, subevent); #if (CLASSIC_BT_GATT_INCLUDED == TRUE) } else { if ((p_tcb->att_lcid = L2CA_ConnectReq(BT_PSM_ATT, rem_bda)) != 0) { @@ -376,7 +377,8 @@ void gatt_update_app_use_link_flag (tGATT_IF gatt_if, tGATT_TCB *p_tcb, BOOLEAN ** *******************************************************************************/ BOOLEAN gatt_act_connect (tGATT_REG *p_reg, BD_ADDR bd_addr, - tBLE_ADDR_TYPE bd_addr_type, tBT_TRANSPORT transport, BOOLEAN is_aux) + tBLE_ADDR_TYPE bd_addr_type, tBT_TRANSPORT transport, BOOLEAN is_aux, + BOOLEAN is_pawr_synced, UINT8 adv_handle, UINT8 subevent) { BOOLEAN ret = FALSE; tGATT_TCB *p_tcb; @@ -389,7 +391,7 @@ BOOLEAN gatt_act_connect (tGATT_REG *p_reg, BD_ADDR bd_addr, /* before link down, another app try to open a GATT connection */ if (st == GATT_CH_OPEN && gatt_num_apps_hold_link(p_tcb) == 0 && transport == BT_TRANSPORT_LE ) { - if (!gatt_connect(bd_addr, bd_addr_type, p_tcb, transport, is_aux)) { + if (!gatt_connect(bd_addr, bd_addr_type, p_tcb, transport, is_aux, is_pawr_synced, adv_handle, subevent)) { ret = FALSE; } } else if (st == GATT_CH_CLOSING) { @@ -400,7 +402,7 @@ BOOLEAN gatt_act_connect (tGATT_REG *p_reg, BD_ADDR bd_addr, } } else { if ((p_tcb = gatt_allocate_tcb_by_bdaddr(bd_addr, transport)) != NULL) { - if (!gatt_connect(bd_addr, bd_addr_type, p_tcb, transport, is_aux)) { + if (!gatt_connect(bd_addr, bd_addr_type, p_tcb, transport, is_aux, is_pawr_synced, adv_handle, subevent)) { GATT_TRACE_ERROR("gatt_connect failed"); // code enter here if create connection failed. if disconnect after connection, code will not enter here diff --git a/components/bt/host/bluedroid/stack/gatt/include/gatt_int.h b/components/bt/host/bluedroid/stack/gatt/include/gatt_int.h index f00bed7e8b..8701c746d1 100644 --- a/components/bt/host/bluedroid/stack/gatt/include/gatt_int.h +++ b/components/bt/host/bluedroid/stack/gatt/include/gatt_int.h @@ -600,8 +600,8 @@ extern void gatt_free(void); /* from gatt_main.c */ extern BOOLEAN gatt_disconnect (tGATT_TCB *p_tcb); -extern BOOLEAN gatt_act_connect (tGATT_REG *p_reg, BD_ADDR bd_addr, tBLE_ADDR_TYPE bd_addr_type, tBT_TRANSPORT transport, BOOLEAN is_aux); -extern BOOLEAN gatt_connect (BD_ADDR rem_bda, tBLE_ADDR_TYPE bd_addr_type, tGATT_TCB *p_tcb, tBT_TRANSPORT transport, BOOLEAN is_aux); +extern BOOLEAN gatt_act_connect (tGATT_REG *p_reg, BD_ADDR bd_addr, tBLE_ADDR_TYPE bd_addr_type, tBT_TRANSPORT transport, BOOLEAN is_aux, BOOLEAN is_pawr_synced, UINT8 adv_handle, UINT8 subevent); +extern BOOLEAN gatt_connect (BD_ADDR rem_bda, tBLE_ADDR_TYPE bd_addr_type, tGATT_TCB *p_tcb, tBT_TRANSPORT transport, BOOLEAN is_aux, BOOLEAN is_pawr_synced, UINT8 adv_handle, UINT8 subevent); extern void gatt_data_process (tGATT_TCB *p_tcb, BT_HDR *p_buf); extern void gatt_update_app_use_link_flag ( tGATT_IF gatt_if, tGATT_TCB *p_tcb, BOOLEAN is_add, BOOLEAN check_acl_link); diff --git a/components/bt/host/bluedroid/stack/hcic/hciblecmds.c b/components/bt/host/bluedroid/stack/hcic/hciblecmds.c index 2a474b3d0b..0e88952115 100644 --- a/components/bt/host/bluedroid/stack/hcic/hciblecmds.c +++ b/components/bt/host/bluedroid/stack/hcic/hciblecmds.c @@ -1703,6 +1703,82 @@ BOOLEAN btsnd_hcic_ble_create_ext_conn(tHCI_CreatExtConn *p_conn) } +#if (BT_BLE_FEAT_PAWR_EN == TRUE) +BOOLEAN btsnd_hcic_ble_create_ext_conn_v2(tHCI_CreatExtConn *p_conn) +{ + BT_HDR *p; + UINT8 *pp; + tHCI_ExtConnParams *params; + HCI_TRACE_EVENT("%s", __func__); + uint8_t size = HCIC_PARAM_SIZE_EXT_CONN_CREATE_BASE + 2; + + if (p_conn->init_phy_mask & 0x01) { + size += sizeof(tHCI_ExtConnParams); + } + + if (p_conn->init_phy_mask & 0x02) { + size += sizeof(tHCI_ExtConnParams); + } + + if (p_conn->init_phy_mask & 0x04) { + size += sizeof(tHCI_ExtConnParams); + } + + HCIC_BLE_CMD_CREATED(p, pp, size); + + UINT16_TO_STREAM(pp, HCI_BLE_EXT_CREATE_CONN_V2); + UINT8_TO_STREAM(pp, size); + UINT8_TO_STREAM(pp, p_conn->adv_handle); + UINT8_TO_STREAM(pp, p_conn->subevent); + UINT8_TO_STREAM(pp, p_conn->filter_policy); + UINT8_TO_STREAM(pp, p_conn->filter_policy); + UINT8_TO_STREAM(pp, p_conn->own_addr_type); + UINT8_TO_STREAM(pp, p_conn->peer_addr_type); + BDADDR_TO_STREAM(pp, p_conn->peer_addr); + UINT8_TO_STREAM(pp, p_conn->init_phy_mask); + + if (p_conn->init_phy_mask & 0x01) { + params = &p_conn->params[0]; + UINT16_TO_STREAM(pp, params->scan_interval); + UINT16_TO_STREAM(pp, params->scan_window); + UINT16_TO_STREAM(pp, params->conn_interval_min); + 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, 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) { + params = &p_conn->params[1]; + UINT16_TO_STREAM(pp, params->scan_interval); + UINT16_TO_STREAM(pp, params->scan_window); + UINT16_TO_STREAM(pp, params->conn_interval_min); + 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, 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) { + params = &p_conn->params[2]; + UINT16_TO_STREAM(pp, params->scan_interval); + UINT16_TO_STREAM(pp, params->scan_window); + UINT16_TO_STREAM(pp, params->conn_interval_min); + 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, 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); + return TRUE; + +} +#endif // (BT_BLE_FEAT_PAWR_EN == TRUE) + #if (BLE_50_EXTEND_SYNC_EN == TRUE) BOOLEAN btsnd_hcic_ble_periodic_adv_create_sync(UINT8 option, UINT8 adv_sid, UINT8 adv_addr_type, BD_ADDR adv_addr, diff --git a/components/bt/host/bluedroid/stack/include/stack/gatt_api.h b/components/bt/host/bluedroid/stack/include/stack/gatt_api.h index 002cb16e33..83667e7724 100644 --- a/components/bt/host/bluedroid/stack/include/stack/gatt_api.h +++ b/components/bt/host/bluedroid/stack/include/stack/gatt_api.h @@ -1140,7 +1140,8 @@ extern void GATT_StartIf (tGATT_IF gatt_if); ** *******************************************************************************/ extern BOOLEAN GATT_Connect (tGATT_IF gatt_if, BD_ADDR bd_addr, tBLE_ADDR_TYPE bd_addr_type, - BOOLEAN is_direct, tBT_TRANSPORT transport, BOOLEAN is_aux); + BOOLEAN is_direct, tBT_TRANSPORT transport, BOOLEAN is_aux, + BOOLEAN is_pawr_synced, UINT8 adv_handle, UINT8 subevent); /******************************************************************************* diff --git a/components/bt/host/bluedroid/stack/include/stack/hcidefs.h b/components/bt/host/bluedroid/stack/include/stack/hcidefs.h index a539b3e69d..8621b67458 100644 --- a/components/bt/host/bluedroid/stack/include/stack/hcidefs.h +++ b/components/bt/host/bluedroid/stack/include/stack/hcidefs.h @@ -451,6 +451,7 @@ #define HCI_BLE_SET_PERIOD_ADV_SUBEVT_DATA (0x0082 | HCI_GRP_BLE_CMDS) #define HCI_BLE_SET_PERIOD_ADV_RSP_DATA (0x0083 | HCI_GRP_BLE_CMDS) #define HCI_BLE_SET_PERIOD_SYNC_SUBEVT (0x0084 | HCI_GRP_BLE_CMDS) +#define HCI_BLE_EXT_CREATE_CONN_V2 (0x0085 | HCI_GRP_BLE_CMDS) #define HCI_BLE_SET_PERIOD_ADV_PARAMS_V2 (0x0086 | HCI_GRP_BLE_CMDS) #endif // #if (BT_BLE_FEAT_PAWR_EN == TRUE) diff --git a/components/bt/host/bluedroid/stack/include/stack/hcimsgs.h b/components/bt/host/bluedroid/stack/include/stack/hcimsgs.h index d497ee2592..d0f8e20529 100644 --- a/components/bt/host/bluedroid/stack/include/stack/hcimsgs.h +++ b/components/bt/host/bluedroid/stack/include/stack/hcimsgs.h @@ -947,6 +947,10 @@ typedef struct { } tHCI_ExtConnParams; typedef struct { +#if (BT_BLE_FEAT_PAWR_EN == TRUE) + UINT8 adv_handle; + UINT8 subevent; +#endif // (BT_BLE_FEAT_PAWR_EN == TRUE) UINT8 filter_policy; UINT8 own_addr_type; UINT8 peer_addr_type; @@ -1032,6 +1036,10 @@ UINT8 btsnd_hcic_ble_ext_scan_enable(UINT8 enable, UINT8 filter_dups, BOOLEAN btsnd_hcic_ble_create_ext_conn(tHCI_CreatExtConn *p_conn); +#if (BT_BLE_FEAT_PAWR_EN == TRUE) +BOOLEAN btsnd_hcic_ble_create_ext_conn_v2(tHCI_CreatExtConn *p_conn); +#endif // (BT_BLE_FEAT_PAWR_EN == TRUE) + BOOLEAN btsnd_hcic_ble_periodic_adv_create_sync(UINT8 filter_policy, UINT8 adv_sid, UINT8 adv_addr_type, BD_ADDR adv_addr, UINT16 sync_timeout, UINT8 sync_cte_type); diff --git a/components/bt/host/bluedroid/stack/include/stack/l2c_api.h b/components/bt/host/bluedroid/stack/include/stack/l2c_api.h index b985b641e8..45538ff534 100644 --- a/components/bt/host/bluedroid/stack/include/stack/l2c_api.h +++ b/components/bt/host/bluedroid/stack/include/stack/l2c_api.h @@ -121,7 +121,7 @@ typedef UINT8 tL2CAP_CHNL_DATA_RATE; #define L2CAP_FCR_CHAN_OPT_ALL_MASK (L2CAP_FCR_CHAN_OPT_BASIC | L2CAP_FCR_CHAN_OPT_ERTM | L2CAP_FCR_CHAN_OPT_STREAM) /* Validity check for PSM. PSM values must be odd. Also, all PSM values must -** be assigned such that the least significant bit of the most sigificant +** be assigned such that the least significant bit of the most significant ** octet equals zero. */ #define L2C_INVALID_PSM(psm) (((psm) & 0x0101) != 0x0001) @@ -938,7 +938,7 @@ typedef struct { ** ** Parameters: tL2CAP_UCD_CB_INFO ** -** Return value: TRUE if successs +** Return value: TRUE if success ** *******************************************************************************/ extern BOOLEAN L2CA_UcdRegister ( UINT16 psm, tL2CAP_UCD_CB_INFO *p_cb_info ); @@ -951,7 +951,7 @@ extern BOOLEAN L2CA_UcdRegister ( UINT16 psm, tL2CAP_UCD_CB_INFO *p_cb_info ); ** ** Parameters: PSM ** -** Return value: TRUE if successs +** Return value: TRUE if success ** *******************************************************************************/ extern BOOLEAN L2CA_UcdDeregister ( UINT16 psm ); @@ -968,7 +968,7 @@ extern BOOLEAN L2CA_UcdDeregister ( UINT16 psm ); ** L2CAP_UCD_INFO_TYPE_MTU ** ** -** Return value: TRUE if successs +** Return value: TRUE if success ** *******************************************************************************/ extern BOOLEAN L2CA_UcdDiscover ( UINT16 psm, BD_ADDR rem_bda, UINT8 info_type ); @@ -1001,7 +1001,7 @@ extern UINT16 L2CA_UcdDataWrite (UINT16 psm, BD_ADDR rem_bda, BT_HDR *p_buf, UIN ** Parameters: BD Addr ** Timeout in second ** -** Return value: TRUE if successs +** Return value: TRUE if success ** *******************************************************************************/ extern BOOLEAN L2CA_UcdSetIdleTimeout ( BD_ADDR rem_bda, UINT16 timeout ); @@ -1089,7 +1089,8 @@ extern BOOLEAN L2CA_RegisterFixedChannel (UINT16 fixed_cid, tL2CAP_FIXED_CHNL_R ** Return value: TRUE if connection started ** *******************************************************************************/ -extern BOOLEAN L2CA_ConnectFixedChnl (UINT16 fixed_cid, BD_ADDR bd_addr, tBLE_ADDR_TYPE bd_addr_type, BOOLEAN is_aux); +extern BOOLEAN L2CA_ConnectFixedChnl (UINT16 fixed_cid, BD_ADDR bd_addr, tBLE_ADDR_TYPE bd_addr_type, BOOLEAN is_aux, + BOOLEAN is_pawr_synced, UINT8 adv_handle, UINT8 subevent); /******************************************************************************* ** diff --git a/components/bt/host/bluedroid/stack/l2cap/include/l2c_int.h b/components/bt/host/bluedroid/stack/l2cap/include/l2c_int.h index 88eac86b2f..d17f82f4cc 100644 --- a/components/bt/host/bluedroid/stack/l2cap/include/l2c_int.h +++ b/components/bt/host/bluedroid/stack/l2cap/include/l2c_int.h @@ -379,6 +379,11 @@ typedef struct t_l2c_linkcb { BOOLEAN in_use; /* TRUE when in use, FALSE when not */ tL2C_LINK_STATE link_state; BOOLEAN is_aux; /* This variable used for BLE 5.0 or higher version when do auxiliary connection */ +#if (BT_BLE_FEAT_PAWR_EN == TRUE) + BOOLEAN is_pawr_synced; + UINT8 adv_handle; + UINT8 subevent; +#endif // (BT_BLE_FEAT_PAWR_EN == TRUE) TIMER_LIST_ENT timer_entry; /* Timer list entry for timeout evt */ UINT16 handle; /* The handle used with LM */ diff --git a/components/bt/host/bluedroid/stack/l2cap/l2c_api.c b/components/bt/host/bluedroid/stack/l2cap/l2c_api.c index 3037511831..b7fbbbdcfc 100644 --- a/components/bt/host/bluedroid/stack/l2cap/l2c_api.c +++ b/components/bt/host/bluedroid/stack/l2cap/l2c_api.c @@ -1649,7 +1649,8 @@ BOOLEAN L2CA_RegisterFixedChannel (UINT16 fixed_cid, tL2CAP_FIXED_CHNL_REG *p_f ** Return value: TRUE if connection started ** *******************************************************************************/ -BOOLEAN L2CA_ConnectFixedChnl (UINT16 fixed_cid, BD_ADDR rem_bda, tBLE_ADDR_TYPE bd_addr_type, BOOLEAN is_aux) +BOOLEAN L2CA_ConnectFixedChnl (UINT16 fixed_cid, BD_ADDR rem_bda, tBLE_ADDR_TYPE bd_addr_type, BOOLEAN is_aux, + BOOLEAN is_pawr_synced, UINT8 adv_handle, UINT8 subevent) { tL2C_LCB *p_lcb; tBT_TRANSPORT transport = BT_TRANSPORT_BR_EDR; @@ -1738,6 +1739,11 @@ BOOLEAN L2CA_ConnectFixedChnl (UINT16 fixed_cid, BD_ADDR rem_bda, tBLE_ADDR_TYPE #if (BLE_INCLUDED == TRUE) p_lcb->is_aux = is_aux; p_lcb->open_addr_type = bd_addr_type; +#if (BT_BLE_FEAT_PAWR_EN == TRUE) + p_lcb->is_pawr_synced = is_pawr_synced; + p_lcb->adv_handle = adv_handle; + p_lcb->subevent = subevent; +#endif // (BT_BLE_FEAT_PAWR_EN == TRUE) #endif if (!l2cu_create_conn(p_lcb, transport)) { L2CAP_TRACE_WARNING ("%s() - create_conn failed", __func__); diff --git a/components/bt/host/bluedroid/stack/l2cap/l2c_ble.c b/components/bt/host/bluedroid/stack/l2cap/l2c_ble.c index d3ae413b5f..39ba389451 100644 --- a/components/bt/host/bluedroid/stack/l2cap/l2c_ble.c +++ b/components/bt/host/bluedroid/stack/l2cap/l2c_ble.c @@ -1012,6 +1012,10 @@ BOOLEAN l2cble_init_direct_conn (tL2C_LCB *p_lcb) } tHCI_CreatExtConn aux_conn = {0}; +#if (BT_BLE_FEAT_PAWR_EN == TRUE) + aux_conn.adv_handle = p_lcb->adv_handle; + aux_conn.subevent = p_lcb->subevent; +#endif // (BT_BLE_FEAT_PAWR_EN == TRUE) aux_conn.filter_policy = FALSE; aux_conn.own_addr_type = own_addr_type; aux_conn.peer_addr_type = peer_addr_type; @@ -1033,9 +1037,19 @@ BOOLEAN l2cble_init_direct_conn (tL2C_LCB *p_lcb) memcpy (l2cb.ble_connecting_bda, p_lcb->remote_bd_addr, BD_ADDR_LEN); btu_start_timer (&p_lcb->timer_entry, BTU_TTYPE_L2CAP_LINK, link_timeout); btm_ble_set_conn_st (BLE_DIR_CONN); - if(!btsnd_hcic_ble_create_ext_conn(&aux_conn)) { - l2cu_release_lcb (p_lcb); - L2CAP_TRACE_ERROR("initiate Aux connection failed, no resources"); +#if (BT_BLE_FEAT_PAWR_EN == TRUE) + if (p_lcb->is_pawr_synced) { + if(!btsnd_hcic_ble_create_ext_conn_v2(&aux_conn)) { + l2cu_release_lcb (p_lcb); + L2CAP_TRACE_ERROR("initiate pawr sync connection failed, no resources"); + } + } else +#endif // (BT_BLE_FEAT_PAWR_EN == TRUE) + { + if(!btsnd_hcic_ble_create_ext_conn(&aux_conn)) { + l2cu_release_lcb (p_lcb); + L2CAP_TRACE_ERROR("initiate Aux connection failed, no resources"); + } } #else L2CAP_TRACE_ERROR("BLE 5.0 not support!\n"); diff --git a/components/bt/host/bluedroid/stack/smp/smp_api.c b/components/bt/host/bluedroid/stack/smp/smp_api.c index 28c4761413..4ae836e0a9 100644 --- a/components/bt/host/bluedroid/stack/smp/smp_api.c +++ b/components/bt/host/bluedroid/stack/smp/smp_api.c @@ -161,7 +161,7 @@ tSMP_STATUS SMP_Pair (BD_ADDR bd_addr) memcpy (p_cb->pairing_bda, bd_addr, BD_ADDR_LEN); - if (!L2CA_ConnectFixedChnl (L2CAP_SMP_CID, bd_addr, BLE_ADDR_UNKNOWN_TYPE, FALSE)) { + if (!L2CA_ConnectFixedChnl (L2CAP_SMP_CID, bd_addr, BLE_ADDR_UNKNOWN_TYPE, FALSE, FALSE, 0xFF, 0xFF)) { SMP_TRACE_ERROR("%s: L2C connect fixed channel failed.\n", __FUNCTION__); smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &status); return status; @@ -205,7 +205,7 @@ tSMP_STATUS SMP_BR_PairWith (BD_ADDR bd_addr) memcpy (p_cb->pairing_bda, bd_addr, BD_ADDR_LEN); - if (!L2CA_ConnectFixedChnl (L2CAP_SMP_BR_CID, bd_addr, BLE_ADDR_UNKNOWN_TYPE, FALSE)) { + if (!L2CA_ConnectFixedChnl (L2CAP_SMP_BR_CID, bd_addr, BLE_ADDR_UNKNOWN_TYPE, FALSE, FALSE, 0xFF, 0xFF)) { SMP_TRACE_ERROR("%s: L2C connect fixed channel failed.", __FUNCTION__); smp_br_state_machine_event(p_cb, SMP_BR_AUTH_CMPL_EVT, &status); return status;