Zephyr API Documentation 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches

RFCOMM. More...

Data Structures

struct  bt_rfcomm_dlc_ops
 RFCOMM DLC operations structure. More...
struct  bt_rfcomm_dlc
 RFCOMM DLC structure. More...
struct  bt_rfcomm_server
struct  bt_rfcomm_rpn
 RFCOMM Remote Port Negotiation (RPN) structure. More...

Macros

#define BT_RFCOMM_HDR_MAX_SIZE   4
 RFCOMM Maximum Header Size.
#define BT_RFCOMM_FCS_SIZE   1
 RFCOMM FCS Size.
#define BT_RFCOMM_CREDITS_SIZE   1
 RFCOMM Credits Size.
#define BT_RFCOMM_OVERHEAD_SIZE   (BT_RFCOMM_HDR_MAX_SIZE + BT_RFCOMM_FCS_SIZE + BT_RFCOMM_CREDITS_SIZE)
 RFCOMM Overhead Size.
#define BT_RFCOMM_BUF_SIZE(mtu)
 Helper to calculate needed buffer size for RFCOMM PDUs.
#define BT_RFCOMM_SET_LINE_SETTINGS(data, stop, parity)
 Combine data bits, stop bits and parity into a single line settings byte.
#define BT_RFCOMM_RPN_FLOW_NONE   0x00
#define BT_RFCOMM_RPN_XON_CHAR   0x11
#define BT_RFCOMM_RPN_XOFF_CHAR   0x13
#define BT_RFCOMM_RPN_PARAM_MASK_ALL   0x3f7f
#define BT_RFCOMM_RLS_NO_ERR   (0x00U)
 Remote Line Status value: No error.
#define BT_RFCOMM_RLS_ERR(err)
 Remote Line Status value: error occurred.
#define BT_RFCOMM_RLS_ERR_OVERRUN_ERROR   BIT(1)
 Overrun Error - Received character overwrote an unread character.
#define BT_RFCOMM_RLS_ERR_PARITY_ERROR   BIT(2)
 Parity Error - Received character's parity was incorrect.
#define BT_RFCOMM_RLS_ERR_FRAMING_ERROR   BIT(3)
 Framing Error - a character did not terminate with a stop bit.

Typedefs

typedef enum bt_rfcomm_role bt_rfcomm_role_t
 Role of RFCOMM session and dlc.

Enumerations

enum  {
  BT_RFCOMM_CHAN_HFP_HF = 1 , BT_RFCOMM_CHAN_HFP_AG , BT_RFCOMM_CHAN_HSP_AG , BT_RFCOMM_CHAN_HSP_HS ,
  BT_RFCOMM_CHAN_SPP , BT_RFCOMM_CHAN_DYNAMIC_START
}
enum  bt_rfcomm_role { BT_RFCOMM_ROLE_ACCEPTOR , BT_RFCOMM_ROLE_INITIATOR }
 Role of RFCOMM session and dlc. More...
enum  {
  BT_RFCOMM_RPN_BAUD_RATE_2400 = 0x0 , BT_RFCOMM_RPN_BAUD_RATE_4800 = 0x1 , BT_RFCOMM_RPN_BAUD_RATE_7200 = 0x2 , BT_RFCOMM_RPN_BAUD_RATE_9600 = 0x3 ,
  BT_RFCOMM_RPN_BAUD_RATE_19200 = 0x4 , BT_RFCOMM_RPN_BAUD_RATE_38400 = 0x5 , BT_RFCOMM_RPN_BAUD_RATE_57600 = 0x6 , BT_RFCOMM_RPN_BAUD_RATE_115200 = 0x7 ,
  BT_RFCOMM_RPN_BAUD_RATE_230400 = 0x8
}
 RFCOMM RPN baud rate values. More...
enum  { BT_RFCOMM_RPN_DATA_BITS_5 = 0x0 , BT_RFCOMM_RPN_DATA_BITS_6 = 0x1 , BT_RFCOMM_RPN_DATA_BITS_7 = 0x2 , BT_RFCOMM_RPN_DATA_BITS_8 = 0x3 }
 RFCOMM RPN data bit values. More...
enum  { BT_RFCOMM_RPN_STOP_BITS_1 = 0 , BT_RFCOMM_RPN_STOP_BITS_1_5 = 1 }
 RFCOMM RPN stop bit values. More...
enum  {
  BT_RFCOMM_RPN_PARITY_NONE = 0x0 , BT_RFCOMM_RPN_PARITY_ODD = 0x1 , BT_RFCOMM_RPN_PARITY_EVEN = 0x3 , BT_RFCOMM_RPN_PARITY_MARK = 0x5 ,
  BT_RFCOMM_RPN_PARITY_SPACE = 0x7
}
 RFCOMM RPN parity bit values. More...

