diff --git a/components/bt/host/bluedroid/stack/btm/btm_acl.c b/components/bt/host/bluedroid/stack/btm/btm_acl.c index 192b62408b..24ffea9fa9 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_acl.c +++ b/components/bt/host/bluedroid/stack/btm/btm_acl.c @@ -292,7 +292,9 @@ void btm_acl_created (BD_ADDR bda, DEV_CLASS dc, UINT8 bdn[BTM_MAX_REM_BD_NAME_L p->conn_addr[0], p->conn_addr[1], p->conn_addr[2], p->conn_addr[3], p->conn_addr[4], p->conn_addr[5]); #endif #endif +#if (CLASSIC_BT_INCLUDED == TRUE) p->switch_role_state = BTM_ACL_SWKEY_STATE_IDLE; +#endif // (CLASSIC_BT_INCLUDED == TRUE) p->p_pm_mode_db = btm_pm_sm_alloc(); #if BTM_PM_DEBUG == TRUE @@ -384,7 +386,7 @@ void btm_acl_created (BD_ADDR bda, DEV_CLASS dc, UINT8 bdn[BTM_MAX_REM_BD_NAME_L } } - +#if (CLASSIC_BT_INCLUDED == TRUE) /******************************************************************************* ** ** Function btm_acl_report_role_change @@ -408,6 +410,7 @@ void btm_acl_report_role_change (UINT8 hci_status, BD_ADDR bda) btm_cb.devcb.p_switch_role_cb = NULL; } } +#endif // (CLASSIC_BT_INCLUDED == TRUE) /******************************************************************************* ** @@ -432,8 +435,10 @@ void btm_acl_removed (BD_ADDR bda, tBT_TRANSPORT transport) if (p != (tACL_CONN *)NULL) { p->in_use = FALSE; +#if (CLASSIC_BT_INCLUDED == TRUE) /* if the disconnected channel has a pending role switch, clear it now */ btm_acl_report_role_change(HCI_ERR_NO_CONNECTION, bda); +#endif // (CLASSIC_BT_INCLUDED == TRUE) /* Only notify if link up has had a chance to be issued */ if (p->link_up_issued) { @@ -646,7 +651,7 @@ tBTM_STATUS BTM_GetRole (BD_ADDR remote_bd_addr, UINT8 *p_role) return (BTM_SUCCESS); } - +#if (CLASSIC_BT_INCLUDED == TRUE) /******************************************************************************* ** ** Function BTM_SwitchRole @@ -865,6 +870,7 @@ void btm_acl_encrypt_change (UINT16 handle, UINT8 status, UINT8 encr_enable) #endif } } +#endif // (CLASSIC_BT_INCLUDED == TRUE) /******************************************************************************* ** ** Function BTM_SetLinkPolicy @@ -1472,6 +1478,7 @@ void btm_process_clk_off_comp_evt (UINT16 hci_handle, UINT16 clock_offset) } +#if (CLASSIC_BT_INCLUDED == TRUE) /******************************************************************************* ** ** Function btm_acl_role_changed @@ -1571,6 +1578,7 @@ void btm_acl_role_changed (UINT8 hci_status, BD_ADDR bd_addr, UINT8 new_role) #endif } +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) /******************************************************************************* ** @@ -2599,6 +2607,7 @@ UINT8 BTM_SetTraceLevel (UINT8 new_level) return (btm_cb.trace_level); } +#if (CLASSIC_BT_INCLUDED == TRUE) /******************************************************************************* ** ** Function btm_cont_rswitch @@ -2653,6 +2662,7 @@ void btm_cont_rswitch (tACL_CONN *p, tBTM_SEC_DEV_REC *p_dev_rec, } } } +#endif // (CLASSIC_BT_INCLUDED == TRUE) #if (CLASSIC_BT_INCLUDED == TRUE) /******************************************************************************* diff --git a/components/bt/host/bluedroid/stack/btm/btm_pm.c b/components/bt/host/bluedroid/stack/btm/btm_pm.c index 915cd43d55..aa94c88c90 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_pm.c +++ b/components/bt/host/bluedroid/stack/btm/btm_pm.c @@ -820,9 +820,10 @@ void btm_pm_proc_mode_change (UINT8 hci_status, UINT16 hci_handle, UINT8 mode, U (*btm_cb.pm_reg_db[yy].cback)( p->remote_addr, mode, interval, hci_status); } } - +#if (CLASSIC_BT_INCLUDED == TRUE) /* If mode change was because of an active role switch or change link key */ btm_cont_rswitch(p, btm_find_dev(p->remote_addr), hci_status); +#endif // (CLASSIC_BT_INCLUDED == TRUE) } /******************************************************************************* 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 d4699329ad..9a00c55afd 100644 --- a/components/bt/host/bluedroid/stack/btm/include/btm_int.h +++ b/components/bt/host/bluedroid/stack/btm/include/btm_int.h @@ -140,7 +140,10 @@ UINT8 legacy_auth_state; #define BTM_ACL_SWKEY_STATE_SWITCHING 3 #define BTM_ACL_SWKEY_STATE_ENCRYPTION_ON 4 #define BTM_ACL_SWKEY_STATE_IN_PROGRESS 5 + +#if (CLASSIC_BT_INCLUDED == TRUE) UINT8 switch_role_state; +#endif // (CLASSIC_BT_INCLUDED == TRUE) #define BTM_ACL_ENCRYPT_STATE_IDLE 0 #define BTM_ACL_ENCRYPT_STATE_ENCRYPT_OFF 1 /* encryption turning off */ @@ -207,9 +210,11 @@ tBTM_CMPL_CB *p_qossu_cmpl_cb; /* Callback function to be called when /* qos setup function completes */ #endif // (CLASSIC_BT_INCLUDED == TRUE) +#if (CLASSIC_BT_INCLUDED == TRUE) tBTM_ROLE_SWITCH_CMPL switch_role_ref_data; tBTM_CMPL_CB *p_switch_role_cb; /* Callback function to be called when */ /* requested switch role is completed */ +#endif // (CLASSIC_BT_INCLUDED == TRUE) #if (BLE_HOST_READ_TX_POWER_EN == TRUE) TIMER_LIST_ENT tx_power_timer; diff --git a/components/bt/host/bluedroid/stack/btu/btu_hcif.c b/components/bt/host/bluedroid/stack/btu/btu_hcif.c index 728d2b178f..1cc4dc23d7 100644 --- a/components/bt/host/bluedroid/stack/btu/btu_hcif.c +++ b/components/bt/host/bluedroid/stack/btu/btu_hcif.c @@ -1025,8 +1025,9 @@ static void btu_hcif_encryption_change_evt (UINT8 *p) STREAM_TO_UINT8 (status, p); STREAM_TO_UINT16 (handle, p); STREAM_TO_UINT8 (encr_enable, p); - +#if (CLASSIC_BT_INCLUDED == TRUE) btm_acl_encrypt_change (handle, status, encr_enable); +#endif // (CLASSIC_BT_INCLUDED == TRUE) btm_sec_encrypt_change (handle, status, encr_enable); } #endif ///SMP_INCLUDED == TRUE @@ -1711,6 +1712,7 @@ static void btu_hcif_hdl_command_status (UINT16 opcode, UINT8 status, UINT8 *p_c case HCI_SWITCH_ROLE: /* Tell BTM that the command failed */ /* read bd addr out of stored command */ + #if (CLASSIC_BT_INCLUDED == TRUE) if (p_cmd != NULL) { p_cmd++; STREAM_TO_BDADDR (bd_addr, p_cmd); @@ -1719,6 +1721,7 @@ static void btu_hcif_hdl_command_status (UINT16 opcode, UINT8 status, UINT8 *p_c btm_acl_role_changed(status, NULL, BTM_ROLE_UNDEFINED); } l2c_link_role_changed (NULL, BTM_ROLE_UNDEFINED, HCI_ERR_COMMAND_DISALLOWED); + #endif // (CLASSIC_BT_INCLUDED == TRUE) break; case HCI_CREATE_CONNECTION: diff --git a/components/bt/host/bluedroid/stack/l2cap/l2c_utils.c b/components/bt/host/bluedroid/stack/l2cap/l2c_utils.c index 0d3fed93d1..cd44976756 100644 --- a/components/bt/host/bluedroid/stack/l2cap/l2c_utils.c +++ b/components/bt/host/bluedroid/stack/l2cap/l2c_utils.c @@ -2274,8 +2274,11 @@ BOOLEAN l2cu_create_conn (tL2C_LCB *p_lcb, tBT_TRANSPORT transport) #if BTM_SCO_INCLUDED == TRUE BOOLEAN is_sco_active; #endif + +#if (CLASSIC_BT_INCLUDED == TRUE) list_node_t *p_node = NULL; tL2C_LCB *p_lcb_cur = NULL; +#endif // (CLASSIC_BT_INCLUDED == TRUE) #if (BLE_INCLUDED == TRUE) tBT_DEVICE_TYPE dev_type; @@ -2298,6 +2301,7 @@ BOOLEAN l2cu_create_conn (tL2C_LCB *p_lcb, tBT_TRANSPORT transport) } #endif +#if (CLASSIC_BT_INCLUDED == TRUE) /* If there is a connection where we perform as a slave, try to switch roles for this connection */ for (p_node = list_begin(l2cb.p_lcb_pool); p_node; p_node = list_next(p_node)) { @@ -2341,6 +2345,8 @@ BOOLEAN l2cu_create_conn (tL2C_LCB *p_lcb, tBT_TRANSPORT transport) p_lcb->link_state = LST_CONNECTING; return (l2cu_create_conn_after_switch (p_lcb)); +#endif // (CLASSIC_BT_INCLUDED == TRUE) + return false; } /*******************************************************************************