nRF Connect SDK API 0.1.0
Loading...
Searching...
No Matches
shell_bt_nus.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
7#ifndef SHELL_BT_NUS_H_
8#define SHELL_BT_NUS_H_
9
10#include <zephyr/shell/shell.h>
11#include <zephyr/bluetooth/conn.h>
13#include <zephyr/sys/ring_buffer.h>
14
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26extern const struct shell_transport_api shell_bt_nus_transport_api;
27
30 struct bt_conn *conn;
31 atomic_t tx_busy;
32 shell_transport_handler_t handler;
33 void *context;
34};
35
39 struct ring_buf *tx_ringbuf;
40 struct ring_buf *rx_ringbuf;
41};
42
44#define SHELL_BT_NUS_DEFINE(_name, _tx_ringbuf_size, _rx_ringbuf_size) \
45 static struct shell_bt_nus_ctrl_blk _name##_ctrl_blk; \
46 RING_BUF_DECLARE(_name##_tx_ringbuf, _tx_ringbuf_size); \
47 RING_BUF_DECLARE(_name##_rx_ringbuf, _rx_ringbuf_size); \
48 static const struct shell_bt_nus _name##_shell_bt_nus = { \
49 .ctrl_blk = &_name##_ctrl_blk, \
50 .tx_ringbuf = &_name##_tx_ringbuf, \
51 .rx_ringbuf = &_name##_rx_ringbuf, \
52 }; \
53 struct shell_transport _name = { \
54 .api = &shell_bt_nus_transport_api, \
55 .ctx = (struct shell_bt_nus *)&_name##_shell_bt_nus \
56 }
57
67
75void shell_bt_nus_enable(struct bt_conn *conn);
76
81
82#ifdef __cplusplus
83}
84#endif
85
90#endif /* SHELL_BT_NUS_H_ */
const struct shell_transport_api shell_bt_nus_transport_api
void shell_bt_nus_enable(struct bt_conn *conn)
Enable the NUS shell transport instance.
int shell_bt_nus_init(void)
Initialize the NUS shell transport instance.
void shell_bt_nus_disable(void)
Disable the NUS shell transport instance.
struct bt_conn * conn
Definition: shell_bt_nus.h:30
atomic_t tx_busy
Definition: shell_bt_nus.h:31
void * context
Definition: shell_bt_nus.h:33
shell_transport_handler_t handler
Definition: shell_bt_nus.h:32
Instance control block (RW data).
Definition: shell_bt_nus.h:29
struct ring_buf * rx_ringbuf
Definition: shell_bt_nus.h:40
struct shell_bt_nus_ctrl_blk * ctrl_blk
Definition: shell_bt_nus.h:38
struct ring_buf * tx_ringbuf
Definition: shell_bt_nus.h:39
Instance structure.
Definition: shell_bt_nus.h:37