Functions

int bt_rfcomm_server_register (struct bt_rfcomm_server *server)
 Register RFCOMM server.
int bt_rfcomm_server_unregister (struct bt_rfcomm_server *server)
 Unregister RFCOMM server.
int bt_rfcomm_dlc_connect (struct bt_conn *conn, struct bt_rfcomm_dlc *dlc, uint8_t channel)
 Connect RFCOMM channel.
int bt_rfcomm_dlc_send (struct bt_rfcomm_dlc *dlc, struct net_buf *buf)
 Send data to RFCOMM.
int bt_rfcomm_dlc_disconnect (struct bt_rfcomm_dlc *dlc)
 Disconnect RFCOMM dlc.
struct net_bufbt_rfcomm_create_pdu (struct net_buf_pool *pool)
 Allocate the buffer from pool after reserving head room for RFCOMM, L2CAP and ACL headers.
int bt_rfcomm_send_rpn_cmd (struct bt_rfcomm_dlc *dlc, struct bt_rfcomm_rpn *rpn)
 Send Remote Port Negotiation command.
int bt_rfcomm_send_rls_cmd (struct bt_rfcomm_dlc *dlc, uint8_t line_status)
 Send Remote Line Status Command.

Detailed Description

RFCOMM.

Since
1.6
Version
0.1.0

Macro Definition Documentation

◆ BT_RFCOMM_BUF_SIZE

#define BT_RFCOMM_BUF_SIZE ( mtu)

#include <zephyr/bluetooth/classic/rfcomm.h>

Value:
#define BT_L2CAP_BUF_SIZE(mtu)
Helper to calculate needed buffer size for L2CAP PDUs.
Definition l2cap.h:56
#define BT_RFCOMM_OVERHEAD_SIZE
RFCOMM Overhead Size.
Definition rfcomm.h:46

Helper to calculate needed buffer size for RFCOMM PDUs.

Useful for creating buffer pools.

Parameters
mtuNeeded RFCOMM PDU MTU.
Returns
Needed buffer size to match the requested RFCOMM PDU MTU.

◆ BT_RFCOMM_CREDITS_SIZE

#define BT_RFCOMM_CREDITS_SIZE   1

#include <zephyr/bluetooth/classic/rfcomm.h>

RFCOMM Credits Size.

◆ BT_RFCOMM_FCS_SIZE

#define BT_RFCOMM_FCS_SIZE   1

#include <zephyr/bluetooth/classic/rfcomm.h>

RFCOMM FCS Size.

◆ BT_RFCOMM_HDR_MAX_SIZE

#define BT_RFCOMM_HDR_MAX_SIZE   4

#include <zephyr/bluetooth/classic/rfcomm.h>

RFCOMM Maximum Header Size.

The length could be 2 bytes, it depends on information length.

◆ BT_RFCOMM_OVERHEAD_SIZE

#define BT_RFCOMM_OVERHEAD_SIZE   (BT_RFCOMM_HDR_MAX_SIZE + BT_RFCOMM_FCS_SIZE + BT_RFCOMM_CREDITS_SIZE)

#include <zephyr/bluetooth/classic/rfcomm.h>

RFCOMM Overhead Size.

The overhead size of RFCOMM includes the maximum header size, FCS size, and credits size.

For the field credits size, in the CFC supported case, the space of credits should be discounted from the maximum frame size. It is used to avoid the SDU length exceeding the maximum frame size if the credits field is included.

◆ BT_RFCOMM_RLS_ERR

#define BT_RFCOMM_RLS_ERR ( err)

#include <zephyr/bluetooth/classic/rfcomm.h>

Value:
(BIT(0) | (err))
#define BIT(n)
Unsigned integer with bit position n set (signed in assembly language).
Definition util_macro.h:44

Remote Line Status value: error occurred.

Parameters
errError code to be set in the RLS value; must be one of the following values: BT_RFCOMM_RLS_ERR_OVERRUN_ERROR, BT_RFCOMM_RLS_ERR_PARITY_ERROR, or BT_RFCOMM_RLS_ERR_FRAMING_ERROR.
Returns
RLS value with error code set.

◆ BT_RFCOMM_RLS_ERR_FRAMING_ERROR

#define BT_RFCOMM_RLS_ERR_FRAMING_ERROR   BIT(3)

#include <zephyr/bluetooth/classic/rfcomm.h>

