Zephyr API Documentation
3.0.0
A Scalable Open Source RTOS
3.0.0
Toggle main menu visibility
Main Page
Related Pages
Modules
Data Structures
Data Structures
Data Structure Index
Data Fields
All
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
Variables
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Enumerator
Files
File List
Globals
All
$
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
$
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Typedefs
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Enumerations
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
Enumerator
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Macros
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
•
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Modules
Pages
buf.h
Go to the documentation of this file.
1
5
/*
6
* Copyright (c) 2016 Intel Corporation
7
*
8
* SPDX-License-Identifier: Apache-2.0
9
*/
10
11
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_BUF_H_
12
#define ZEPHYR_INCLUDE_BLUETOOTH_BUF_H_
13
21
#include <
zephyr/types.h
>
22
#include <
net/buf.h
>
23
#include <
bluetooth/hci.h
>
24
#include <
sys/util.h
>
25
26
#ifdef __cplusplus
27
extern
"C"
{
28
#endif
29
31
enum
bt_buf_type
{
33
BT_BUF_CMD
,
35
BT_BUF_EVT
,
37
BT_BUF_ACL_OUT
,
39
BT_BUF_ACL_IN
,
41
BT_BUF_ISO_OUT
,
43
BT_BUF_ISO_IN
,
45
BT_BUF_H4
,
46
};
47
49
struct
bt_buf_data
{
50
uint8_t
type
;
51
};
52
53
#if defined(CONFIG_BT_HCI_RAW)
54
#define BT_BUF_RESERVE MAX(CONFIG_BT_HCI_RESERVE, CONFIG_BT_HCI_RAW_RESERVE)
55
#else
56
#define BT_BUF_RESERVE CONFIG_BT_HCI_RESERVE
57
#endif
58
60
#define BT_BUF_SIZE(size) (BT_BUF_RESERVE + (size))
61
63
#define BT_BUF_ACL_SIZE(size) BT_BUF_SIZE(BT_HCI_ACL_HDR_SIZE + (size))
64
66
#define BT_BUF_EVT_SIZE(size) BT_BUF_SIZE(BT_HCI_EVT_HDR_SIZE + (size))
67
69
#define BT_BUF_CMD_SIZE(size) BT_BUF_SIZE(BT_HCI_CMD_HDR_SIZE + (size))
70
72
#define BT_BUF_ISO_SIZE(size) BT_BUF_SIZE(BT_HCI_ISO_HDR_SIZE + \
73
BT_HCI_ISO_DATA_HDR_SIZE + \
74
(size))
75
77
#define BT_BUF_ACL_RX_SIZE BT_BUF_ACL_SIZE(CONFIG_BT_BUF_ACL_RX_SIZE)
78
80
#define BT_BUF_EVT_RX_SIZE BT_BUF_EVT_SIZE(CONFIG_BT_BUF_EVT_RX_SIZE)
81
82
#if defined(CONFIG_BT_ISO)
83
#define BT_BUF_ISO_RX_SIZE BT_BUF_ISO_SIZE(CONFIG_BT_ISO_RX_MTU)
84
#define BT_BUF_ISO_RX_COUNT CONFIG_BT_ISO_RX_BUF_COUNT
85
#else
86
#define BT_BUF_ISO_RX_SIZE 0
87
#define BT_BUF_ISO_RX_COUNT 0
88
#endif
/* CONFIG_BT_ISO */
89
91
#define BT_BUF_RX_SIZE (MAX(MAX(BT_BUF_ACL_RX_SIZE, BT_BUF_EVT_RX_SIZE), \
92
BT_BUF_ISO_RX_SIZE))
93
95
#define BT_BUF_RX_COUNT (MAX(MAX(CONFIG_BT_BUF_EVT_RX_COUNT, \
96
CONFIG_BT_BUF_ACL_RX_COUNT), \
97
BT_BUF_ISO_RX_COUNT))
98
100
#define BT_BUF_CMD_TX_SIZE BT_BUF_CMD_SIZE(CONFIG_BT_BUF_CMD_TX_SIZE)
101
113
struct
net_buf
*
bt_buf_get_rx
(
enum
bt_buf_type
type,
k_timeout_t
timeout
);
114
128
struct
net_buf
*
bt_buf_get_tx
(
enum
bt_buf_type
type,
k_timeout_t
timeout
,
129
const
void
*
data
,
size_t
size
);
130
140
struct
net_buf
*
bt_buf_get_cmd_complete
(
k_timeout_t
timeout
);
141
153
struct
net_buf
*
bt_buf_get_evt
(
uint8_t
evt,
bool
discardable,
k_timeout_t
timeout
);
154
160
static
inline
void
bt_buf_set_type
(
struct
net_buf
*buf,
enum
bt_buf_type
type)
161
{
162
((
struct
bt_buf_data
*)
net_buf_user_data
(buf))->
type
=
type
;
163
}
164
171
static
inline
enum
bt_buf_type
bt_buf_get_type
(
struct
net_buf
*buf)
172
{
173
return
(
enum
bt_buf_type
)((
struct
bt_buf_data
*)
net_buf_user_data
(buf))
174
->
type
;
175
}
176
181
#ifdef __cplusplus
182
}
183
#endif
184
185
#endif
/* ZEPHYR_INCLUDE_BLUETOOTH_BUF_H_ */
timeout
ZTEST_BMEM int timeout
Definition:
main.c:31
bt_buf_get_type
static enum bt_buf_type bt_buf_get_type(struct net_buf *buf)
Definition:
buf.h:171
bt_buf_get_rx
struct net_buf * bt_buf_get_rx(enum bt_buf_type type, k_timeout_t timeout)
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)
bt_buf_get_evt
struct net_buf * bt_buf_get_evt(uint8_t evt, bool discardable, k_timeout_t timeout)
bt_buf_get_cmd_complete
struct net_buf * bt_buf_get_cmd_complete(k_timeout_t timeout)
bt_buf_set_type
static void bt_buf_set_type(struct net_buf *buf, enum bt_buf_type type)
Definition:
buf.h:160
bt_buf_type
bt_buf_type
Definition:
buf.h:31
BT_BUF_EVT
@ BT_BUF_EVT
Definition:
buf.h:35
BT_BUF_ISO_OUT
@ BT_BUF_ISO_OUT
Definition:
buf.h:41
BT_BUF_ACL_OUT
@ BT_BUF_ACL_OUT
Definition:
buf.h:37
BT_BUF_ISO_IN
@ BT_BUF_ISO_IN
Definition:
buf.h:43
BT_BUF_CMD
@ BT_BUF_CMD
Definition:
buf.h:33
BT_BUF_H4
@ BT_BUF_H4
Definition:
buf.h:45
BT_BUF_ACL_IN
@ BT_BUF_ACL_IN
Definition:
buf.h:39
net_buf_user_data
static void * net_buf_user_data(const struct net_buf *buf)
Get a pointer to the user data of a buffer.
Definition:
buf.h:1475
hci.h
types.h
buf.h
Buffer management.
uint8_t
__UINT8_TYPE__ uint8_t
Definition:
stdint.h:58
bt_buf_data
This is a base type for bt_buf user data.
Definition:
buf.h:49
bt_buf_data::type
uint8_t type
Definition:
buf.h:50
k_timeout_t
Kernel timeout type.
Definition:
sys_clock.h:65
net_buf
Network buffer representation.
Definition:
buf.h:915
net_buf::size
uint16_t size
Definition:
buf.h:949
data
static fdata_t data[2]
Definition:
test_fifo_contexts.c:15
util.h
Misc utilities.
include
bluetooth
buf.h
Generated on Mon Feb 21 2022 22:43:01 for Zephyr API Documentation by
1.9.2