summaryrefslogtreecommitdiff
path: root/lib/bt/host/bluedroid/stack/l2cap
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2025-07-25 13:33:07 +1000
committerjacqueline <me@jacqueline.id.au>2025-07-25 13:33:07 +1000
commitc8e79a926620e48830778714cfe4b2ea2453fcaf (patch)
tree8c756e08e01b8e147cf72bec128026f46bd854c5 /lib/bt/host/bluedroid/stack/l2cap
parent237136f3e93cb6b5be24670d7520adb17cc0fa36 (diff)
downloadtangara-fw-c8e79a926620e48830778714cfe4b2ea2453fcaf.tar.gz
Update forked idf components
Diffstat (limited to 'lib/bt/host/bluedroid/stack/l2cap')
-rw-r--r--lib/bt/host/bluedroid/stack/l2cap/include/l2c_int.h14
-rw-r--r--lib/bt/host/bluedroid/stack/l2cap/l2c_ble.c42
-rw-r--r--lib/bt/host/bluedroid/stack/l2cap/l2c_link.c22
-rw-r--r--lib/bt/host/bluedroid/stack/l2cap/l2c_utils.c14
4 files changed, 59 insertions, 33 deletions
diff --git a/lib/bt/host/bluedroid/stack/l2cap/include/l2c_int.h b/lib/bt/host/bluedroid/stack/l2cap/include/l2c_int.h
index 045fb10d..88eac86b 100644
--- a/lib/bt/host/bluedroid/stack/l2cap/include/l2c_int.h
+++ b/lib/bt/host/bluedroid/stack/l2cap/include/l2c_int.h
@@ -65,7 +65,7 @@
#define L2CAP_WAIT_UNPARK_TOUT 2 /* 2 seconds */
#define L2CAP_LINK_INFO_RESP_TOUT 2 /* 2 seconds */
#define L2CAP_UPDATE_CONN_PARAM_TOUT 6 /* 6 seconds */
-#define L2CAP_BLE_LINK_CONNECT_TOUT BLE_ESTABLISH_LINK_CONNECTION_TIMEOUT // configed in menuconfig
+#define L2CAP_BLE_LINK_CONNECT_TOUT BLE_ESTABLISH_LINK_CONNECTION_TIMEOUT // configured in menuconfig
#define L2CAP_BLE_CONN_PARAM_UPD_TOUT 30 /* 30 seconds */
/* quick timer uses millisecond unit */
@@ -80,10 +80,10 @@
** the Bluetooth specification.
*/
typedef enum {
- CST_CLOSED, /* Channel is in clodes state */
+ CST_CLOSED, /* Channel is in closed state */
CST_ORIG_W4_SEC_COMP, /* Originator waits security clearence */
CST_TERM_W4_SEC_COMP, /* Acceptor waits security clearence */
- CST_W4_L2CAP_CONNECT_RSP, /* Waiting for peer conenct response */
+ CST_W4_L2CAP_CONNECT_RSP, /* Waiting for peer connect response */
CST_W4_L2CA_CONNECT_RSP, /* Waiting for upper layer connect rsp */
CST_CONFIG, /* Negotiating configuration */
CST_OPEN, /* Data transfer state */
@@ -208,8 +208,8 @@ typedef struct {
UINT32 controller_idle; /* # of times less than 2 packets in controller */
/* when the xmit window was closed */
UINT32 pkts_retransmitted; /* # of packets that were retransmitted */
- UINT32 retrans_touts; /* # of retransmission timouts */
- UINT32 xmit_ack_touts; /* # of xmit ack timouts */
+ UINT32 retrans_touts; /* # of retransmission timeouts */
+ UINT32 xmit_ack_touts; /* # of xmit ack timeouts */
#define L2CAP_ERTM_STATS_NUM_AVG 10
#define L2CAP_ERTM_STATS_AVG_NUM_SAMPLES 100
@@ -386,7 +386,7 @@ typedef struct t_l2c_linkcb {
tL2C_CCB *p_pending_ccb; /* ccb of waiting channel during link disconnect */
TIMER_LIST_ENT info_timer_entry; /* Timer entry for info resp timeout evt */
- TIMER_LIST_ENT upda_con_timer; /* Timer entry for update connection parametr */
+ TIMER_LIST_ENT upda_con_timer; /* Timer entry for update connection parameter */
BD_ADDR remote_bd_addr; /* The BD address of the remote */
UINT8 link_role; /* Master or slave */
@@ -599,7 +599,7 @@ extern BOOLEAN l2cu_start_post_bond_timer (UINT16 handle);
extern void l2cu_release_lcb (tL2C_LCB *p_lcb);
extern tL2C_LCB *l2cu_find_lcb_by_bd_addr (BD_ADDR p_bd_addr, tBT_TRANSPORT transport);
extern tL2C_LCB *l2cu_find_lcb_by_handle (UINT16 handle);
-extern uint8_t l2cu_plcb_active_count(void);
+extern uint8_t l2cu_ble_plcb_active_count(void);
extern void l2cu_update_lcb_4_bonding (BD_ADDR p_bd_addr, BOOLEAN is_bonding);
extern UINT8 l2cu_get_conn_role (tL2C_LCB *p_this_lcb);
diff --git a/lib/bt/host/bluedroid/stack/l2cap/l2c_ble.c b/lib/bt/host/bluedroid/stack/l2cap/l2c_ble.c
index 956a4b7f..3ce25ab9 100644
--- a/lib/bt/host/bluedroid/stack/l2cap/l2c_ble.c
+++ b/lib/bt/host/bluedroid/stack/l2cap/l2c_ble.c
@@ -111,7 +111,7 @@ BOOLEAN L2CA_CancelBleConnectReq (BD_ADDR rem_bda)
p_lcb = l2cu_find_lcb_by_bd_addr(rem_bda, BT_TRANSPORT_LE);
/* Do not remove lcb if an LE link is already up as a peripheral */
if (p_lcb != NULL &&
- !(p_lcb->link_role == HCI_ROLE_SLAVE && BTM_ACL_IS_CONNECTED(rem_bda))) {
+ !(p_lcb->link_role == HCI_ROLE_SLAVE && BTM_LE_ACL_IS_CONNECTED(rem_bda))) {
p_lcb->disc_reason = L2CAP_CONN_CANCEL;
l2cu_release_lcb (p_lcb);
}
@@ -242,7 +242,7 @@ BOOLEAN L2CA_EnableUpdateBleConnParams (BD_ADDR rem_bda, BOOLEAN enable)
return (FALSE);
}
bool is_disable = (p_lcb->conn_update_mask & L2C_BLE_CONN_UPDATE_DISABLE);
- if(l2cu_plcb_active_count() >1 && !(enable && is_disable)) {
+ if(l2cu_ble_plcb_active_count() >1 && !(enable && is_disable)) {
return FALSE;
}
@@ -376,6 +376,7 @@ void l2cble_scanner_conn_comp (UINT16 handle, BD_ADDR bda, tBLE_ADDR_TYPE type,
p_lcb->waiting_update_conn_latency = p_lcb->current_used_conn_latency = conn_latency;
p_lcb->conn_update_mask = L2C_BLE_NOT_DEFAULT_PARAM;
p_lcb->updating_param_flag = false;
+ p_lcb->ble_addr_type = type;
/* If there are any preferred connection parameters, set them now */
if ( (p_dev_rec->conn_params.min_conn_int >= BTM_BLE_CONN_INT_MIN ) &&
@@ -476,6 +477,7 @@ void l2cble_advertiser_conn_comp (UINT16 handle, BD_ADDR bda, tBLE_ADDR_TYPE typ
p_lcb->waiting_update_conn_latency = p_lcb->current_used_conn_latency = conn_latency;
p_lcb->conn_update_mask = L2C_BLE_NOT_DEFAULT_PARAM;
p_lcb->updating_param_flag = false;
+ p_lcb->ble_addr_type = type;
/* Tell BTM Acl management about the link */
p_dev_rec = btm_find_or_alloc_dev (bda);
@@ -900,6 +902,12 @@ BOOLEAN l2cble_init_direct_conn (tL2C_LCB *p_lcb)
scan_int = (p_cb->scan_int == BTM_BLE_SCAN_PARAM_UNDEF) ? BTM_BLE_SCAN_FAST_INT : p_cb->scan_int;
scan_win = (p_cb->scan_win == BTM_BLE_SCAN_PARAM_UNDEF) ? BTM_BLE_SCAN_FAST_WIN : p_cb->scan_win;
+ if (p_dev_rec->conn_params.scan_interval && p_dev_rec->conn_params.scan_interval != BTM_BLE_CONN_PARAM_UNDEF) {
+ scan_int = p_dev_rec->conn_params.scan_interval;
+ }
+ if (p_dev_rec->conn_params.scan_window && p_dev_rec->conn_params.scan_window != BTM_BLE_CONN_PARAM_UNDEF) {
+ scan_win = p_dev_rec->conn_params.scan_window;
+ }
peer_addr_type = p_lcb->ble_addr_type;
memcpy(peer_addr, p_lcb->remote_bd_addr, BD_ADDR_LEN);
@@ -964,22 +972,24 @@ BOOLEAN l2cble_init_direct_conn (tL2C_LCB *p_lcb)
}
if (!p_lcb->is_aux) {
- if (!btsnd_hcic_ble_create_ll_conn (scan_int,/* UINT16 scan_int */
- scan_win, /* UINT16 scan_win */
- FALSE, /* UINT8 white_list */
- peer_addr_type, /* UINT8 addr_type_peer */
- peer_addr, /* BD_ADDR bda_peer */
- own_addr_type, /* UINT8 addr_type_own */
+ if (!btsnd_hcic_ble_create_ll_conn (scan_int, /* UINT16 scan_int */
+ scan_win, /* UINT16 scan_win */
+ FALSE, /* UINT8 white_list */
+ peer_addr_type, /* UINT8 addr_type_peer */
+ peer_addr, /* BD_ADDR bda_peer */
+ own_addr_type, /* UINT8 addr_type_own */
(UINT16) ((p_dev_rec->conn_params.min_conn_int != BTM_BLE_CONN_PARAM_UNDEF) ?
- p_dev_rec->conn_params.min_conn_int : BTM_BLE_CONN_INT_MIN_DEF), /* UINT16 conn_int_min */
+ p_dev_rec->conn_params.min_conn_int : BTM_BLE_CONN_INT_MIN_DEF), /* UINT16 conn_int_min */
(UINT16) ((p_dev_rec->conn_params.max_conn_int != BTM_BLE_CONN_PARAM_UNDEF) ?
- p_dev_rec->conn_params.max_conn_int : BTM_BLE_CONN_INT_MAX_DEF), /* UINT16 conn_int_max */
+ p_dev_rec->conn_params.max_conn_int : BTM_BLE_CONN_INT_MAX_DEF), /* UINT16 conn_int_max */
(UINT16) ((p_dev_rec->conn_params.slave_latency != BTM_BLE_CONN_PARAM_UNDEF) ?
- p_dev_rec->conn_params.slave_latency : BTM_BLE_CONN_SLAVE_LATENCY_DEF), /* UINT16 conn_latency */
+ p_dev_rec->conn_params.slave_latency : BTM_BLE_CONN_SLAVE_LATENCY_DEF), /* UINT16 conn_latency */
(UINT16) ((p_dev_rec->conn_params.supervision_tout != BTM_BLE_CONN_PARAM_UNDEF) ?
- p_dev_rec->conn_params.supervision_tout : BTM_BLE_CONN_TIMEOUT_DEF), /* conn_timeout */
- BLE_CE_LEN_MIN, /* UINT16 min_len */
- BLE_CE_LEN_MIN)) { /* UINT16 max_len */
+ p_dev_rec->conn_params.supervision_tout : BTM_BLE_CONN_TIMEOUT_DEF), /* UINT16 conn_timeout */
+ (UINT16) ((p_dev_rec->conn_params.min_ce_len != BTM_BLE_CONN_PARAM_UNDEF) ?
+ p_dev_rec->conn_params.min_ce_len : BLE_CE_LEN_MIN), /* UINT16 min_ce_len */
+ (UINT16) ((p_dev_rec->conn_params.max_ce_len != BTM_BLE_CONN_PARAM_UNDEF) ?
+ p_dev_rec->conn_params.max_ce_len : BLE_CE_LEN_MIN) /* UINT16 max_ce_len */)) {
l2cu_release_lcb (p_lcb);
L2CAP_TRACE_ERROR("initiate direct connection fail, no resources");
return (FALSE);
@@ -1063,11 +1073,11 @@ BOOLEAN l2cble_create_conn (tL2C_LCB *p_lcb)
L2CAP_TRACE_WARNING ("L2CAP - LE - cannot start new connection at conn st: %d", conn_st);
btm_ble_enqueue_direct_conn_req(p_lcb);
-
+#if (tGATT_BG_CONN_DEV == TRUE)
if (conn_st == BLE_BG_CONN) {
btm_ble_suspend_bg_conn();
}
-
+#endif // #if (tGATT_BG_CONN_DEV == TRUE)
rt = TRUE;
}
return rt;
diff --git a/lib/bt/host/bluedroid/stack/l2cap/l2c_link.c b/lib/bt/host/bluedroid/stack/l2cap/l2c_link.c
index c3118fdd..1af7e8b3 100644
--- a/lib/bt/host/bluedroid/stack/l2cap/l2c_link.c
+++ b/lib/bt/host/bluedroid/stack/l2cap/l2c_link.c
@@ -368,9 +368,11 @@ BOOLEAN l2c_link_hci_disc_comp (UINT16 handle, UINT8 reason)
BTM_Recovery_Pre_State();
}
#if (BLE_50_FEATURE_SUPPORT == TRUE)
+ #if (BLE_50_EXTEND_ADV_EN == TRUE)
if(btm_ble_inter_get() && reason == HCI_ERR_CONN_FAILED_ESTABLISHMENT) {
BTM_BleStartExtAdvRestart(handle);
}
+ #endif // #if (BLE_50_EXTEND_ADV_EN == TRUE)
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
#endif ///BLE_INCLUDED == TRUE
status = FALSE;
@@ -478,24 +480,36 @@ BOOLEAN l2c_link_hci_disc_comp (UINT16 handle, UINT8 reason)
if (l2cu_create_conn(p_lcb, BT_TRANSPORT_LE)) {
btm_acl_removed (p_lcb->remote_bd_addr, BT_TRANSPORT_LE);
lcb_is_free = FALSE; /* still using this lcb */
+ } else {
+ L2CAP_TRACE_ERROR("master retry connect failed");
}
}
#endif // (GATTC_CONNECT_RETRY_EN == TRUE)
#if (BLE_50_FEATURE_SUPPORT == TRUE)
+ #if (BLE_50_EXTEND_ADV_EN == TRUE)
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);
- BTM_BleStartExtAdvRestart(handle);
+ tBTM_STATUS start_adv_status = BTM_BleStartExtAdvRestart(handle);
+ if (start_adv_status != BTM_SUCCESS) {
+ L2CAP_TRACE_ERROR("slave restart extend adv failed (err 0x%x)", start_adv_status);
+ }
}
+ #endif // #if (BLE_50_EXTEND_ADV_EN == 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);
- btm_ble_start_adv();
+ 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)
}
@@ -1078,7 +1092,9 @@ void l2c_link_check_send_pkts (tL2C_LCB *p_lcb, tL2C_CCB *p_ccb, BT_HDR *p_buf)
p_lcb_cur = list_node(p_node);
if (p_lcb_cur == p_lcb) {
p_node = list_next(p_node);
- p_lcb = list_node(p_node);
+ if (p_node) {
+ p_lcb = list_node(p_node);
+ }
break;
}
}
diff --git a/lib/bt/host/bluedroid/stack/l2cap/l2c_utils.c b/lib/bt/host/bluedroid/stack/l2cap/l2c_utils.c
index 992d4b68..e4bf8a08 100644
--- a/lib/bt/host/bluedroid/stack/l2cap/l2c_utils.c
+++ b/lib/bt/host/bluedroid/stack/l2cap/l2c_utils.c
@@ -336,14 +336,14 @@ tL2C_LCB *l2cu_find_free_lcb (void)
return (NULL);
}
-uint8_t l2cu_plcb_active_count(void)
+uint8_t l2cu_ble_plcb_active_count(void)
{
list_node_t *p_node = NULL;
tL2C_LCB *p_lcb = NULL;
uint8_t active_count = 0;
for (p_node = list_begin(l2cb.p_lcb_pool); p_node; p_node = list_next(p_node)) {
p_lcb = list_node(p_node);
- if (p_lcb && p_lcb->in_use) {
+ if (p_lcb && p_lcb->in_use && p_lcb->transport == BT_TRANSPORT_LE) {
active_count ++;
}
}
@@ -615,7 +615,7 @@ void l2cu_send_peer_connect_rsp (tL2C_CCB *p_ccb, UINT16 result, UINT16 status)
**
** Description Build and send an L2CAP "connection response neg" message
** to the peer. This function is called when there is no peer
-** CCB (non-existant PSM or no resources).
+** CCB (non-existent PSM or no resources).
**
** Returns void
**
@@ -1737,7 +1737,7 @@ void l2cu_release_ccb (tL2C_CCB *p_ccb)
) {
l2cu_dequeue_ccb (p_ccb);
- /* Delink the CCB from the LCB */
+ /* Unlink the CCB from the LCB */
p_ccb->p_lcb = NULL;
}
@@ -1960,7 +1960,7 @@ tL2C_RCB *l2cu_find_ble_rcb_by_psm (UINT16 psm)
**
** Returns UINT8 - L2CAP_PEER_CFG_OK if passed to upper layer,
** L2CAP_PEER_CFG_UNACCEPTABLE if automatically responded to
-** because parameters are unnacceptable from a specification
+** because parameters are unacceptable from a specification
** point of view.
** L2CAP_PEER_CFG_DISCONNECT if no compatible channel modes
** between the two devices, and shall be closed.
@@ -2558,7 +2558,7 @@ BOOLEAN l2cu_set_acl_priority (BD_ADDR bd_addr, UINT8 priority, BOOLEAN reset_af
**
** Function l2cu_set_non_flushable_pbf
**
-** Description set L2CAP_PKT_START_NON_FLUSHABLE if controller supoorts
+** Description set L2CAP_PKT_START_NON_FLUSHABLE if controller supports
**
** Returns void
**
@@ -3328,7 +3328,7 @@ static tL2C_CCB *l2cu_get_next_channel_in_rr(tL2C_LCB *p_lcb)
for ( i = 0; (i < L2CAP_NUM_CHNL_PRIORITY) && (!p_serve_ccb); i++ ) {
/* scan all channel within serving priority group until finding a channel to serve */
for ( j = 0; (j < p_lcb->rr_serv[p_lcb->rr_pri].num_ccb) && (!p_serve_ccb); j++) {
- /* scaning from next serving channel */
+ /* scanning from next serving channel */
p_ccb = p_lcb->rr_serv[p_lcb->rr_pri].p_serve_ccb;
if (!p_ccb) {