Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
Data buffers

Data buffers. More...

Data Structures

struct  bt_buf_data
 This is a base type for bt_buf user data. More...
 

Macros

#define BT_BUF_RESERVE   CONFIG_BT_HCI_RESERVE
 
#define BT_BUF_SIZE(size)   (BT_BUF_RESERVE + (size))
 
#define BT_BUF_ACL_SIZE(size)   BT_BUF_SIZE(BT_HCI_ACL_HDR_SIZE + (size))
 
#define BT_BUF_EVT_SIZE(size)   BT_BUF_SIZE(BT_HCI_EVT_HDR_SIZE + (size))
 
#define BT_BUF_CMD_SIZE(size)   BT_BUF_SIZE(BT_HCI_CMD_HDR_SIZE + (size))
 
#define BT_BUF_ACL_RX_SIZE   BT_BUF_ACL_SIZE(CONFIG_BT_BUF_ACL_RX_SIZE)
 
#define BT_BUF_EVT_RX_SIZE   BT_BUF_EVT_SIZE(CONFIG_BT_BUF_EVT_RX_SIZE)
 
#define BT_BUF_RX_SIZE   (MAX(BT_BUF_ACL_RX_SIZE, BT_BUF_EVT_RX_SIZE))
 
#define BT_BUF_CMD_TX_SIZE   BT_BUF_CMD_SIZE(CONFIG_BT_BUF_CMD_TX_SIZE)
 

Enumerations

enum  bt_buf_type {
  BT_BUF_CMD , BT_BUF_EVT , BT_BUF_ACL_OUT , BT_BUF_ACL_IN ,
  BT_BUF_ISO_OUT , BT_BUF_ISO_IN , BT_BUF_H4
}
 

Functions

struct net_bufbt_buf_get_rx (enum bt_buf_type type, k_timeout_t timeout)
 
struct net_bufbt_buf_get_tx (enum bt_buf_type type, k_timeout_t timeout, const void *data, size_t size)
 
struct net_bufbt_buf_get_cmd_complete (k_timeout_t timeout)
 
struct net_bufbt_buf_get_evt (uint8_t evt, bool discardable, k_timeout_t timeout)
 
static void bt_buf_set_type (struct net_buf *buf, enum bt_buf_type type)
 
static enum bt_buf_type bt_buf_get_type (struct net_buf *buf)
 

Detailed Description

Data buffers.

Macro Definition Documentation

◆ BT_BUF_ACL_RX_SIZE

#define BT_BUF_ACL_RX_SIZE   BT_BUF_ACL_SIZE(CONFIG_BT_BUF_ACL_RX_SIZE)

#include <include/bluetooth/buf.h>

Data size needed for HCI ACL RX buffers

◆ BT_BUF_ACL_SIZE

#define BT_BUF_ACL_SIZE (   size)    BT_BUF_SIZE(BT_HCI_ACL_HDR_SIZE + (size))

#include <include/bluetooth/buf.h>

Helper to calculate needed buffer size for HCI ACL packets

◆ BT_BUF_CMD_SIZE

#define BT_BUF_CMD_SIZE (   size)    BT_BUF_SIZE(BT_HCI_CMD_HDR_SIZE + (size))

#include <include/bluetooth/buf.h>

Helper to calculate needed buffer size for HCI Command packets.

◆ BT_BUF_CMD_TX_SIZE

#define BT_BUF_CMD_TX_SIZE   BT_BUF_CMD_SIZE(CONFIG_BT_BUF_CMD_TX_SIZE)

#include <include/bluetooth/buf.h>

Data size needed for HCI Command buffers.

◆ BT_BUF_EVT_RX_SIZE

#define BT_BUF_EVT_RX_SIZE   BT_BUF_EVT_SIZE(CONFIG_BT_BUF_EVT_RX_SIZE)

#include <include/bluetooth/buf.h>

Data size needed for HCI Event RX buffers

◆ BT_BUF_EVT_SIZE

#define BT_BUF_EVT_SIZE (   size)    BT_BUF_SIZE(BT_HCI_EVT_HDR_SIZE + (size))

#include <include/bluetooth/buf.h>

Helper to calculate needed buffer size for HCI Event packets.

