Bluetooth: ISO: Add CONFIG_BT_ISO_{RX/TX}
Add 2 new Kconfig promptless options that are shorthand for whether the ISO configuration can support RX and TX. This also applies these new options as guards for existing and missing code pieces. Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
parent
0703a3532d
commit
9553347080
|
@ -120,7 +120,7 @@ config BT_MAX_CONN
|
|||
|
||||
config BT_CONN_TX
|
||||
bool
|
||||
default BT_CONN || BT_ISO_BROADCASTER
|
||||
default BT_CONN || BT_ISO_TX
|
||||
help
|
||||
Hidden configuration that is true if ACL or broadcast ISO is enabled
|
||||
|
||||
|
|
|
@ -7,11 +7,19 @@
|
|||
config BT_ISO
|
||||
bool
|
||||
|
||||
config BT_ISO_TX
|
||||
bool
|
||||
|
||||
config BT_ISO_RX
|
||||
bool
|
||||
|
||||
# TODO: Split between client (central) and server (peripheral)
|
||||
config BT_ISO_UNICAST
|
||||
bool
|
||||
depends on BT_CONN
|
||||
select BT_ISO
|
||||
select BT_ISO_TX
|
||||
select BT_ISO_RX
|
||||
help
|
||||
This option enables support for Bluetooth Unicast
|
||||
Isochronous channels.
|
||||
|
@ -45,6 +53,7 @@ config BT_ISO_BROADCASTER
|
|||
bool "Bluetooth Isochronous Broadcaster Support [EXPERIMENTAL]"
|
||||
depends on !BT_CTLR || BT_CTLR_ADV_ISO_SUPPORT
|
||||
select BT_ISO_BROADCAST
|
||||
select BT_ISO_TX
|
||||
select BT_BROADCASTER
|
||||
select BT_PER_ADV
|
||||
select EXPERIMENTAL
|
||||
|
@ -55,6 +64,7 @@ config BT_ISO_SYNC_RECEIVER
|
|||
bool "Bluetooth Isochronous Synchronized Receiver Support [EXPERIMENTAL]"
|
||||
depends on !BT_CTLR || BT_CTLR_SYNC_ISO_SUPPORT
|
||||
select BT_ISO_BROADCAST
|
||||
select BT_ISO_RX
|
||||
select BT_OBSERVER
|
||||
select BT_PER_ADV_SYNC
|
||||
select EXPERIMENTAL
|
||||
|
|
|
@ -62,9 +62,7 @@ struct net_buf *bt_buf_get_rx(enum bt_buf_type type, k_timeout_t timeout)
|
|||
__ASSERT(type == BT_BUF_EVT || type == BT_BUF_ACL_IN ||
|
||||
type == BT_BUF_ISO_IN, "Invalid buffer type requested");
|
||||
|
||||
if ((IS_ENABLED(CONFIG_BT_ISO_UNICAST) ||
|
||||
IS_ENABLED(CONFIG_BT_ISO_SYNC_RECEIVER)) &&
|
||||
type == BT_BUF_ISO_IN) {
|
||||
if (IS_ENABLED(CONFIG_BT_ISO_RX) && type == BT_BUF_ISO_IN) {
|
||||
return bt_iso_get_rx(timeout);
|
||||
}
|
||||
|
||||
|
|
|
@ -403,9 +403,7 @@ void bt_conn_recv(struct bt_conn *conn, struct net_buf *buf, uint8_t flags)
|
|||
|
||||
LOG_DBG("handle %u len %u flags %02x", conn->handle, buf->len, flags);
|
||||
|
||||
if ((IS_ENABLED(CONFIG_BT_ISO_UNICAST) ||
|
||||
IS_ENABLED(CONFIG_BT_ISO_SYNC_RECEIVER)) &&
|
||||
conn->type == BT_CONN_TYPE_ISO) {
|
||||
if (IS_ENABLED(CONFIG_BT_ISO_RX) && conn->type == BT_CONN_TYPE_ISO) {
|
||||
bt_iso_recv(conn, buf, flags);
|
||||
return;
|
||||
} else if (IS_ENABLED(CONFIG_BT_CONN)) {
|
||||
|
|
|
@ -3266,10 +3266,14 @@ static int le_init_iso(void)
|
|||
|
||||
net_buf_unref(rsp);
|
||||
} else if (IS_ENABLED(CONFIG_BT_CONN_TX)) {
|
||||
LOG_WRN("Read Buffer Size V2 command is not supported. "
|
||||
"No ISO TX buffers will be available");
|
||||
if (IS_ENABLED(CONFIG_BT_ISO_TX)) {
|
||||
LOG_WRN("Read Buffer Size V2 command is not supported. "
|
||||
"No ISO TX buffers will be available");
|
||||
}
|
||||
|
||||
/* Read LE Buffer Size */
|
||||
/* Read LE Buffer Size in the case that we support ACL without TX ISO (e.g. if we
|
||||
* only support ISO sync receiver).
|
||||
*/
|
||||
err = bt_hci_cmd_send_sync(BT_HCI_OP_LE_READ_BUFFER_SIZE,
|
||||
NULL, &rsp);
|
||||
if (err) {
|
||||
|
|
|
@ -34,14 +34,14 @@ LOG_MODULE_REGISTER(bt_iso);
|
|||
|
||||
#define iso_chan(_iso) ((_iso)->iso.chan);
|
||||
|
||||
#if defined(CONFIG_BT_ISO_UNICAST) || defined(CONFIG_BT_ISO_SYNC_RECEIVER)
|
||||
#if defined(CONFIG_BT_ISO_RX)
|
||||
NET_BUF_POOL_FIXED_DEFINE(iso_rx_pool, CONFIG_BT_ISO_RX_BUF_COUNT,
|
||||
BT_ISO_SDU_BUF_SIZE(CONFIG_BT_ISO_RX_MTU),
|
||||
sizeof(struct iso_data), NULL);
|
||||
|
||||
static struct bt_iso_recv_info iso_info_data[CONFIG_BT_ISO_RX_BUF_COUNT];
|
||||
#define iso_info(buf) (&iso_info_data[net_buf_id(buf)])
|
||||
#endif /* CONFIG_BT_ISO_UNICAST || CONFIG_BT_ISO_SYNC_RECEIVER */
|
||||
#endif /* CONFIG_BT_ISO_RX */
|
||||
|
||||
#if defined(CONFIG_BT_ISO_UNICAST) || defined(CONFIG_BT_ISO_BROADCAST)
|
||||
NET_BUF_POOL_FIXED_DEFINE(iso_tx_pool, CONFIG_BT_ISO_TX_BUF_COUNT,
|
||||
|
@ -80,7 +80,7 @@ struct bt_iso_big bigs[CONFIG_BT_ISO_MAX_BIG];
|
|||
static struct bt_iso_big *lookup_big_by_handle(uint8_t big_handle);
|
||||
#endif /* CONFIG_BT_ISO_BROADCAST */
|
||||
|
||||
#if defined(CONFIG_BT_CONN_TX)
|
||||
#if defined(CONFIG_BT_ISO_TX)
|
||||
static void bt_iso_send_cb(struct bt_conn *iso, void *user_data, int err)
|
||||
{
|
||||
struct bt_iso_chan *chan = iso->iso.chan;
|
||||
|
@ -94,7 +94,7 @@ static void bt_iso_send_cb(struct bt_conn *iso, void *user_data, int err)
|
|||
ops->sent(chan);
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_BT_CONN_TX */
|
||||
#endif /* CONFIG_BT_ISO_TX */
|
||||
|
||||
void hci_iso(struct net_buf *buf)
|
||||
{
|
||||
|
@ -570,7 +570,7 @@ int bt_iso_chan_get_info(const struct bt_iso_chan *chan,
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BT_ISO_UNICAST) || defined(CONFIG_BT_ISO_SYNC_RECEIVER)
|
||||
#if defined(CONFIG_BT_ISO_RX)
|
||||
struct net_buf *bt_iso_get_rx(k_timeout_t timeout)
|
||||
{
|
||||
struct net_buf *buf = net_buf_alloc(&iso_rx_pool, timeout);
|
||||
|
@ -727,9 +727,9 @@ void bt_iso_recv(struct bt_conn *iso, struct net_buf *buf, uint8_t flags)
|
|||
|
||||
bt_conn_reset_rx_state(iso);
|
||||
}
|
||||
#endif /* CONFIG_BT_ISO_UNICAST) || defined(CONFIG_BT_ISO_SYNC_RECEIVER */
|
||||
#endif /* CONFIG_BT_ISO_RX */
|
||||
|
||||
#if defined(CONFIG_BT_CONN_TX)
|
||||
#if defined(CONFIG_BT_ISO_TX)
|
||||
static uint16_t iso_chan_max_data_len(const struct bt_iso_chan *chan)
|
||||
{
|
||||
size_t max_controller_data_len;
|
||||
|
@ -954,7 +954,7 @@ int bt_iso_chan_get_tx_sync(const struct bt_iso_chan *chan, struct bt_iso_tx_inf
|
|||
|
||||
return 0;
|
||||
}
|
||||
#endif /* CONFIG_BT_CONN_TX */
|
||||
#endif /* CONFIG_BT_ISO_TX */
|
||||
|
||||
#if defined(CONFIG_BT_ISO_UNICAST)
|
||||
int bt_iso_chan_disconnect(struct bt_iso_chan *chan)
|
||||
|
|
|
@ -24,8 +24,15 @@
|
|||
|
||||
#include "bt.h"
|
||||
|
||||
#if defined(CONFIG_BT_ISO_TX)
|
||||
#define DEFAULT_IO_QOS \
|
||||
{ \
|
||||
.sdu = 40u, .phy = BT_GAP_LE_PHY_2M, .rtn = 2u, \
|
||||
}
|
||||
|
||||
#define TX_BUF_TIMEOUT K_SECONDS(1)
|
||||
|
||||
static struct bt_iso_chan_io_qos iso_tx_qos = DEFAULT_IO_QOS;
|
||||
static uint32_t cis_sn_last;
|
||||
static uint32_t bis_sn_last;
|
||||
static int64_t cis_sn_last_updated_ticks;
|
||||
|
@ -61,7 +68,9 @@ static uint32_t get_next_sn(uint32_t last_sn, int64_t *last_ticks,
|
|||
|
||||
return (uint32_t)next_sn;
|
||||
}
|
||||
#endif /* CONFIG_BT_ISO_TX */
|
||||
|
||||
#if defined(CONFIG_BT_ISO_RX)
|
||||
static void iso_recv(struct bt_iso_chan *chan, const struct bt_iso_recv_info *info,
|
||||
struct net_buf *buf)
|
||||
{
|
||||
|
@ -70,6 +79,7 @@ static void iso_recv(struct bt_iso_chan *chan, const struct bt_iso_recv_info *in
|
|||
chan, buf->len, info->seq_num, info->ts);
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_BT_ISO_RX */
|
||||
|
||||
static void iso_connected(struct bt_iso_chan *chan)
|
||||
{
|
||||
|
@ -85,6 +95,7 @@ static void iso_connected(struct bt_iso_chan *chan)
|
|||
return;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BT_ISO_TX)
|
||||
if (iso_info.type == BT_ISO_CHAN_TYPE_CONNECTED) {
|
||||
cis_sn_last = 0U;
|
||||
cis_sn_last_updated_ticks = k_uptime_ticks();
|
||||
|
@ -92,6 +103,7 @@ static void iso_connected(struct bt_iso_chan *chan)
|
|||
bis_sn_last = 0U;
|
||||
bis_sn_last_updated_ticks = k_uptime_ticks();
|
||||
}
|
||||
#endif /* CONFIG_BT_ISO_TX */
|
||||
}
|
||||
|
||||
static void iso_disconnected(struct bt_iso_chan *chan, uint8_t reason)
|
||||
|
@ -101,20 +113,13 @@ static void iso_disconnected(struct bt_iso_chan *chan, uint8_t reason)
|
|||
}
|
||||
|
||||
static struct bt_iso_chan_ops iso_ops = {
|
||||
.recv = iso_recv,
|
||||
.connected = iso_connected,
|
||||
.disconnected = iso_disconnected,
|
||||
#if defined(CONFIG_BT_ISO_RX)
|
||||
.recv = iso_recv,
|
||||
#endif /* CONFIG_BT_ISO_RX */
|
||||
.connected = iso_connected,
|
||||
.disconnected = iso_disconnected,
|
||||
};
|
||||
|
||||
#define DEFAULT_IO_QOS \
|
||||
{ \
|
||||
.sdu = 40u, \
|
||||
.phy = BT_GAP_LE_PHY_2M, \
|
||||
.rtn = 2u, \
|
||||
}
|
||||
|
||||
static struct bt_iso_chan_io_qos iso_tx_qos = DEFAULT_IO_QOS;
|
||||
|
||||
#if defined(CONFIG_BT_ISO_UNICAST)
|
||||
static uint32_t cis_sdu_interval_us;
|
||||
|
||||
|
@ -934,7 +939,8 @@ static int cmd_big_term(const struct shell *sh, size_t argc, char *argv[])
|
|||
SHELL_STATIC_SUBCMD_SET_CREATE(iso_cmds,
|
||||
#if defined(CONFIG_BT_ISO_UNICAST)
|
||||
#if defined(CONFIG_BT_ISO_CENTRAL)
|
||||
SHELL_CMD_ARG(cig_create, NULL, "[dir=tx,rx,txrx] [C to P interval] [P to C interval] "
|
||||
SHELL_CMD_ARG(cig_create, NULL,
|
||||
"[dir=tx,rx,txrx] [C to P interval] [P to C interval] "
|
||||
"[packing] [framing] [C to P latency] [P to C latency] [sdu] [phy] [rtn]",
|
||||
cmd_cig_create, 1, 10),
|
||||
SHELL_CMD_ARG(cig_term, NULL, "Terminate the CIG", cmd_cig_term, 1, 0),
|
||||
|
@ -951,10 +957,10 @@ SHELL_STATIC_SUBCMD_SET_CREATE(iso_cmds,
|
|||
SHELL_CMD_ARG(listen, NULL, "<dir=tx,rx,txrx>", cmd_listen, 2, 0),
|
||||
#endif /* CONFIG_BT_SMP */
|
||||
#endif /* CONFIG_BT_ISO_PERIPHERAL */
|
||||
SHELL_CMD_ARG(send, NULL, "Send to ISO Channel [count]",
|
||||
cmd_send, 1, 1),
|
||||
SHELL_CMD_ARG(disconnect, NULL, "Disconnect ISO Channel",
|
||||
cmd_disconnect, 1, 0),
|
||||
#if defined(CONFIG_BT_ISO_TX)
|
||||
SHELL_CMD_ARG(send, NULL, "Send to ISO Channel [count]", cmd_send, 1, 1),
|
||||
#endif /* CONFIG_BT_ISO_TX */
|
||||
SHELL_CMD_ARG(disconnect, NULL, "Disconnect ISO Channel", cmd_disconnect, 1, 0),
|
||||
SHELL_CMD_ARG(tx_sync_read_cis, NULL, "Read CIS TX sync info", cmd_tx_sync_read_cis, 1, 0),
|
||||
#endif /* CONFIG_BT_ISO_UNICAST */
|
||||
#if defined(CONFIG_BT_ISO_BROADCASTER)
|
||||
|
@ -964,8 +970,10 @@ SHELL_STATIC_SUBCMD_SET_CREATE(iso_cmds,
|
|||
SHELL_CMD_ARG(tx_sync_read_bis, NULL, "Read BIS TX sync info", cmd_tx_sync_read_bis, 1, 0),
|
||||
#endif /* CONFIG_BT_ISO_BROADCASTER */
|
||||
#if defined(CONFIG_BT_ISO_SYNC_RECEIVER)
|
||||
SHELL_CMD_ARG(sync-big, NULL, "Synchronize to a BIG as a receiver <BIS bitfield> [mse] "
|
||||
"[timeout] [enc <broadcast code>]", cmd_big_sync, 2, 4),
|
||||
SHELL_CMD_ARG(sync-big, NULL,
|
||||
"Synchronize to a BIG as a receiver <BIS bitfield> [mse] "
|
||||
"[timeout] [enc <broadcast code>]",
|
||||
cmd_big_sync, 2, 4),
|
||||
#endif /* CONFIG_BT_ISO_SYNC_RECEIVER */
|
||||
#if defined(CONFIG_BT_ISO_BROADCAST)
|
||||
SHELL_CMD_ARG(term-big, NULL, "Terminate a BIG", cmd_big_term, 1, 0),
|
||||
|
|
Loading…
Reference in a new issue