feat(ble/bluedroid): Support PAWR connection event

This commit is contained in:
zhiweijian
2026-07-30 21:00:26 +08:00
parent 4b82a06d73
commit 7da7fa42ac
18 changed files with 216 additions and 34 deletions
@@ -415,6 +415,7 @@ typedef struct t_l2c_linkcb {
BOOLEAN is_pawr_synced;
UINT8 adv_handle;
UINT8 subevent;
UINT16 sync_handle;
#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 */
@@ -841,12 +842,16 @@ extern void l2c_fcr_free_timer (tL2C_CCB *p_ccb);
************************************
*/
#if (BLE_INCLUDED == TRUE)
#define L2C_BLE_PAWR_ADV_HANDLE_NONE 0xFF
#define L2C_BLE_PAWR_SYNC_HANDLE_NONE 0xFFFF
extern BOOLEAN l2cble_create_conn (tL2C_LCB *p_lcb);
extern void l2cble_remove_pending_direct_conn (tL2C_LCB *p_lcb);
extern void l2cble_cleanup_alloc_ccb_failed_conn (tL2C_LCB *p_lcb);
extern void l2cble_process_sig_cmd (tL2C_LCB *p_lcb, UINT8 *p, UINT16 pkt_len);
extern void l2cble_conn_comp (UINT16 handle, UINT8 role, BD_ADDR bda, tBLE_ADDR_TYPE type,
UINT16 conn_interval, UINT16 conn_latency, UINT16 conn_timeout);
UINT16 conn_interval, UINT16 conn_latency, UINT16 conn_timeout,
UINT8 adv_handle, UINT16 sync_handle);
extern void l2cu_read_pawr_conn_handles(const tL2C_LCB *p_lcb, UINT8 *adv_handle, UINT16 *sync_handle);
extern BOOLEAN l2cble_init_direct_conn (tL2C_LCB *p_lcb);
extern void l2cble_notify_le_connection (BD_ADDR bda);
extern void l2c_ble_link_adjust_allocation (void);
@@ -328,8 +328,39 @@ void l2cble_notify_le_connection (BD_ADDR bda)
** Returns void
**
*******************************************************************************/
static void l2cble_store_pawr_conn_handles(tL2C_LCB *p_lcb, UINT8 adv_handle, UINT16 sync_handle)
{
#if (BT_BLE_FEAT_PAWR_EN == TRUE)
/* Keep the outgoing adv_handle if the controller reports NONE (non-PAwR central). */
if (adv_handle != L2C_BLE_PAWR_ADV_HANDLE_NONE) {
p_lcb->adv_handle = adv_handle;
}
p_lcb->sync_handle = sync_handle;
#else
UNUSED(p_lcb);
UNUSED(adv_handle);
UNUSED(sync_handle);
#endif // #if (BT_BLE_FEAT_PAWR_EN == TRUE)
}
void l2cu_read_pawr_conn_handles(const tL2C_LCB *p_lcb, UINT8 *adv_handle, UINT16 *sync_handle)
{
#if (BT_BLE_FEAT_PAWR_EN == TRUE)
if (p_lcb != NULL) {
*adv_handle = p_lcb->adv_handle;
*sync_handle = p_lcb->sync_handle;
return;
}
#else
UNUSED(p_lcb);
#endif // #if (BT_BLE_FEAT_PAWR_EN == TRUE)
*adv_handle = L2C_BLE_PAWR_ADV_HANDLE_NONE;
*sync_handle = L2C_BLE_PAWR_SYNC_HANDLE_NONE;
}
void l2cble_scanner_conn_comp (UINT16 handle, BD_ADDR bda, tBLE_ADDR_TYPE type,
UINT16 conn_interval, UINT16 conn_latency, UINT16 conn_timeout)
UINT16 conn_interval, UINT16 conn_latency, UINT16 conn_timeout,
UINT8 adv_handle, UINT16 sync_handle)
{
tL2C_LCB *p_lcb;
tBTM_SEC_DEV_REC *p_dev_rec = btm_find_or_alloc_dev (bda);
@@ -381,6 +412,8 @@ void l2cble_scanner_conn_comp (UINT16 handle, BD_ADDR bda, tBLE_ADDR_TYPE type,
p_lcb->updating_param_flag = false;
p_lcb->ble_addr_type = type;
l2cble_store_pawr_conn_handles(p_lcb, adv_handle, sync_handle);
/* If there are any preferred connection parameters, set them now */
if ( (p_dev_rec->conn_params.min_conn_int >= BLE_CONN_INT_MIN_HOST_CHECK ) &&
(p_dev_rec->conn_params.min_conn_int <= BTM_BLE_CONN_INT_MAX ) &&
@@ -435,7 +468,8 @@ void l2cble_scanner_conn_comp (UINT16 handle, BD_ADDR bda, tBLE_ADDR_TYPE type,
**
*******************************************************************************/
void l2cble_advertiser_conn_comp (UINT16 handle, BD_ADDR bda, tBLE_ADDR_TYPE type,
UINT16 conn_interval, UINT16 conn_latency, UINT16 conn_timeout)
UINT16 conn_interval, UINT16 conn_latency, UINT16 conn_timeout,
UINT8 adv_handle, UINT16 sync_handle)
{
tL2C_LCB *p_lcb;
tBTM_SEC_DEV_REC *p_dev_rec;
@@ -482,6 +516,8 @@ void l2cble_advertiser_conn_comp (UINT16 handle, BD_ADDR bda, tBLE_ADDR_TYPE typ
p_lcb->updating_param_flag = false;
p_lcb->ble_addr_type = type;
l2cble_store_pawr_conn_handles(p_lcb, adv_handle, sync_handle);
/* Tell BTM Acl management about the link */
p_dev_rec = btm_find_or_alloc_dev (bda);
@@ -518,7 +554,8 @@ void l2cble_advertiser_conn_comp (UINT16 handle, BD_ADDR bda, tBLE_ADDR_TYPE typ
**
*******************************************************************************/
void l2cble_conn_comp(UINT16 handle, UINT8 role, BD_ADDR bda, tBLE_ADDR_TYPE type,
UINT16 conn_interval, UINT16 conn_latency, UINT16 conn_timeout)
UINT16 conn_interval, UINT16 conn_latency, UINT16 conn_timeout,
UINT8 adv_handle, UINT16 sync_handle)
{
#if (BLE_TOPOLOGY_CHECK == TRUE)
btm_ble_update_link_topology_mask(role, TRUE);
@@ -528,9 +565,11 @@ void l2cble_conn_comp(UINT16 handle, UINT8 role, BD_ADDR bda, tBLE_ADDR_TYPE typ
btm_cb.ble_ctr_cb.inq_var.directed_conn = BTM_BLE_CONNECT_EVT;
#endif // (BLE_TOPOLOGY_CHECK == TRUE)
if (role == HCI_ROLE_MASTER) {
l2cble_scanner_conn_comp(handle, bda, type, conn_interval, conn_latency, conn_timeout);
l2cble_scanner_conn_comp(handle, bda, type, conn_interval, conn_latency, conn_timeout,
adv_handle, sync_handle);
} else {
l2cble_advertiser_conn_comp(handle, bda, type, conn_interval, conn_latency, conn_timeout);
l2cble_advertiser_conn_comp(handle, bda, type, conn_interval, conn_latency, conn_timeout,
adv_handle, sync_handle);
}
}
@@ -115,6 +115,10 @@ tL2C_LCB *l2cu_allocate_lcb (BD_ADDR p_bd_addr, BOOLEAN is_bonding, tBT_TRANSPOR
if (transport == BT_TRANSPORT_LE) {
l2cb.num_ble_links_active++;
l2c_ble_link_adjust_allocation();
#if (BT_BLE_FEAT_PAWR_EN == TRUE)
p_lcb->adv_handle = L2C_BLE_PAWR_ADV_HANDLE_NONE;
p_lcb->sync_handle = L2C_BLE_PAWR_SYNC_HANDLE_NONE;
#endif // #if (BT_BLE_FEAT_PAWR_EN == TRUE)
} else
#endif
{
@@ -188,6 +192,8 @@ void l2cu_release_lcb (tL2C_LCB *p_lcb)
#if (BT_BLE_FEAT_PAWR_EN == TRUE)
p_lcb->is_pawr_synced = FALSE;
p_lcb->adv_handle = L2C_BLE_PAWR_ADV_HANDLE_NONE;
p_lcb->sync_handle = L2C_BLE_PAWR_SYNC_HANDLE_NONE;
#endif
/* Stop and release timers */