fix(ble/bluedroid): Fixed bt buuld error

fix(ble/bluedroid): disable power management if bt is disabled


(cherry picked from commit 6f27074c1e)

Co-authored-by: zhiweijian <zhiweijian@espressif.com>
This commit is contained in:
Zhi Wei Jian
2026-01-07 17:24:34 +08:00
parent 8e361fc5bb
commit cbf4640668
25 changed files with 144 additions and 61 deletions
@@ -488,7 +488,9 @@ typedef struct {
list_t *p_lcb_pool; /* Link Control Block pool */
list_t *p_ccb_pool; /* Channel Control Block pool */
#if (CLASSIC_BT_INCLUDED == TRUE)
tL2C_RCB rcb_pool[MAX_L2CAP_CLIENTS]; /* Registration info pool */
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
#if (CLASSIC_BT_INCLUDED == TRUE)
UINT8 desire_role; /* desire to be master/slave when accepting a connection */
@@ -500,8 +502,10 @@ typedef struct {
list_t *rcv_pending_q; /* Recv pending queue */
TIMER_LIST_ENT rcv_hold_tle; /* Timer list entry for rcv hold */
tL2C_LCB *p_cur_hcit_lcb; /* Current HCI Transport buffer */
// tL2C_LCB *p_cur_hcit_lcb; /* Current HCI Transport buffer */
#if (CLASSIC_BT_INCLUDED == TRUE)
UINT16 num_links_active; /* Number of links active */
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
#if (L2CAP_NON_FLUSHABLE_PB_INCLUDED == TRUE)
UINT16 non_flushable_pbf; /* L2CAP_PKT_START_NON_FLUSHABLE if controller supports */
@@ -530,13 +534,16 @@ typedef struct {
tL2C_RCB ble_rcb_pool[BLE_MAX_L2CAP_CLIENTS]; /* Registration info pool */
#endif
#if (CLASSIC_BT_INCLUDED == TRUE)
tL2CA_ECHO_DATA_CB *p_echo_data_cb; /* Echo data callback */
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
#if (defined(L2CAP_HIGH_PRI_CHAN_QUOTA_IS_CONFIGURABLE) && (L2CAP_HIGH_PRI_CHAN_QUOTA_IS_CONFIGURABLE == TRUE))
UINT16 high_pri_min_xmit_quota; /* Minimum number of ACL credit for high priority link */
#endif /* (L2CAP_HIGH_PRI_CHAN_QUOTA_IS_CONFIGURABLE == TRUE) */
#if (CLASSIC_BT_INCLUDED == TRUE)
UINT16 dyn_psm;
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
} tL2C_CB;
@@ -1118,6 +1118,7 @@ void l2c_link_processs_ble_num_bufs (UINT16 num_lm_ble_bufs)
l2cb.num_lm_ble_bufs = l2cb.controller_le_xmit_window = num_lm_ble_bufs;
}
#if (BLE_INCLUDED == TRUE)
/*******************************************************************************
**
** Function l2c_ble_link_adjust_allocation
@@ -1237,6 +1238,7 @@ void l2c_ble_link_adjust_allocation (void)
}
}
}
#endif // #if (BLE_INCLUDED == TRUE)
#if (defined BLE_LLT_INCLUDED) && (BLE_LLT_INCLUDED == TRUE)
/*******************************************************************************
@@ -736,7 +736,7 @@ void l2c_info_timeout (tL2C_LCB *p_lcb)
#endif ///CLASSIC_BT_INCLUDED == TRUE
}
}
#if (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
**
** Function l2c_link_adjust_allocation
@@ -857,7 +857,7 @@ void l2c_link_adjust_allocation (void)
}
}
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
**
** Function l2c_link_adjust_chnl_allocation
@@ -1013,7 +1013,9 @@ void l2c_pin_code_request (BD_ADDR bd_addr)
*******************************************************************************/
BOOLEAN l2c_link_check_power_mode (tL2C_LCB *p_lcb)
{
#if (CLASSIC_BT_INCLUDED == TRUE)
tBTM_PM_MODE mode;
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
tL2C_CCB *p_ccb;
BOOLEAN need_to_active = FALSE;
@@ -1033,6 +1035,7 @@ BOOLEAN l2c_link_check_power_mode (tL2C_LCB *p_lcb)
/* if we have packets to send */
if ( need_to_active ) {
#if (CLASSIC_BT_INCLUDED == TRUE)
/* check power mode */
if (BTM_ReadPowerMode(p_lcb->remote_bd_addr, &mode) == BTM_SUCCESS) {
if ( mode == BTM_PM_STS_PENDING ) {
@@ -1041,6 +1044,7 @@ BOOLEAN l2c_link_check_power_mode (tL2C_LCB *p_lcb)
return TRUE;
}
}
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
}
return FALSE;
}
@@ -859,8 +859,10 @@ void l2c_init (void)
l2c_cb_ptr = (tL2C_CB *)osi_malloc(sizeof(tL2C_CB));
#endif /* #if L2C_DYNAMIC_MEMORY */
memset (&l2cb, 0, sizeof (tL2C_CB));
#if (CLASSIC_BT_INCLUDED == TRUE)
/* the psm is increased by 2 before being used */
l2cb.dyn_psm = 0xFFF;
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
l2cb.p_ccb_pool = list_new(osi_free_func);
if (l2cb.p_ccb_pool == NULL) {
@@ -113,8 +113,10 @@ tL2C_LCB *l2cu_allocate_lcb (BD_ADDR p_bd_addr, BOOLEAN is_bonding, tBT_TRANSPOR
} else
#endif
{
#if (CLASSIC_BT_INCLUDED == TRUE)
l2cb.num_links_active++;
l2c_link_adjust_allocation();
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
}
p_lcb->link_xmit_data_q = list_new(NULL);
return (p_lcb);
@@ -261,11 +263,13 @@ void l2cu_release_lcb (tL2C_LCB *p_lcb)
} else
#endif
{
#if (CLASSIC_BT_INCLUDED == TRUE)
if (l2cb.num_links_active >= 1) {
l2cb.num_links_active--;
}
l2c_link_adjust_allocation();
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
}
/* Check for ping outstanding */
@@ -1799,6 +1803,7 @@ tL2C_CCB *l2cu_find_ccb_by_remote_cid (tL2C_LCB *p_lcb, UINT16 remote_cid)
return (NULL);
}
#if (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
**
** Function l2cu_allocate_rcb
@@ -1828,6 +1833,7 @@ tL2C_RCB *l2cu_allocate_rcb (UINT16 psm)
/* If here, no free RCB found */
return (NULL);
}
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
#if (BLE_INCLUDED == TRUE)
/*******************************************************************************
@@ -1907,7 +1913,7 @@ void l2cu_disconnect_chnl (tL2C_CCB *p_ccb)
}
}
#if (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
**
** Function l2cu_find_rcb_by_psm
@@ -1932,6 +1938,7 @@ tL2C_RCB *l2cu_find_rcb_by_psm (UINT16 psm)
/* If here, no match found */
return (NULL);
}
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
#if (BLE_INCLUDED == TRUE)
/*******************************************************************************