Bluetooth: Add bt_buf_get_rx() helper API
The separate ACL & event pools will soon be removed, and it's already now convenient to have a generic API when the exact type of the incoming packet is not yet known. Change-Id: I84cb65d17ea69ebeaeb21532fbf76689e4fb59a0 Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
parent
bc8564bddc
commit
0174200cd0
3 changed files with 28 additions and 0 deletions
|
@ -52,6 +52,17 @@ enum bt_buf_type {
|
|||
sizeof(struct bt_hci_acl_hdr) + \
|
||||
CONFIG_BLUETOOTH_RX_BUF_LEN)
|
||||
|
||||
/** Allocate a buffer for incoming data
|
||||
*
|
||||
* This will not set the buffer type so bt_buf_set_type() needs to be called
|
||||
* before bt_recv().
|
||||
*
|
||||
* @param timeout Timeout in milliseconds, or one of the special values
|
||||
* K_NO_WAIT and K_FOREVER.
|
||||
* @return A new buffer.
|
||||
*/
|
||||
struct net_buf *bt_buf_get_rx(int32_t timeout);
|
||||
|
||||
/** Allocate a buffer for an HCI event
|
||||
*
|
||||
* This will set the BT_BUF_EVT buffer type so bt_buf_set_type()
|
||||
|
|
|
@ -4018,6 +4018,18 @@ struct net_buf *bt_buf_get_acl(int32_t timeout)
|
|||
#endif /* CONFIG_BLUETOOTH_CONN */
|
||||
}
|
||||
|
||||
struct net_buf *bt_buf_get_rx(int32_t timeout)
|
||||
{
|
||||
struct net_buf *buf;
|
||||
|
||||
buf = net_buf_alloc(&hci_rx_pool, timeout);
|
||||
if (buf) {
|
||||
net_buf_reserve(buf, CONFIG_BLUETOOTH_HCI_RECV_RESERVE);
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BLUETOOTH_BREDR)
|
||||
static int br_start_inquiry(const struct bt_br_discovery_param *param)
|
||||
{
|
||||
|
|
|
@ -59,6 +59,11 @@ void bt_hci_driver_unregister(struct bt_hci_driver *drv)
|
|||
bt_dev.drv = NULL;
|
||||
}
|
||||
|
||||
struct net_buf *bt_buf_get_rx(int timeout)
|
||||
{
|
||||
return net_buf_alloc(&hci_rx_pool, timeout);
|
||||
}
|
||||
|
||||
struct net_buf *bt_buf_get_evt(uint8_t opcode, int timeout)
|
||||
{
|
||||
struct net_buf *buf;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue