Skip to content

Commit

Permalink
samples: Align samples to new recommeneded net_buf API.
Browse files Browse the repository at this point in the history
Align the usage of net_buf_put/get to use k_fifo_put/get as recommended
per Zephyr upstream.

Signed-off-by: Dominik Chat <[email protected]>
  • Loading branch information
dchat-nordic authored and bjarki-andreasen committed Sep 18, 2024
1 parent bbceb33 commit ebc7d5b
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions samples/bluetooth/direct_test_mode/remote_hci/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,15 @@ NRF_RPC_CBOR_CMD_DECODER(hci_group, hci_uart_init, RPC_HCI_UART_INIT_CMD,

static void dtm_hci_put_wrapper(struct net_buf *buf)
{
net_buf_put(&dtm_put_queue, buf);
k_fifo_put(&dtm_put_queue, buf);
}

static void dtm_put_thread(void)
{
struct net_buf *buf;

for (;;) {
buf = net_buf_get(&dtm_put_queue, K_FOREVER);
buf = k_fifo_get(&dtm_put_queue, K_FOREVER);

__ASSERT_NO_MSG(buf != NULL);

Expand Down
4 changes: 2 additions & 2 deletions samples/bluetooth/direct_test_mode/src/transport/dtm_hci.c
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ static int hci_cmd(const struct bt_hci_cmd_hdr *hdr, const uint8_t *data)

static void dtm_hci_put(struct net_buf *buf)
{
net_buf_put(&hci_rx_queue, buf);
k_fifo_put(&hci_rx_queue, buf);
}

int dtm_tr_init(void)
Expand All @@ -738,7 +738,7 @@ union dtm_tr_packet dtm_tr_get(void)
{
union dtm_tr_packet tmp;

tmp.hci = net_buf_get(&hci_rx_queue, K_FOREVER);
tmp.hci = k_fifo_get(&hci_rx_queue, K_FOREVER);
return tmp;
}

Expand Down
4 changes: 2 additions & 2 deletions samples/bluetooth/direct_test_mode/src/transport/hci_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ static void tx_thread(void)
* and it's not supposed to be sent over uart.
* The pointer is an address to the associated net_buf.
*/
buf = net_buf_get(&hci_tx_queue, K_FOREVER);
buf = k_fifo_get(&hci_tx_queue, K_FOREVER);
uart_tx(hci_uart_dev, &buf->data[sizeof(buf)],
buf->len - sizeof(buf), SYS_FOREVER_US);
}
Expand Down Expand Up @@ -304,6 +304,6 @@ int hci_uart_write(uint8_t type, const uint8_t *hdr, size_t hdr_len, const uint8
net_buf_add_mem(buf, hdr, hdr_len);
net_buf_add_mem(buf, pld, len);

net_buf_put(&hci_tx_queue, buf);
k_fifo_put(&hci_tx_queue, buf);
return 0;
}
6 changes: 3 additions & 3 deletions samples/nrf5340/multiprotocol_rpmsg/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ static void hci_rpmsg_rx(uint8_t *data, size_t len)
}

if (buf) {
net_buf_put(&tx_queue, buf);
k_fifo_put(&tx_queue, buf);

LOG_HEXDUMP_DBG(buf->data, buf->len, "Final net buffer:");
}
Expand All @@ -144,7 +144,7 @@ static void tx_thread(void *p1, void *p2, void *p3)
int err;

/* Wait until a buffer is available */
buf = net_buf_get(&tx_queue, K_FOREVER);
buf = k_fifo_get(&tx_queue, K_FOREVER);
/* Pass buffer to the stack */
err = bt_send(buf);
if (err) {
Expand Down Expand Up @@ -253,7 +253,7 @@ int main(void)
while (1) {
struct net_buf *buf;

buf = net_buf_get(&rx_queue, K_FOREVER);
buf = k_fifo_get(&rx_queue, K_FOREVER);
err = hci_rpmsg_send(buf);
if (err) {
LOG_ERR("Failed to send (err %d)", err);
Expand Down
10 changes: 5 additions & 5 deletions samples/openthread/coprocessor/src/rcp_hci.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ static void rx_isr(void)
if (remaining == 0) {
/* Packet received */
LOG_DBG("putting RX packet in queue.");
net_buf_put(&tx_queue, buf);
k_fifo_put(&tx_queue, buf);
state = ST_IDLE;
}
break;
Expand Down Expand Up @@ -192,7 +192,7 @@ static void tx_isr(void)
int len;

if (!buf) {
buf = net_buf_get(&uart_tx_queue, K_NO_WAIT);
buf = k_fifo_get(&uart_tx_queue, K_NO_WAIT);
if (!buf) {
uart_irq_tx_disable(hci_uart_dev);
return;
Expand Down Expand Up @@ -232,7 +232,7 @@ static void tx_thread(void *p1, void *p2, void *p3)
int err;

/* Wait until a buffer is available */
buf = net_buf_get(&tx_queue, K_FOREVER);
buf = k_fifo_get(&tx_queue, K_FOREVER);
/* Pass buffer to the stack */
err = bt_send(buf);
if (err) {
Expand All @@ -251,7 +251,7 @@ static int h4_send(struct net_buf *buf)
{
LOG_DBG("buf %p type %u len %u", buf, bt_buf_get_type(buf), buf->len);

net_buf_put(&uart_tx_queue, buf);
k_fifo_put(&uart_tx_queue, buf);
uart_irq_tx_enable(hci_uart_dev);

return 0;
Expand Down Expand Up @@ -369,7 +369,7 @@ void run_hci(void)
while (1) {
struct net_buf *buf;

buf = net_buf_get(&rx_queue, K_FOREVER);
buf = k_fifo_get(&rx_queue, K_FOREVER);
err = h4_send(buf);
if (err) {
LOG_ERR("Failed to send");
Expand Down

0 comments on commit ebc7d5b

Please sign in to comment.