Zephyr API Documentation 4.2.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
bt_l2cap_fixed_chan Struct Reference

Fixed L2CAP Channel structure. More...

#include <zephyr/bluetooth/l2cap.h>

Data Fields

uint16_t cid
 Channel Identifier (CID)
int(* accept )(struct bt_conn *conn, struct bt_l2cap_chan **chan)
 Channel accept callback.

Detailed Description

Fixed L2CAP Channel structure.

Should be defined using the BT_L2CAP_FIXED_CHANNEL_DEFINE macro.

Field Documentation

◆ accept

int(* bt_l2cap_fixed_chan::accept) (struct bt_conn *conn, struct bt_l2cap_chan **chan)

Channel accept callback.

This callback needs to be provided by the application, and is invoked when a new connection has been established. If accepting the connection, the user is expected to allocate memory with suitable alignment for the type bt_l2cap_chan for the channel, and update the channel reference chan to point to the allocated memory. The channel should be initialized by assigning the callbacks to the bt_l2cap_chan_ops field as follows:

static int accept(struct bt_conn *conn, struct bt_l2cap_chan **chan)
{
// Allocation of fixed_chan and definition of the ops are assumed done prior.
*chan = &fixed_chan;
**chan = (struct bt_l2cap_chan){
.ops = &ops,
};
return 0;
}
L2CAP Channel structure.
Definition l2cap.h:218
const struct bt_l2cap_chan_ops * ops
Channel operations reference.
Definition l2cap.h:222
int(* accept)(struct bt_conn *conn, struct bt_l2cap_chan **chan)
Channel accept callback.
Definition l2cap.h:356

The allocated context needs to be valid for the lifetime of the channel, i. e. freeing of the memory can be done in the bt_l2cap_chan_ops::released callback.

Parameters
connThe connection that has been established.
chanL2CAP channel reference.
Returns
0 to accept the channel connection, negative error code otherwise.

◆ cid

uint16_t bt_l2cap_fixed_chan::cid

Channel Identifier (CID)

Note
Shall be in the range 0x0001 to 0x003F (Core 3.A.2.1 v6.0). The CIDs in this range are reserved by the stack, so the application needs to make sure that the CID is not already in use. Table 2.1 in Core 3.A.2.1 and L2CAP channel identifiers shows the CIDs used by the stack.

The documentation for this struct was generated from the following file: