mirror of
https://github.com/espressif/esp-nimble.git
synced 2026-08-17 15:30:11 +00:00
nimble/l2cap: Minor change to avoid confusion on MPS/MTU meaning
This commit is contained in:
@@ -290,7 +290,7 @@ ble_l2cap_coc_chan_alloc(struct ble_hs_conn *conn, uint16_t psm, uint16_t mtu,
|
||||
chan->cb = cb;
|
||||
chan->cb_arg = cb_arg;
|
||||
chan->scid = ble_l2cap_coc_get_cid(conn->l2cap_coc_cid_mask);
|
||||
chan->my_mtu = MYNEWT_VAL(BLE_L2CAP_COC_MPS);
|
||||
chan->my_coc_mps = MYNEWT_VAL(BLE_L2CAP_COC_MPS);
|
||||
chan->rx_fn = ble_l2cap_coc_rx_fn;
|
||||
chan->coc_rx.mtu = mtu;
|
||||
chan->coc_rx.sdu = sdu_rx;
|
||||
@@ -298,8 +298,8 @@ ble_l2cap_coc_chan_alloc(struct ble_hs_conn *conn, uint16_t psm, uint16_t mtu,
|
||||
/* Number of credits should allow to send full SDU with on given
|
||||
* L2CAP MTU
|
||||
*/
|
||||
chan->coc_rx.credits = mtu / chan->my_mtu;
|
||||
if (mtu % chan->my_mtu) {
|
||||
chan->coc_rx.credits = mtu / chan->my_coc_mps;
|
||||
if (mtu % chan->my_coc_mps) {
|
||||
chan->coc_rx.credits++;
|
||||
}
|
||||
|
||||
@@ -412,7 +412,7 @@ ble_l2cap_coc_continue_tx(struct ble_l2cap_chan *chan)
|
||||
}
|
||||
|
||||
/* Take into account peer MTU */
|
||||
len = min(left_to_send, chan->peer_mtu);
|
||||
len = min(left_to_send, chan->peer_coc_mps);
|
||||
|
||||
/* Prepare packet */
|
||||
txom = ble_hs_mbuf_l2cap_pkt();
|
||||
|
||||
@@ -65,8 +65,20 @@ struct ble_l2cap_chan {
|
||||
uint16_t conn_handle;
|
||||
uint16_t dcid;
|
||||
uint16_t scid;
|
||||
uint16_t my_mtu;
|
||||
uint16_t peer_mtu; /* 0 if not exchanged. */
|
||||
|
||||
/* Unions just to avoid confusion on MPS/MTU.
|
||||
* In CoC context, L2CAP MTU is MPS
|
||||
*/
|
||||
union {
|
||||
uint16_t my_mtu;
|
||||
uint16_t my_coc_mps;
|
||||
};
|
||||
|
||||
union {
|
||||
uint16_t peer_mtu;
|
||||
uint16_t peer_coc_mps;
|
||||
};
|
||||
|
||||
ble_l2cap_chan_flags flags;
|
||||
|
||||
struct os_mbuf *rx_buf;
|
||||
|
||||
@@ -692,7 +692,7 @@ ble_l2cap_sig_coc_req_rx(uint16_t conn_handle, struct ble_l2cap_sig_hdr *hdr,
|
||||
|
||||
/* Fill up remote configuration. Note MPS is the L2CAP MTU*/
|
||||
chan->dcid = scid;
|
||||
chan->peer_mtu = le16toh(req->mps);
|
||||
chan->peer_coc_mps = le16toh(req->mps);
|
||||
chan->coc_tx.credits = le16toh(req->credits);
|
||||
chan->coc_tx.mtu = le16toh(req->mtu);
|
||||
|
||||
@@ -716,7 +716,7 @@ ble_l2cap_sig_coc_req_rx(uint16_t conn_handle, struct ble_l2cap_sig_hdr *hdr,
|
||||
|
||||
rsp->dcid = htole16(chan->scid);
|
||||
rsp->credits = htole16(chan->coc_rx.credits);
|
||||
rsp->mps = htole16(chan->my_mtu);
|
||||
rsp->mps = htole16(chan->my_coc_mps);
|
||||
rsp->mtu = htole16(chan->coc_rx.mtu);
|
||||
rsp->result = htole16(BLE_L2CAP_COC_ERR_CONNECTION_SUCCESS);
|
||||
|
||||
@@ -777,7 +777,7 @@ ble_l2cap_sig_coc_rsp_rx(uint16_t conn_handle, struct ble_l2cap_sig_hdr *hdr,
|
||||
/* Fill up remote configuration
|
||||
* Note MPS is the L2CAP MTU
|
||||
*/
|
||||
chan->peer_mtu = le16toh(rsp->mps);
|
||||
chan->peer_coc_mps = le16toh(rsp->mps);
|
||||
chan->dcid = le16toh(rsp->dcid);
|
||||
chan->coc_tx.mtu = le16toh(rsp->mtu);
|
||||
chan->coc_tx.credits = le16toh(rsp->credits);
|
||||
@@ -851,7 +851,7 @@ ble_l2cap_sig_coc_connect(uint16_t conn_handle, uint16_t psm, uint16_t mtu,
|
||||
req->psm = htole16(psm);
|
||||
req->scid = htole16(chan->scid);
|
||||
req->mtu = htole16(chan->coc_rx.mtu);
|
||||
req->mps = htole16(chan->my_mtu);
|
||||
req->mps = htole16(chan->my_coc_mps);
|
||||
req->credits = htole16(chan->coc_rx.credits);
|
||||
|
||||
ble_hs_unlock();
|
||||
|
||||
Reference in New Issue
Block a user