Framing Error - a character did not terminate with a stop bit.

◆ BT_RFCOMM_RLS_ERR_OVERRUN_ERROR

#define BT_RFCOMM_RLS_ERR_OVERRUN_ERROR   BIT(1)

#include <zephyr/bluetooth/classic/rfcomm.h>

Overrun Error - Received character overwrote an unread character.

◆ BT_RFCOMM_RLS_ERR_PARITY_ERROR

#define BT_RFCOMM_RLS_ERR_PARITY_ERROR   BIT(2)

#include <zephyr/bluetooth/classic/rfcomm.h>

Parity Error - Received character's parity was incorrect.

◆ BT_RFCOMM_RLS_NO_ERR

#define BT_RFCOMM_RLS_NO_ERR   (0x00U)

#include <zephyr/bluetooth/classic/rfcomm.h>

Remote Line Status value: No error.

◆ BT_RFCOMM_RPN_FLOW_NONE

#define BT_RFCOMM_RPN_FLOW_NONE   0x00

◆ BT_RFCOMM_RPN_PARAM_MASK_ALL

#define BT_RFCOMM_RPN_PARAM_MASK_ALL   0x3f7f

◆ BT_RFCOMM_RPN_XOFF_CHAR

#define BT_RFCOMM_RPN_XOFF_CHAR   0x13

◆ BT_RFCOMM_RPN_XON_CHAR

#define BT_RFCOMM_RPN_XON_CHAR   0x11

◆ BT_RFCOMM_SET_LINE_SETTINGS

#define BT_RFCOMM_SET_LINE_SETTINGS ( data,
stop,
parity )

#include <zephyr/bluetooth/classic/rfcomm.h>

Value:
((data & 0x3) | \
((stop & 0x1) << 2) | \
((parity & 0x7) << 3))

Combine data bits, stop bits and parity into a single line settings byte.

Parameters
dataData bits value (0-3)
stopStop bits value (0-1)
parityParity value (0-7)
Returns
Combined line settings byte

Typedef Documentation

◆ bt_rfcomm_role_t

#include <zephyr/bluetooth/classic/rfcomm.h>

Role of RFCOMM session and dlc.

Used only by internal APIs

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

#include <zephyr/bluetooth/classic/rfcomm.h>

RFCOMM RPN baud rate values.

Enumerator
BT_RFCOMM_RPN_BAUD_RATE_2400 
BT_RFCOMM_RPN_BAUD_RATE_4800 
BT_RFCOMM_RPN_BAUD_RATE_7200 
BT_RFCOMM_RPN_BAUD_RATE_9600 
BT_RFCOMM_RPN_BAUD_RATE_19200 
BT_RFCOMM_RPN_BAUD_RATE_38400 
BT_RFCOMM_RPN_BAUD_RATE_57600 
BT_RFCOMM_RPN_BAUD_RATE_115200 
BT_RFCOMM_RPN_BAUD_RATE_230400 

◆ anonymous enum

anonymous enum

#include <zephyr/bluetooth/classic/rfcomm.h>

RFCOMM RPN data bit values.

Enumerator
BT_RFCOMM_RPN_DATA_BITS_5 
BT_RFCOMM_RPN_DATA_BITS_6 
BT_RFCOMM_RPN_DATA_BITS_7 
BT_RFCOMM_RPN_DATA_BITS_8 

◆ anonymous enum

anonymous enum

#include <zephyr/bluetooth/classic/rfcomm.h>

Enumerator
BT_RFCOMM_CHAN_HFP_HF 
BT_RFCOMM_CHAN_HFP_AG 
BT_RFCOMM_CHAN_HSP_AG 
BT_RFCOMM_CHAN_HSP_HS 
BT_RFCOMM_CHAN_SPP 
BT_RFCOMM_CHAN_DYNAMIC_START 

◆ anonymous enum

anonymous enum

#include <zephyr/bluetooth/classic/rfcomm.h>

RFCOMM RPN parity bit values.

Enumerator
BT_RFCOMM_RPN_PARITY_NONE 
BT_RFCOMM_RPN_PARITY_ODD 
BT_RFCOMM_RPN_PARITY_EVEN 
BT_RFCOMM_RPN_PARITY_MARK 
BT_RFCOMM_RPN_PARITY_SPACE 

◆ anonymous enum

anonymous enum

#include <zephyr/bluetooth/classic/rfcomm.h>

RFCOMM RPN stop bit values.

Enumerator
BT_RFCOMM_RPN_STOP_BITS_1 
BT_RFCOMM_RPN_STOP_BITS_1_5 

◆ bt_rfcomm_role

