rfcomm supports the use of ERTM

This commit is contained in:
xiongweichao 2022-04-21 14:37:49 +08:00 committed by BOT
parent 1d9fd4707a
commit 740dc8795d
4 changed files with 70 additions and 6 deletions

View File

@ -1565,6 +1565,31 @@
#define PORT_CREDIT_RX_LOW 8
#endif
/* ERTM Tx window size */
#ifndef RFC_FCR_OPT_TX_WINDOW_SIZE
#define RFC_FCR_OPT_TX_WINDOW_SIZE 20
#endif
/* ERTM Maximum transmissions before disconnecting */
#ifndef RFC_FCR_OPT_MAX_TX_B4_DISCNT
#define RFC_FCR_OPT_MAX_TX_B4_DISCNT 20
#endif
/* ERTM Retransmission timeout (2 secs) */
#ifndef RFC_FCR_OPT_RETX_TOUT
#define RFC_FCR_OPT_RETX_TOUT 2000
#endif
/* ERTM Monitor timeout (12 secs) */
#ifndef RFC_FCR_OPT_MONITOR_TOUT
#define RFC_FCR_OPT_MONITOR_TOUT 12000
#endif
/* ERTM ERTM MPS segment size */
#ifndef RFC_FCR_OPT_MAX_PDU_SIZE
#define RFC_FCR_OPT_MAX_PDU_SIZE 1010
#endif
/******************************************************************************
**
** OBEX

View File

@ -1559,7 +1559,7 @@ tL2C_CCB *l2cu_allocate_ccb (tL2C_LCB *p_lcb, UINT16 cid)
l2c_fcr_free_timer (p_ccb);
#endif ///CLASSIC_BT_INCLUDED == TRUE
p_ccb->ertm_info.preferred_mode = L2CAP_FCR_BASIC_MODE; /* Default mode for channel is basic mode */
p_ccb->ertm_info.allowed_modes = L2CAP_FCR_CHAN_OPT_BASIC; /* Default mode for channel is basic mode */
p_ccb->ertm_info.allowed_modes = L2CAP_FCR_CHAN_OPT_BASIC|L2CAP_FCR_CHAN_OPT_BASIC;
p_ccb->ertm_info.fcr_rx_buf_size = L2CAP_FCR_RX_BUF_SIZE;
p_ccb->ertm_info.fcr_tx_buf_size = L2CAP_FCR_TX_BUF_SIZE;
p_ccb->ertm_info.user_rx_buf_size = L2CAP_USER_RX_BUF_SIZE;

View File

@ -36,6 +36,17 @@
#include "osi/mutex.h"
#include "osi/alarm.h"
#if (defined RFCOMM_INCLUDED && RFCOMM_INCLUDED == TRUE)
static tL2CAP_ERTM_INFO rfc_l2c_etm_opt =
{
L2CAP_FCR_ERTM_MODE,
L2CAP_FCR_CHAN_OPT_ERTM|L2CAP_FCR_CHAN_OPT_BASIC, /* Some devices do not support ERTM */
L2CAP_USER_RX_BUF_SIZE,
L2CAP_USER_TX_BUF_SIZE,
L2CAP_FCR_RX_BUF_SIZE,
L2CAP_FCR_TX_BUF_SIZE
};
/*
** Define Callback functions to be called by L2CAP
*/
@ -117,7 +128,8 @@ void RFCOMM_ConnectInd (BD_ADDR bd_addr, UINT16 lcid, UINT16 psm, UINT8 id)
}
if (p_mcb == NULL) {
L2CA_ConnectRsp (bd_addr, id, lcid, L2CAP_CONN_NO_RESOURCES, 0);
// L2CA_ConnectRsp (bd_addr, id, lcid, L2CAP_CONN_NO_RESOURCES, 0);
L2CA_ErtmConnectRsp (bd_addr, id, lcid, L2CAP_CONN_NO_RESOURCES, 0, &rfc_l2c_etm_opt);
return;
}
p_mcb->lcid = lcid;
@ -178,7 +190,9 @@ void RFCOMM_ConnectCnf (UINT16 lcid, UINT16 result)
RFCOMM_TRACE_DEBUG ("RFCOMM_ConnectCnf peer gave up pending LCID(0x%x)", p_mcb->pending_lcid);
/* Peer gave up his connection request, make sure cleaning up L2CAP channel */
L2CA_ConnectRsp (p_mcb->bd_addr, p_mcb->pending_id, p_mcb->pending_lcid, L2CAP_CONN_NO_RESOURCES, 0);
// L2CA_ConnectRsp (p_mcb->bd_addr, p_mcb->pending_id, p_mcb->pending_lcid, L2CAP_CONN_NO_RESOURCES, 0);
L2CA_ErtmConnectRsp (p_mcb->bd_addr, p_mcb->pending_id, p_mcb->pending_lcid, L2CAP_CONN_NO_RESOURCES, 0,
&rfc_l2c_etm_opt);
p_mcb->pending_lcid = 0;
}

