mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 11:10:54 +03:00
fix(ble/bluedroid): Fixed reconnection failed with extend adv
(cherry picked from commit ec4052c1c7)
Co-authored-by: zhiweijian <zhiweijian@espressif.com>
This commit is contained in:
@@ -377,6 +377,9 @@ BOOLEAN l2c_link_hci_disc_comp (UINT16 handle, UINT8 reason)
|
|||||||
#endif ///BLE_INCLUDED == TRUE
|
#endif ///BLE_INCLUDED == TRUE
|
||||||
status = FALSE;
|
status = FALSE;
|
||||||
} else {
|
} else {
|
||||||
|
#if (BLE_INCLUDED == TRUE)
|
||||||
|
tL2C_LINK_STATE link_state_temp = p_lcb->link_state;
|
||||||
|
#endif // (BLE_INCLUDED == TRUE)
|
||||||
/* There can be a case when we rejected PIN code authentication */
|
/* There can be a case when we rejected PIN code authentication */
|
||||||
/* otherwise save a new reason */
|
/* otherwise save a new reason */
|
||||||
if (btm_cb.acl_disc_reason != HCI_ERR_HOST_REJECT_SECURITY) {
|
if (btm_cb.acl_disc_reason != HCI_ERR_HOST_REJECT_SECURITY) {
|
||||||
@@ -471,7 +474,25 @@ BOOLEAN l2c_link_hci_disc_comp (UINT16 handle, UINT8 reason)
|
|||||||
|
|
||||||
p_lcb->p_pending_ccb = NULL;
|
p_lcb->p_pending_ccb = NULL;
|
||||||
#if (BLE_INCLUDED == TRUE)
|
#if (BLE_INCLUDED == TRUE)
|
||||||
if(reason == HCI_ERR_CONN_FAILED_ESTABLISHMENT && p_lcb->transport == BT_TRANSPORT_LE) {
|
if(p_lcb->transport == BT_TRANSPORT_LE) {
|
||||||
|
// for legacy adv, adv restart in gatt_le_connect_cback->gatt_cleanup_upon_disc->BTM_Recovery_Pre_State
|
||||||
|
if (reason == HCI_ERR_CONN_FAILED_ESTABLISHMENT) {
|
||||||
|
|
||||||
|
#if (BLE_42_FEATURE_SUPPORT == TRUE)
|
||||||
|
#if (BLE_42_ADV_EN == TRUE)
|
||||||
|
if(!btm_ble_inter_get() && p_lcb->link_role == HCI_ROLE_SLAVE) {
|
||||||
|
L2CAP_TRACE_DEBUG("slave resatrt adv, retry count %d reason 0x%x\n", p_lcb->retry_create_con, reason);
|
||||||
|
tBTM_STATUS start_adv_status = btm_ble_start_adv();
|
||||||
|
if (start_adv_status != BTM_SUCCESS) {
|
||||||
|
L2CAP_TRACE_ERROR("slave resatrt adv failed (err 0x%x)", start_adv_status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif // #if (BLE_42_ADV_EN == TRUE)
|
||||||
|
#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)
|
||||||
|
}
|
||||||
|
// try to reconnect for master
|
||||||
|
if ((reason == HCI_ERR_CONN_FAILED_ESTABLISHMENT) || (link_state_temp == LST_CONNECTING)) {
|
||||||
|
|
||||||
#if (GATTC_CONNECT_RETRY_EN == TRUE)
|
#if (GATTC_CONNECT_RETRY_EN == TRUE)
|
||||||
if(p_lcb->link_role == HCI_ROLE_MASTER && p_lcb->retry_create_con < GATTC_CONNECT_RETRY_COUNT) {
|
if(p_lcb->link_role == HCI_ROLE_MASTER && p_lcb->retry_create_con < GATTC_CONNECT_RETRY_COUNT) {
|
||||||
L2CAP_TRACE_DEBUG("master retry connect, retry count %d reason 0x%x\n", p_lcb->retry_create_con, reason);
|
L2CAP_TRACE_DEBUG("master retry connect, retry count %d reason 0x%x\n", p_lcb->retry_create_con, reason);
|
||||||
@@ -485,11 +506,12 @@ BOOLEAN l2c_link_hci_disc_comp (UINT16 handle, UINT8 reason)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // (GATTC_CONNECT_RETRY_EN == TRUE)
|
#endif // (GATTC_CONNECT_RETRY_EN == TRUE)
|
||||||
|
}
|
||||||
|
// try to restart extended adv for slave
|
||||||
|
if ((reason == HCI_ERR_CONN_FAILED_ESTABLISHMENT) || (link_state_temp == LST_DISCONNECTED)) {
|
||||||
#if (BLE_50_FEATURE_SUPPORT == TRUE)
|
#if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||||
#if (BLE_50_EXTEND_ADV_EN == TRUE)
|
#if (BLE_50_EXTEND_ADV_EN == TRUE)
|
||||||
if(btm_ble_inter_get() && p_lcb->link_role == HCI_ROLE_SLAVE) {
|
if(btm_ble_inter_get() && p_lcb->link_role == HCI_ROLE_SLAVE) {
|
||||||
p_lcb->retry_create_con ++;
|
|
||||||
L2CAP_TRACE_DEBUG("slave restart extend adv, retry count %d reason 0x%x\n", p_lcb->retry_create_con, reason);
|
L2CAP_TRACE_DEBUG("slave restart extend adv, retry count %d reason 0x%x\n", p_lcb->retry_create_con, reason);
|
||||||
tBTM_STATUS start_adv_status = BTM_BleStartExtAdvRestart(handle);
|
tBTM_STATUS start_adv_status = BTM_BleStartExtAdvRestart(handle);
|
||||||
if (start_adv_status != BTM_SUCCESS) {
|
if (start_adv_status != BTM_SUCCESS) {
|
||||||
@@ -498,19 +520,8 @@ BOOLEAN l2c_link_hci_disc_comp (UINT16 handle, UINT8 reason)
|
|||||||
}
|
}
|
||||||
#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE)
|
#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE)
|
||||||
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
|
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||||
|
}
|
||||||
|
|
||||||
#if (BLE_42_FEATURE_SUPPORT == TRUE)
|
|
||||||
#if (BLE_42_ADV_EN == TRUE)
|
|
||||||
if(!btm_ble_inter_get() && p_lcb->link_role == HCI_ROLE_SLAVE) {
|
|
||||||
p_lcb->retry_create_con ++;
|
|
||||||
L2CAP_TRACE_DEBUG("slave resatrt adv, retry count %d reason 0x%x\n", p_lcb->retry_create_con, reason);
|
|
||||||
tBTM_STATUS start_adv_status = btm_ble_start_adv();
|
|
||||||
if (start_adv_status != BTM_SUCCESS) {
|
|
||||||
L2CAP_TRACE_ERROR("slave resatrt adv failed (err 0x%x)", start_adv_status);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif // #if (BLE_42_ADV_EN == TRUE)
|
|
||||||
#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user