Skip to content

Commit b923bde

Browse files
makeshicfriedt
authored andcommitted
bluetooth: avrcp: provide an API for net buffer allocation
Add bt_avrcp_create_pdu() to allocate net_buf with protocol headroom. Signed-off-by: Make Shi <[email protected]>
1 parent 895ba04 commit b923bde

File tree

2 files changed

+21
-0
lines changed
  • include/zephyr/bluetooth/classic
  • subsys/bluetooth/host/classic

2 files changed

+21
-0
lines changed

include/zephyr/bluetooth/classic/avrcp.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,19 @@ int bt_avrcp_connect(struct bt_conn *conn);
264264
*/
265265
int bt_avrcp_disconnect(struct bt_conn *conn);
266266

267+
/**
268+
* @brief Allocate a net_buf for AVRCP PDU transmission, reserving headroom
269+
* for AVRCP, AVRCTP, L2CAP, and ACL headers.
270+
*
271+
* This function allocates a buffer from the specified pool and reserves
272+
* sufficient headroom for protocol headers required by AVRCP over Bluetooth.
273+
*
274+
* @param pool The buffer pool to allocate from.
275+
*
276+
* @return A newly allocated net_buf with reserved headroom.
277+
*/
278+
struct net_buf *bt_avrcp_create_pdu(struct net_buf_pool *pool);
279+
267280
/** @brief Register callback.
268281
*
269282
* Register AVRCP callbacks to monitor the state and interact with the remote device.

subsys/bluetooth/host/classic/avrcp.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,14 @@ int bt_avrcp_disconnect(struct bt_conn *conn)
814814
return err;
815815
}
816816

817+
struct net_buf *bt_avrcp_create_pdu(struct net_buf_pool *pool)
818+
{
819+
return bt_conn_create_pdu(pool,
820+
sizeof(struct bt_l2cap_hdr) +
821+
sizeof(struct bt_avctp_header) +
822+
sizeof(struct bt_avrcp_header));
823+
}
824+
817825
int bt_avrcp_ct_get_cap(struct bt_avrcp_ct *ct, uint8_t tid, uint8_t cap_id)
818826
{
819827
struct net_buf *buf;

0 commit comments

Comments
 (0)