View File

@ -39,6 +39,25 @@
#define L2CAP_SUCCESS 0
#define L2CAP_ERROR 1
static tL2CAP_ERTM_INFO rfc_l2c_etm_opt =
{
L2CAP_FCR_ERTM_MODE,
L2CAP_FCR_CHAN_OPT_ERTM|L2CAP_FCR_CHAN_OPT_BASIC, /* Some devices do not support ERTM */
L2CAP_USER_RX_BUF_SIZE,
L2CAP_USER_TX_BUF_SIZE,
L2CAP_FCR_RX_BUF_SIZE,
L2CAP_FCR_TX_BUF_SIZE
};
static tL2CAP_FCR_OPTS rfc_l2c_fcr_opts_def =
{
L2CAP_FCR_ERTM_MODE,
RFC_FCR_OPT_TX_WINDOW_SIZE, /* Tx window size */
RFC_FCR_OPT_MAX_TX_B4_DISCNT, /* Maximum transmissions before disconnecting */
RFC_FCR_OPT_RETX_TOUT, /* Retransmission timeout (2 secs) */
RFC_FCR_OPT_MONITOR_TOUT, /* Monitor timeout (12 secs) */
RFC_FCR_OPT_MAX_PDU_SIZE /* MPS segment size */
};
/********************************************************************************/
/* L O C A L F U N C T I O N P R O T O T Y P E S */
@ -124,7 +143,8 @@ void rfc_mx_sm_state_idle (tRFC_MCB *p_mcb, UINT16 event, void *p_data)
/* Initialize L2CAP MTU */
p_mcb->peer_l2cap_mtu = L2CAP_DEFAULT_MTU - RFCOMM_MIN_OFFSET - 1;
if ((p_mcb->lcid = L2CA_ConnectReq (BT_PSM_RFCOMM, p_mcb->bd_addr)) == 0) {
// if ((p_mcb->lcid = L2CA_ConnectReq (BT_PSM_RFCOMM, p_mcb->bd_addr)) == 0) {
if ((p_mcb->lcid = L2CA_ErtmConnectReq (BT_PSM_RFCOMM, p_mcb->bd_addr, &rfc_l2c_etm_opt)) == 0) {
PORT_StartCnf (p_mcb, RFCOMM_ERROR);
return;
}
@ -144,7 +164,8 @@ void rfc_mx_sm_state_idle (tRFC_MCB *p_mcb, UINT16 event, void *p_data)
case RFC_MX_EVENT_CONN_IND:
rfc_timer_start (p_mcb, RFCOMM_CONN_TIMEOUT);
L2CA_ConnectRsp (p_mcb->bd_addr, *((UINT8 *)p_data), p_mcb->lcid, L2CAP_CONN_OK, 0);
// L2CA_ConnectRsp (p_mcb->bd_addr, *((UINT8 *)p_data), p_mcb->lcid, L2CAP_CONN_OK, 0);
L2CA_ErtmConnectRsp (p_mcb->bd_addr, *((UINT8 *)p_data), p_mcb->lcid, L2CAP_CONN_OK, 0, &rfc_l2c_etm_opt);
rfc_mx_send_config_req (p_mcb);
@ -482,7 +503,8 @@ void rfc_mx_sm_state_disc_wait_ua (tRFC_MCB *p_mcb, UINT16 event, void *p_data)
if (p_mcb->restart_required) {
/* Start Request was received while disconnecting. Execute it again */
if ((p_mcb->lcid = L2CA_ConnectReq (BT_PSM_RFCOMM, p_mcb->bd_addr)) == 0) {
// if ((p_mcb->lcid = L2CA_ConnectReq (BT_PSM_RFCOMM, p_mcb->bd_addr)) == 0) {
if ((p_mcb->lcid = L2CA_ErtmConnectReq (BT_PSM_RFCOMM, p_mcb->bd_addr, &rfc_l2c_etm_opt)) == 0) {
PORT_StartCnf (p_mcb, RFCOMM_ERROR);
return;
}
@ -554,6 +576,9 @@ static void rfc_mx_send_config_req (tRFC_MCB *p_mcb)
cfg.mtu_present = TRUE;
cfg.mtu = L2CAP_MTU_SIZE;
cfg.fcr_present = TRUE;
cfg.fcr = rfc_l2c_fcr_opts_def;
/* Defaults set by memset
cfg.flush_to_present = FALSE;
cfg.qos_present = FALSE;