◆ BT_BUF_RESERVE

#define BT_BUF_RESERVE   CONFIG_BT_HCI_RESERVE

◆ BT_BUF_RX_SIZE

#define BT_BUF_RX_SIZE   (MAX(BT_BUF_ACL_RX_SIZE, BT_BUF_EVT_RX_SIZE))

#include <include/bluetooth/buf.h>

Data size needed for HCI ACL or Event RX buffers

◆ BT_BUF_SIZE

#define BT_BUF_SIZE (   size)    (BT_BUF_RESERVE + (size))

#include <include/bluetooth/buf.h>

Helper to include reserved HCI data in buffer calculations

Enumeration Type Documentation

◆ bt_buf_type

#include <include/bluetooth/buf.h>

Possible types of buffers passed around the Bluetooth stack

Enumerator
BT_BUF_CMD 

HCI command

BT_BUF_EVT 

HCI event

BT_BUF_ACL_OUT 

Outgoing ACL data

BT_BUF_ACL_IN 

Incoming ACL data

BT_BUF_ISO_OUT 

Outgoing ISO data

BT_BUF_ISO_IN 

Incoming ISO data

BT_BUF_H4 

H:4 data

Function Documentation

◆ bt_buf_get_cmd_complete()

struct net_buf * bt_buf_get_cmd_complete ( k_timeout_t  timeout)

#include <include/bluetooth/buf.h>

Allocate a buffer for an HCI Command Complete/Status Event

This will set the buffer type so bt_buf_set_type() does not need to be explicitly called before bt_recv_prio().

Parameters
timeoutNon-negative waiting period to obtain a buffer or one of the special values K_NO_WAIT and K_FOREVER.
Returns
A new buffer.

◆ bt_buf_get_evt()

struct net_buf * bt_buf_get_evt ( uint8_t  evt,
bool  discardable,
k_timeout_t  timeout 
)

#include <include/bluetooth/buf.h>

Allocate a buffer for an HCI Event

This will set the buffer type so bt_buf_set_type() does not need to be explicitly called before bt_recv_prio() or bt_recv().

Parameters
evtHCI event code
discardableWhether the driver considers the event discardable.
timeoutNon-negative waiting period to obtain a buffer or one of the special values K_NO_WAIT and K_FOREVER.
Returns
A new buffer.

◆ bt_buf_get_rx()

struct net_buf * bt_buf_get_rx ( enum bt_buf_type  type,
k_timeout_t  timeout 
)

#include <include/bluetooth/buf.h>

Allocate a buffer for incoming data

This will set the buffer type so bt_buf_set_type() does not need to be explicitly called before bt_recv_prio().

Parameters
typeType of buffer. Only BT_BUF_EVT and BT_BUF_ACL_IN are allowed.
timeoutNon-negative waiting period to obtain a buffer or one of the special values K_NO_WAIT and K_FOREVER.
Returns
A new buffer.

◆ bt_buf_get_tx()

struct net_buf * bt_buf_get_tx ( enum bt_buf_type  type,
k_timeout_t  timeout,
const void data,
size_t  size 
)

#include <include/bluetooth/buf.h>

Allocate a buffer for outgoing data

This will set the buffer type so bt_buf_set_type() does not need to be explicitly called before bt_send().

Parameters
typeType of buffer. Only BT_BUF_CMD, BT_BUF_ACL_OUT or BT_BUF_H4, when operating on H:4 mode, are allowed.
timeoutNon-negative waiting period to obtain a buffer or one of the special values K_NO_WAIT and K_FOREVER.
dataInitial data to append to buffer.
sizeInitial data size.
Returns
A new buffer.

◆ bt_buf_get_type()

static enum bt_buf_type bt_buf_get_type ( struct net_buf buf)
inlinestatic

#include <include/bluetooth/buf.h>

Get the buffer type

Parameters
bufBluetooth buffer
Returns
The BT_* type to of the buffer

◆ bt_buf_set_type()

static void bt_buf_set_type ( struct net_buf buf,
enum bt_buf_type  type 
)
inlinestatic

#include <include/bluetooth/buf.h>

Set the buffer type

Parameters
bufBluetooth buffer
typeThe BT_* type to set the buffer to