Zephyr Project API 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
bt_rfcomm_dlc_ops Struct Reference

RFCOMM DLC operations structure. More...

#include <rfcomm.h>

Data Fields

void(* connected )(struct bt_rfcomm_dlc *dlc)
 DLC connected callback.
void(* disconnected )(struct bt_rfcomm_dlc *dlc)
 DLC disconnected callback.
int(* recv )(struct bt_rfcomm_dlc *dlc, struct net_buf *buf)
 DLC recv callback.
void(* sent )(struct bt_rfcomm_dlc *dlc, int err)
 DLC sent callback.

Detailed Description

RFCOMM DLC operations structure.

The object has to stay valid and constant for the lifetime of the DLC.

Note
The callbacks are invoked from a thread context, never from an ISR. Whether a callback is invoked from a context internal to the stack or synchronously from within the API call that triggers it, and from which context, is not part of the API and may change between releases. See @rstref{Callback execution contexts <bluetooth_callback_contexts>} for the hazards of blocking in a callback and their mitigations.

Field Documentation

◆ connected

void(* bt_rfcomm_dlc_ops::connected) (struct bt_rfcomm_dlc *dlc)

DLC connected callback.

If this callback is provided it will be called whenever the connection completes.

Parameters
dlcThe dlc that has been connected

◆ disconnected

void(* bt_rfcomm_dlc_ops::disconnected) (struct bt_rfcomm_dlc *dlc)

DLC disconnected callback.

If this callback is provided it will be called whenever the dlc is disconnected, including when a connection gets rejected or cancelled (both incoming and outgoing)

Parameters
dlcThe dlc that has been Disconnected

◆ recv

int(* bt_rfcomm_dlc_ops::recv) (struct bt_rfcomm_dlc *dlc, struct net_buf *buf)

DLC recv callback.

Called whenever data is received on the DLC.

If processing buf requires work that cannot complete immediately (e.g. passing data to another thread or a work queue), return -EINPROGRESS to defer the completion. The callback must not block in this case. Then the stack will hold back RX flow-control credits (CFC) or assert FC=1 (non-CFC) until bt_rfcomm_dlc_recv_complete is called for every outstanding buffer.

When -EINPROGRESS is returned, the application takes ownership of the buf reference and must eventually call bt_rfcomm_dlc_recv_complete exactly once, passing back the same buf pointer. No net_buf_ref or net_buf_unref calls are needed around that hand-off.

Warning
bt_rfcomm_dlc_recv_complete must be called from a thread context after this callback has returned. Calling it from inside the recv callback (before it returns) will underflow the in-progress counter and cause bt_rfcomm_dlc_recv_complete to fail with -EINVAL.
Parameters
dlcThe dlc receiving data.
bufBuffer containing incoming data.
Return values
0Data was fully consumed synchronously; the stack retains ownership of buf.
-EINPROGRESSData processing is deferred; the application now owns buf and must call bt_rfcomm_dlc_recv_complete once processing is done.
Returns
Other negative error code; the DLC will be actively disconnected by the stack.

◆ sent

void(* bt_rfcomm_dlc_ops::sent) (struct bt_rfcomm_dlc *dlc, int err)

DLC sent callback.

Parameters
dlcThe dlc which has sent data.
errSent result.

The documentation for this struct was generated from the following file:
  • include/zephyr/bluetooth/classic/rfcomm.h