#include <zephyr/bluetooth/classic/rfcomm.h>

Role of RFCOMM session and dlc.

Used only by internal APIs

Enumerator
BT_RFCOMM_ROLE_ACCEPTOR 
BT_RFCOMM_ROLE_INITIATOR 

Function Documentation

◆ bt_rfcomm_create_pdu()

struct net_buf * bt_rfcomm_create_pdu ( struct net_buf_pool * pool)

#include <zephyr/bluetooth/classic/rfcomm.h>

Allocate the buffer from pool after reserving head room for RFCOMM, L2CAP and ACL headers.

Parameters
poolWhich pool to take the buffer from.
Returns
New buffer.

◆ bt_rfcomm_dlc_connect()

int bt_rfcomm_dlc_connect ( struct bt_conn * conn,
struct bt_rfcomm_dlc * dlc,
uint8_t channel )

#include <zephyr/bluetooth/classic/rfcomm.h>

Connect RFCOMM channel.

Connect RFCOMM dlc by channel, once the connection is completed dlc connected() callback will be called. If the connection is rejected disconnected() callback is called instead.

Parameters
connConnection object.
dlcDlc object.
channelServer channel to connect to.
Returns
0 in case of success or negative value in case of error.

◆ bt_rfcomm_dlc_disconnect()

int bt_rfcomm_dlc_disconnect ( struct bt_rfcomm_dlc * dlc)

#include <zephyr/bluetooth/classic/rfcomm.h>

Disconnect RFCOMM dlc.

Disconnect RFCOMM dlc, if the connection is pending it will be canceled and as a result the dlc disconnected() callback is called.

Parameters
dlcDlc object.
Returns
0 in case of success or negative value in case of error.

◆ bt_rfcomm_dlc_send()

int bt_rfcomm_dlc_send ( struct bt_rfcomm_dlc * dlc,
struct net_buf * buf )

#include <zephyr/bluetooth/classic/rfcomm.h>

Send data to RFCOMM.

Send data from buffer to the dlc. Length should be less than or equal to mtu.

Parameters
dlcDlc object.
bufData buffer.
Returns
Bytes sent in case of success or negative value in case of error.

◆ bt_rfcomm_send_rls_cmd()

int bt_rfcomm_send_rls_cmd ( struct bt_rfcomm_dlc * dlc,
uint8_t line_status )

#include <zephyr/bluetooth/classic/rfcomm.h>

Send Remote Line Status Command.

Send remote line status with specific rls value line_status to the RFCOMM DLC. For line_status, the BIT(4-7) are reserved and must be set to 0. The BIT(0-3) indicate the Line Status. If the BIT(0) is set to 0, there is no error occurred. If the BIT(0) is set to 1, the error is indicated by BIT(1-3) with the following values: BT_RFCOMM_RLS_ERR_OVERRUN_ERROR - Received character overwrote an unread character. BT_RFCOMM_RLS_ERR_PARITY_ERROR - Received character's parity was incorrect. BT_RFCOMM_RLS_ERR_FRAMING_ERROR - a character did not terminate with a stop bit.

line_status can be created using BT_RFCOMM_RLS_NO_ERR and BT_RFCOMM_RLS_ERR macros.

Parameters
dlcPointer to the RFCOMM DLC
line_statusLine Status value
Returns
0 on success, negative error code on failure

◆ bt_rfcomm_send_rpn_cmd()

int bt_rfcomm_send_rpn_cmd ( struct bt_rfcomm_dlc * dlc,
struct bt_rfcomm_rpn * rpn )

#include <zephyr/bluetooth/classic/rfcomm.h>

Send Remote Port Negotiation command.

Parameters
dlcPointer to the RFCOMM DLC
rpnPointer to the RPN parameters to send
Returns
0 on success, negative error code on failure

◆ bt_rfcomm_server_register()

int bt_rfcomm_server_register ( struct bt_rfcomm_server * server)

#include <zephyr/bluetooth/classic/rfcomm.h>

Register RFCOMM server.

Register RFCOMM server for a channel, each new connection is authorized using the accept() callback which in case of success shall allocate the dlc structure to be used by the new connection.

Parameters
serverServer structure.
Returns
0 in case of success or negative value in case of error.

◆ bt_rfcomm_server_unregister()

int bt_rfcomm_server_unregister ( struct bt_rfcomm_server * server)

#include <zephyr/bluetooth/classic/rfcomm.h>

Unregister RFCOMM server.

Unregister RFCOMM server for a channel.

Parameters
serverServer structure.
Returns
0 in case of success or negative value in case of error.