feat(ble/bluedroid): Support bluedroid LE COC and EATT features

(cherry picked from commit 83f0831c53)

Co-authored-by: zhiweijian <zhiweijian@espressif.com>
This commit is contained in:
Zhi Wei Jian
2026-07-14 11:56:02 +08:00
parent 58361a6b08
commit 95bd892dba
39 changed files with 7689 additions and 64 deletions
@@ -1278,6 +1278,11 @@ extern tGATT_STATUS GATTS_HandleMultiValueNotification (UINT16 conn_id, tGATT_HL
*******************************************************************************/
extern tGATT_STATUS GATTS_ShowLocalDatabase(void);
#if (BLE_EATT_INCLUDED == TRUE)
extern void GATT_EattSetChanNum(UINT8 num_chan);
extern BOOLEAN GATT_EattSetDefaultBearer(UINT16 conn_id, UINT16 lcid);
#endif
#ifdef __cplusplus
}
@@ -277,6 +277,15 @@ typedef void (tL2CA_ECHO_DATA_CB) (BD_ADDR, UINT16, UINT8 *);
*/
typedef void (tL2CA_CONGESTION_STATUS_CB) (UINT16, BOOLEAN);
#if (BLE_L2CAP_ENHANCED_COC_INCLUDED == TRUE)
/* LE CoC reconfiguration indication. Parameters are:
** Local CID
** Result (0 = L2CAP_LE_RECONFIG_OK)
** TRUE if peer initiated the reconfiguration
*/
typedef void (tL2CA_LE_RECONFIG_IND_CB) (UINT16, UINT16, BOOLEAN);
#endif
/* Callback prototype for number of packets completed events.
** This callback notifies the application when Number of Completed Packets
** event has been received.
@@ -312,6 +321,9 @@ typedef struct {
tL2CA_DATA_IND_CB *pL2CA_DataInd_Cb;
tL2CA_CONGESTION_STATUS_CB *pL2CA_CongestionStatus_Cb;
tL2CA_TX_COMPLETE_CB *pL2CA_TxComplete_Cb;
#if (BLE_L2CAP_ENHANCED_COC_INCLUDED == TRUE)
tL2CA_LE_RECONFIG_IND_CB *pL2CA_LeReconfigInd_Cb;
#endif
} tL2CAP_APPL_INFO;
@@ -558,6 +570,12 @@ extern UINT16 L2CA_ConnectLECocReq (UINT16 psm, BD_ADDR p_bd_addr, tL2CAP_LE_CFG
extern BOOLEAN L2CA_ConnectLECocRsp (BD_ADDR p_bd_addr, UINT8 id, UINT16 lcid, UINT16 result,
UINT16 status, tL2CAP_LE_CFG_INFO *p_cfg);
#if (BLE_L2CAP_ENHANCED_COC_INCLUDED == TRUE)
extern UINT8 L2CA_ConnectLEEcocReq(UINT16 psm, BD_ADDR p_bd_addr, tL2CAP_LE_CFG_INFO *p_cfg,
UINT8 num_chan, UINT16 *p_lcids);
extern BOOLEAN L2CA_LEEcocReconfig(UINT16 lcids[], UINT8 num, UINT16 new_mtu, UINT16 new_mps);
#endif
/*******************************************************************************
**
** Function L2CA_GetPeerLECocConfig
@@ -569,6 +587,12 @@ extern BOOLEAN L2CA_ConnectLECocRsp (BD_ADDR p_bd_addr, UINT8 id, UINT16 lcid, U
*******************************************************************************/
extern BOOLEAN L2CA_GetPeerLECocConfig (UINT16 lcid, tL2CAP_LE_CFG_INFO* peer_cfg);
extern UINT8 L2CA_LECocDataWrite (UINT16 lcid, BT_HDR *p_data);
extern BOOLEAN L2CA_LECocIsCongested (UINT16 lcid);
extern BOOLEAN L2CA_LECocGiveCredits (UINT16 lcid, UINT16 credits);
extern BOOLEAN L2CA_LECocSetAutoCredit (UINT16 lcid, BOOLEAN enable);
extern BOOLEAN L2CA_LECocDisconnect (UINT16 lcid);
#endif // (BLE_L2CAP_COC_INCLUDED == TRUE)
/*******************************************************************************
@@ -44,6 +44,10 @@
#define L2CAP_CMD_BLE_CREDIT_BASED_CONN_REQ 0x14
#define L2CAP_CMD_BLE_CREDIT_BASED_CONN_RES 0x15
#define L2CAP_CMD_BLE_FLOW_CTRL_CREDIT 0x16
#define L2CAP_CMD_BLE_ENHANCED_CONN_REQ 0x17
#define L2CAP_CMD_BLE_ENHANCED_CONN_RES 0x18
#define L2CAP_CMD_BLE_CREDIT_RECONFIG_REQ 0x19
#define L2CAP_CMD_BLE_CREDIT_RECONFIG_RSP 0x1A
@@ -77,6 +81,10 @@
#define L2CAP_CMD_BLE_CREDIT_BASED_CONN_REQ_LEN 10 /* LE_PSM, SCID, MTU, MPS, Init Credit */
#define L2CAP_CMD_BLE_CREDIT_BASED_CONN_RES_LEN 10 /* DCID, MTU, MPS, Init credit, Result */
#define L2CAP_CMD_BLE_FLOW_CTRL_CREDIT_LEN 4 /* CID, Credit */
#define L2CAP_CMD_BLE_ENHANCED_CONN_REQ_BASE_LEN 8 /* LE_PSM, MTU, MPS, Init Credit */
#define L2CAP_CMD_BLE_ENHANCED_CONN_RES_BASE_LEN 8 /* MTU, MPS, Init credit, Result */
#define L2CAP_CMD_BLE_CREDIT_RECONFIG_REQ_BASE_LEN 4 /* MTU, MPS */
#define L2CAP_CMD_BLE_CREDIT_RECONFIG_RSP_LEN 2 /* Result */
@@ -288,7 +296,7 @@
/* SAR bits in the control word
*/
#define L2CAP_FCR_UNSEG_SDU 0x0000 /* Control word to begin with for unsegmented PDU*/
#define L2CAP_FCR_START_SDU 0x4000 /* ...for Starting PDU of a semented SDU */
#define L2CAP_FCR_START_SDU 0x4000 /* ...for Starting PDU of a segmented SDU */
#define L2CAP_FCR_END_SDU 0x8000 /* ...for ending PDU of a segmented SDU */
#define L2CAP_FCR_CONT_SDU 0xc000 /* ...for continuation PDU of a segmented SDU */
@@ -333,4 +341,10 @@
#define L2CAP_LE_RESULT_UNACCEPTABLE_PARAMETERS 0x0B
#define L2CAP_LE_RESULT_INVALID_PARAMETERS 0x0C
#define L2CAP_LE_RECONFIG_OK 0
#define L2CAP_LE_RECONFIG_REDUCTION_MTU_NOT_ALLOWED 1
#define L2CAP_LE_RECONFIG_REDUCTION_MPS_NOT_ALLOWED 2
#define L2CAP_LE_RECONFIG_INVALID_DCID 3
#define L2CAP_LE_RECONFIG_UNACCEPTED_PARAM 4
#endif