Zephyr API Documentation
3.7.0
A Scalable Open Source RTOS
|
L2CAP Channel operations structure. More...
#include <l2cap.h>
Data Fields | |
void(* | connected )(struct bt_l2cap_chan *chan) |
Channel connected callback. | |
void(* | disconnected )(struct bt_l2cap_chan *chan) |
Channel disconnected callback. | |
void(* | encrypt_change )(struct bt_l2cap_chan *chan, uint8_t hci_status) |
Channel encrypt_change callback. | |
struct net_buf *(* | alloc_seg )(struct bt_l2cap_chan *chan) |
Channel alloc_seg callback. | |
struct net_buf *(* | alloc_buf )(struct bt_l2cap_chan *chan) |
Channel alloc_buf callback. | |
int(* | recv )(struct bt_l2cap_chan *chan, struct net_buf *buf) |
Channel recv callback. | |
void(* | sent )(struct bt_l2cap_chan *chan) |
Channel sent callback. | |
void(* | status )(struct bt_l2cap_chan *chan, atomic_t *status) |
Channel status callback. | |
void(* | released )(struct bt_l2cap_chan *chan) |
void(* | reconfigured )(struct bt_l2cap_chan *chan) |
Channel reconfigured callback. | |
void(* | seg_recv )(struct bt_l2cap_chan *chan, size_t sdu_len, off_t seg_offset, struct net_buf_simple *seg) |
Handle L2CAP segments directly. | |
L2CAP Channel operations structure.
struct net_buf *(* bt_l2cap_chan_ops::alloc_buf) (struct bt_l2cap_chan *chan) |
Channel alloc_buf callback.
If this callback is provided the channel will use it to allocate buffers to store incoming data. Channels that requires segmentation must set this callback. If the application has not set a callback the L2CAP SDU MTU will be truncated to BT_L2CAP_SDU_RX_MTU.
chan | The channel requesting a buffer. |
struct net_buf *(* bt_l2cap_chan_ops::alloc_seg) (struct bt_l2cap_chan *chan) |
Channel alloc_seg callback.
If this callback is provided the channel will use it to allocate buffers to store segments. This avoids wasting big SDU buffers with potentially much smaller PDUs. If this callback is supplied, it must return a valid buffer.
chan | The channel requesting a buffer. |
void(* bt_l2cap_chan_ops::connected) (struct bt_l2cap_chan *chan) |
Channel connected callback.
If this callback is provided it will be called whenever the connection completes.
chan | The channel that has been connected |
void(* bt_l2cap_chan_ops::disconnected) (struct bt_l2cap_chan *chan) |
Channel disconnected callback.
If this callback is provided it will be called whenever the channel is disconnected, including when a connection gets rejected.
chan | The channel that has been Disconnected |
void(* bt_l2cap_chan_ops::encrypt_change) (struct bt_l2cap_chan *chan, uint8_t hci_status) |
Channel encrypt_change callback.
If this callback is provided it will be called whenever the security level changed (indirectly link encryption done) or authentication procedure fails. In both cases security initiator and responder got the final status (HCI status) passed by related to encryption and authentication events from local host's controller.
chan | The channel which has made encryption status changed. |
status | HCI status of performed security procedure caused by channel security requirements. The value is populated by HCI layer and set to 0 when success and to non-zero (reference to HCI Error Codes) when security/authentication failed. |
void(* bt_l2cap_chan_ops::reconfigured) (struct bt_l2cap_chan *chan) |
Channel reconfigured callback.
If this callback is provided it will be called whenever peer or local device requested reconfiguration. Application may check updated MTU and MPS values by inspecting chan->le endpoints.
chan | The channel which was reconfigured |
int(* bt_l2cap_chan_ops::recv) (struct bt_l2cap_chan *chan, struct net_buf *buf) |
Channel recv callback.
chan | The channel receiving data. |
buf | Buffer containing incoming data. |
void(* bt_l2cap_chan_ops::released) (struct bt_l2cap_chan *chan) |
void(* bt_l2cap_chan_ops::seg_recv) (struct bt_l2cap_chan *chan, size_t sdu_len, off_t seg_offset, struct net_buf_simple *seg) |
Handle L2CAP segments directly.
This is an alternative to bt_l2cap_chan_ops::recv. They cannot be used together.
This is called immediately for each received segment.
Unlike with bt_l2cap_chan_ops::recv, flow control is explicit. Each time this handler is invoked, the remote has permanently used up one credit. Use bt_l2cap_chan_give_credits to give credits.
The start of an SDU is marked by seg_offset == 0
. The end of an SDU is marked by seg_offset + seg->len == sdu_len
.
The stack guarantees that:
Additionally, the L2CAP protocol is such that:
chan | The receiving channel. |
sdu_len | Byte length of the SDU this segment is part of. |
seg_offset | The byte offset of this segment in the SDU. |
seg | The segment payload. |
void(* bt_l2cap_chan_ops::sent) (struct bt_l2cap_chan *chan) |
Channel sent callback.
This callback will be called once the controller marks the SDU as completed. When the controller does so is implementation dependent. It could be after the SDU is enqueued for transmission, or after it is sent on air.
chan | The channel which has sent data. |
void(* bt_l2cap_chan_ops::status) (struct bt_l2cap_chan *chan, atomic_t *status) |
Channel status callback.
If this callback is provided it will be called whenever the channel status changes.
chan | The channel which status changed |
status | The channel status |