|
Zephyr API Documentation 4.3.99
A Scalable Open Source RTOS
|
Data buffers. More...
Macros | |
| #define | BT_BUF_RESERVE 1 |
| #define | BT_BUF_SIZE(size) |
| Helper to include reserved HCI data in buffer calculations. | |
| #define | BT_BUF_ACL_SIZE(size) |
| Helper to calculate needed buffer size for HCI ACL packets. | |
| #define | BT_BUF_EVT_SIZE(size) |
| Helper to calculate needed buffer size for HCI Event packets. | |
| #define | BT_BUF_CMD_SIZE(size) |
| Helper to calculate needed buffer size for HCI Command packets. | |
| #define | BT_BUF_ISO_SIZE(size) |
| Helper to calculate needed buffer size for HCI ISO packets. | |
| #define | BT_BUF_ACL_RX_SIZE BT_BUF_ACL_SIZE(CONFIG_BT_BUF_ACL_RX_SIZE) |
| Data size needed for HCI ACL RX buffers. | |
| #define | BT_BUF_EVT_RX_SIZE BT_BUF_EVT_SIZE(CONFIG_BT_BUF_EVT_RX_SIZE) |
| Data size needed for HCI Event RX buffers. | |
| #define | BT_BUF_ISO_RX_SIZE 0 |
| #define | BT_BUF_ISO_RX_COUNT 0 |
| #define | BT_BUF_ACL_RX_COUNT_MAX 65535 |
| #define | BT_BUF_ACL_RX_COUNT_EXTRA 0 |
| #define | BT_BUF_ACL_RX_COUNT 0 |
| #define | BT_BUF_RX_SIZE |
| Data size needed for HCI ACL, HCI ISO or Event RX buffers. | |
| #define | BT_BUF_RX_COUNT |
| Buffer count needed for HCI ACL or HCI ISO plus Event RX buffers. | |
| #define | BT_BUF_CMD_TX_SIZE BT_BUF_CMD_SIZE(CONFIG_BT_BUF_CMD_TX_SIZE) |
| Data size needed for HCI Command buffers. | |
Typedefs | |
| typedef void(* | bt_buf_rx_freed_cb_t) (enum bt_buf_type type_mask) |
| A callback to notify about freed buffer in the incoming data pool. | |
Enumerations | |
| enum | bt_buf_type { BT_BUF_TYPE_NONE = 0 , BT_BUF_CMD = (1UL << (0)) , BT_BUF_EVT = (1UL << (1)) , BT_BUF_ACL_OUT = (1UL << (2)) , BT_BUF_ACL_IN = (1UL << (3)) , BT_BUF_ISO_OUT = (1UL << (4)) , BT_BUF_ISO_IN = (1UL << (5)) } |
| Possible types of buffers passed around the Bluetooth stack in a form of bitmask. More... | |
| enum | bt_buf_dir { BT_BUF_IN , BT_BUF_OUT } |
| Direction of HCI packets. More... | |
Functions | |
| static uint8_t | bt_buf_type_to_h4 (enum bt_buf_type type) |
| Convert from bt_buf_type to H:4 type. | |
| static enum bt_buf_type | bt_buf_type_from_h4 (uint8_t h4_type, enum bt_buf_dir dir) |
| Convert from H:4 type to bt_buf_type. | |
| struct net_buf * | bt_buf_get_rx (enum bt_buf_type type, k_timeout_t timeout) |
| Allocate a buffer for incoming data. | |
| void | bt_buf_rx_freed_cb_set (bt_buf_rx_freed_cb_t cb) |
| Set the callback to notify about freed buffer in the incoming data pool. | |
| struct net_buf * | bt_buf_get_tx (enum bt_buf_type type, k_timeout_t timeout, const void *data, size_t size) |
| Allocate a buffer for outgoing data. | |
| struct net_buf * | bt_buf_get_evt (uint8_t evt, bool discardable, k_timeout_t timeout) |
| Allocate a buffer for an HCI Event. | |
| static void | bt_buf_set_type (struct net_buf *buf, enum bt_buf_type type) |
| Set the buffer type. | |
| static enum bt_buf_type | bt_buf_get_type (struct net_buf *buf) |
| Get the buffer type. | |
Data buffers.
| #define BT_BUF_ACL_RX_COUNT 0 |
#include <zephyr/bluetooth/buf.h>
| #define BT_BUF_ACL_RX_COUNT_EXTRA 0 |
#include <zephyr/bluetooth/buf.h>
| #define BT_BUF_ACL_RX_COUNT_MAX 65535 |
#include <zephyr/bluetooth/buf.h>
| #define BT_BUF_ACL_RX_SIZE BT_BUF_ACL_SIZE(CONFIG_BT_BUF_ACL_RX_SIZE) |
#include <zephyr/bluetooth/buf.h>
Data size needed for HCI ACL RX buffers.
| #define BT_BUF_ACL_SIZE | ( | size | ) |
#include <zephyr/bluetooth/buf.h>
Helper to calculate needed buffer size for HCI ACL packets.
| #define BT_BUF_CMD_SIZE | ( | size | ) |
#include <zephyr/bluetooth/buf.h>
Helper to calculate needed buffer size for HCI Command packets.
| #define BT_BUF_CMD_TX_SIZE BT_BUF_CMD_SIZE(CONFIG_BT_BUF_CMD_TX_SIZE) |
#include <zephyr/bluetooth/buf.h>
Data size needed for HCI Command buffers.
| #define BT_BUF_EVT_RX_SIZE BT_BUF_EVT_SIZE(CONFIG_BT_BUF_EVT_RX_SIZE) |
#include <zephyr/bluetooth/buf.h>
Data size needed for HCI Event RX buffers.
| #define BT_BUF_EVT_SIZE | ( | size | ) |
#include <zephyr/bluetooth/buf.h>
Helper to calculate needed buffer size for HCI Event packets.
| #define BT_BUF_ISO_RX_COUNT 0 |
#include <zephyr/bluetooth/buf.h>
| #define BT_BUF_ISO_RX_SIZE 0 |
#include <zephyr/bluetooth/buf.h>
| #define BT_BUF_ISO_SIZE | ( | size | ) |
#include <zephyr/bluetooth/buf.h>
Helper to calculate needed buffer size for HCI ISO packets.
| #define BT_BUF_RESERVE 1 |
#include <zephyr/bluetooth/buf.h>
| #define BT_BUF_RX_COUNT |
#include <zephyr/bluetooth/buf.h>
Buffer count needed for HCI ACL or HCI ISO plus Event RX buffers.
| #define BT_BUF_RX_SIZE |
#include <zephyr/bluetooth/buf.h>
Data size needed for HCI ACL, HCI ISO or Event RX buffers.
| #define BT_BUF_SIZE | ( | size | ) |
#include <zephyr/bluetooth/buf.h>
Helper to include reserved HCI data in buffer calculations.
|
isr-ok |
#include <zephyr/bluetooth/buf.h>
A callback to notify about freed buffer in the incoming data pool.
This callback is called when a buffer of a given type is freed and can be requested through the bt_buf_get_rx function. However, this callback is called from the context of the buffer freeing operation and must not attempt to allocate a new buffer from the same pool.
This callback must only be used for very short non-blocking operations (e.g. submitting a work item). When called from thread context, the scheduler is locked during execution and the callee must not perform any action that makes the current thread unready. When called from ISR context, the callback runs without scheduler lock.
| type_mask | A bit mask of buffer types that have been freed. |
| enum bt_buf_dir |
#include <zephyr/bluetooth/buf.h>
Direction of HCI packets.
Only used for mapping H:4 to BT_BUF_* values.
| Enumerator | |
|---|---|
| BT_BUF_IN | Packet from the controller to the host. |
| BT_BUF_OUT | Packet from the host to the controller. |
| enum bt_buf_type |
#include <zephyr/bluetooth/buf.h>
Possible types of buffers passed around the Bluetooth stack in a form of bitmask.
| struct net_buf * bt_buf_get_evt | ( | uint8_t | evt, |
| bool | discardable, | ||
| k_timeout_t | timeout ) |
#include <zephyr/bluetooth/buf.h>
Allocate a buffer for an HCI Event.
This will set the buffer type so it doesn't need to be explicitly encoded into the buffer.
| evt | HCI event code |
| discardable | Whether the driver considers the event discardable. |
| timeout | Non-negative waiting period to obtain a buffer or one of the special values K_NO_WAIT and K_FOREVER. |
| struct net_buf * bt_buf_get_rx | ( | enum bt_buf_type | type, |
| k_timeout_t | timeout ) |
#include <zephyr/bluetooth/buf.h>
Allocate a buffer for incoming data.
This will set the buffer type so it doesn't need to be explicitly encoded into the buffer.
| type | Type of buffer. Only BT_BUF_EVT, BT_BUF_ACL_IN and BT_BUF_ISO_IN are allowed. |
| timeout | Non-negative waiting period to obtain a buffer or one of the special values K_NO_WAIT and K_FOREVER. |
| struct net_buf * bt_buf_get_tx | ( | enum bt_buf_type | type, |
| k_timeout_t | timeout, | ||
| const void * | data, | ||
| size_t | size ) |
#include <zephyr/bluetooth/buf.h>
Allocate a buffer for outgoing data.
This will set the buffer type so it doesn't need to be explicitly encoded into the buffer.
| type | Type of buffer. BT_BUF_CMD or BT_BUF_ACL_OUT. |
| timeout | Non-negative waiting period to obtain a buffer or one of the special values K_NO_WAIT and K_FOREVER. |
| data | Initial data to append to buffer. This is optional and can be NULL. |
| size | Initial data size. |
|
inlinestatic |
#include <zephyr/bluetooth/buf.h>
Get the buffer type.
This pulls the H:4 byte prefix from the payload, which means that the call can be done only once per buffer.
| buf | Bluetooth buffer |
|
isr-ok |
#include <zephyr/bluetooth/buf.h>
Set the callback to notify about freed buffer in the incoming data pool.
It's safe to call this inside the callback itself.
| cb | Callback to notify about freed buffer in the incoming data pool. If NULL, the callback is disabled. |
|
inlinestatic |
#include <zephyr/bluetooth/buf.h>
Set the buffer type.
The type is encoded as an H:4 byte prefix as part of the payload itself.
| buf | Bluetooth buffer |
| type | The BT_* type to set the buffer to |
|
inlinestatic |
#include <zephyr/bluetooth/buf.h>
Convert from H:4 type to bt_buf_type.
| h4_type | The H:4 type to convert |
| dir | The direction of the packet |
|
inlinestatic |
#include <zephyr/bluetooth/buf.h>
Convert from bt_buf_type to H:4 type.
| type | The bt_buf_type to convert |