Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bluetooth: RFCOMM: Move BT_RFCOMM_BUF_SIZE to rfcomm.h #83787

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions include/zephyr/bluetooth/classic/rfcomm.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,27 @@

#include <zephyr/bluetooth/buf.h>
#include <zephyr/bluetooth/conn.h>
#include <zephyr/bluetooth/l2cap.h>

#ifdef __cplusplus
extern "C" {
#endif

/** RFCOMM Maximum Header Size. The length could be 2 bytes, it depends on information length. */
#define BT_RFCOMM_HDR_MAX_SIZE 4
/** RFCOMM FCS Size */
#define BT_RFCOMM_FCS_SIZE 1

/** @brief Helper to calculate needed buffer size for RFCOMM PDUs.
* Useful for creating buffer pools.
*
* @param mtu Needed RFCOMM PDU MTU.
*
* @return Needed buffer size to match the requested RFCOMM PDU MTU.
*/
#define BT_RFCOMM_BUF_SIZE(mtu) \
BT_L2CAP_BUF_SIZE(BT_RFCOMM_HDR_MAX_SIZE + BT_RFCOMM_FCS_SIZE + (mtu))

/* RFCOMM channels (1-30): pre-allocated for profiles to avoid conflicts */
enum {
BT_RFCOMM_CHAN_HFP_HF = 1,
Expand Down
10 changes: 0 additions & 10 deletions subsys/bluetooth/host/classic/rfcomm_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,6 @@ struct bt_rfcomm_rpn {
#define BT_RFCOMM_CHECK_MTU(mtu) (!!((mtu) >= BT_RFCOMM_SIG_MIN_MTU && \
(mtu) <= BT_RFCOMM_SIG_MAX_MTU))

/* Helper to calculate needed outgoing buffer size.
* Length in rfcomm header can be two bytes depending on user data length.
* One byte in the tail should be reserved for FCS.
*/
#define BT_RFCOMM_BUF_SIZE(mtu) (BT_BUF_RESERVE + \
BT_HCI_ACL_HDR_SIZE + BT_L2CAP_HDR_SIZE + \
sizeof(struct bt_rfcomm_hdr) + 1 + (mtu) + \
BT_RFCOMM_FCS_SIZE)

#define BT_RFCOMM_GET_DLCI(addr) (((addr) & 0xfc) >> 2)
#define BT_RFCOMM_GET_FRAME_TYPE(ctrl) ((ctrl) & 0xef)
#define BT_RFCOMM_GET_MSG_TYPE(type) (((type) & 0xfc) >> 2)
Expand Down Expand Up @@ -192,7 +183,6 @@ struct bt_rfcomm_rpn {

/* Length can be 2 bytes depending on data size */
#define BT_RFCOMM_HDR_SIZE (sizeof(struct bt_rfcomm_hdr) + 1)
#define BT_RFCOMM_FCS_SIZE 1

#define BT_RFCOMM_FCS_LEN_UIH 2
#define BT_RFCOMM_FCS_LEN_NON_UIH 3
Expand Down
Loading