Skip to content

Commit 13c4e70

Browse files
Thalleycvinayak
authored andcommitted
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 <[email protected]> (cherry picked from commit 9553347) Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent f3cda7d commit 13c4e70

File tree

7 files changed

+58
-42
lines changed

7 files changed

+58
-42
lines changed

subsys/bluetooth/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ config BT_MAX_CONN
120120

121121
config BT_CONN_TX
122122
bool
123-
default BT_CONN || BT_ISO_BROADCASTER
123+
default BT_CONN || BT_ISO_TX
124124
help
125125
Hidden configuration that is true if ACL or broadcast ISO is enabled
126126

subsys/bluetooth/Kconfig.iso

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,19 @@
77
config BT_ISO
88
bool
99

10+
config BT_ISO_TX
11+
bool
12+
13+
config BT_ISO_RX
14+
bool
15+
1016
# TODO: Split between client (central) and server (peripheral)
1117
config BT_ISO_UNICAST
1218
bool
1319
depends on BT_CONN
1420
select BT_ISO
21+
select BT_ISO_TX
22+
select BT_ISO_RX
1523
help
1624
This option enables support for Bluetooth Unicast
1725
Isochronous channels.
@@ -45,6 +53,7 @@ config BT_ISO_BROADCASTER
4553
bool "Bluetooth Isochronous Broadcaster Support [EXPERIMENTAL]"
4654
depends on !BT_CTLR || BT_CTLR_ADV_ISO_SUPPORT
4755
select BT_ISO_BROADCAST
56+
select BT_ISO_TX
4857
select BT_BROADCASTER
4958
select BT_PER_ADV
5059
select EXPERIMENTAL
@@ -55,6 +64,7 @@ config BT_ISO_SYNC_RECEIVER
5564
bool "Bluetooth Isochronous Synchronized Receiver Support [EXPERIMENTAL]"
5665
depends on !BT_CTLR || BT_CTLR_SYNC_ISO_SUPPORT
5766
select BT_ISO_BROADCAST
67+
select BT_ISO_RX
5868
select BT_OBSERVER
5969
select BT_PER_ADV_SYNC
6070
select EXPERIMENTAL

subsys/bluetooth/host/buf.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ struct net_buf *bt_buf_get_rx(enum bt_buf_type type, k_timeout_t timeout)
6262
__ASSERT(type == BT_BUF_EVT || type == BT_BUF_ACL_IN ||
6363
type == BT_BUF_ISO_IN, "Invalid buffer type requested");
6464

65-
if ((IS_ENABLED(CONFIG_BT_ISO_UNICAST) ||
66-
IS_ENABLED(CONFIG_BT_ISO_SYNC_RECEIVER)) &&
67-
type == BT_BUF_ISO_IN) {
65+
if (IS_ENABLED(CONFIG_BT_ISO_RX) && type == BT_BUF_ISO_IN) {
6866
return bt_iso_get_rx(timeout);
6967
}
7068

subsys/bluetooth/host/conn.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,7 @@ void bt_conn_recv(struct bt_conn *conn, struct net_buf *buf, uint8_t flags)
391391

392392
LOG_DBG("handle %u len %u flags %02x", conn->handle, buf->len, flags);
393393

394-
if ((IS_ENABLED(CONFIG_BT_ISO_UNICAST) ||
395-
IS_ENABLED(CONFIG_BT_ISO_SYNC_RECEIVER)) &&
396-
conn->type == BT_CONN_TYPE_ISO) {
394+
if (IS_ENABLED(CONFIG_BT_ISO_RX) && conn->type == BT_CONN_TYPE_ISO) {
397395
bt_iso_recv(conn, buf, flags);
398396
return;
399397
} else if (IS_ENABLED(CONFIG_BT_CONN)) {

subsys/bluetooth/host/hci_core.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3288,11 +3288,15 @@ static int le_init_iso(void)
32883288
read_buffer_size_v2_complete(rsp);
32893289

32903290
net_buf_unref(rsp);
3291-
} else if (IS_ENABLED(CONFIG_BT_CONN)) {
3292-
LOG_WRN("Read Buffer Size V2 command is not supported."
3293-
"No ISO buffers will be available");
3291+
} else if (IS_ENABLED(CONFIG_BT_CONN_TX)) {
3292+
if (IS_ENABLED(CONFIG_BT_ISO_TX)) {
3293+
LOG_WRN("Read Buffer Size V2 command is not supported. "
3294+
"No ISO TX buffers will be available");
3295+
}
32943296

3295-
/* Read LE Buffer Size */
3297+
/* Read LE Buffer Size in the case that we support ACL without TX ISO (e.g. if we
3298+
* only support ISO sync receiver).
3299+
*/
32963300
err = bt_hci_cmd_send_sync(BT_HCI_OP_LE_READ_BUFFER_SIZE,
32973301
NULL, &rsp);
32983302
if (err) {

subsys/bluetooth/host/iso.c

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ LOG_MODULE_REGISTER(bt_iso);
3434

3535
#define iso_chan(_iso) ((_iso)->iso.chan);
3636

37-
#if defined(CONFIG_BT_ISO_UNICAST) || defined(CONFIG_BT_ISO_SYNC_RECEIVER)
37+
#if defined(CONFIG_BT_ISO_RX)
3838
NET_BUF_POOL_FIXED_DEFINE(iso_rx_pool, CONFIG_BT_ISO_RX_BUF_COUNT,
3939
BT_ISO_SDU_BUF_SIZE(CONFIG_BT_ISO_RX_MTU),
4040
sizeof(struct iso_data), NULL);
4141

4242
static struct bt_iso_recv_info iso_info_data[CONFIG_BT_ISO_RX_BUF_COUNT];
4343
#define iso_info(buf) (&iso_info_data[net_buf_id(buf)])
44-
#endif /* CONFIG_BT_ISO_UNICAST || CONFIG_BT_ISO_SYNC_RECEIVER */
44+
#endif /* CONFIG_BT_ISO_RX */
4545

4646
#if defined(CONFIG_BT_ISO_UNICAST) || defined(CONFIG_BT_ISO_BROADCAST)
4747
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];
8080
static struct bt_iso_big *lookup_big_by_handle(uint8_t big_handle);
8181
#endif /* CONFIG_BT_ISO_BROADCAST */
8282

83-
#if defined(CONFIG_BT_ISO_UNICAST) || defined(CONFIG_BT_ISO_BROADCASTER)
83+
#if defined(CONFIG_BT_ISO_TX)
8484
static void bt_iso_send_cb(struct bt_conn *iso, void *user_data, int err)
8585
{
8686
struct bt_iso_chan *chan = iso->iso.chan;
@@ -94,8 +94,7 @@ static void bt_iso_send_cb(struct bt_conn *iso, void *user_data, int err)
9494
ops->sent(chan);
9595
}
9696
}
97-
#endif /* CONFIG_BT_ISO_UNICAST || CONFIG_BT_ISO_BROADCASTER */
98-
97+
#endif /* CONFIG_BT_ISO_TX */
9998

10099
void hci_iso(struct net_buf *buf)
101100
{
@@ -571,7 +570,7 @@ int bt_iso_chan_get_info(const struct bt_iso_chan *chan,
571570
return 0;
572571
}
573572

574-
#if defined(CONFIG_BT_ISO_UNICAST) || defined(CONFIG_BT_ISO_SYNC_RECEIVER)
573+
#if defined(CONFIG_BT_ISO_RX)
575574
struct net_buf *bt_iso_get_rx(k_timeout_t timeout)
576575
{
577576
struct net_buf *buf = net_buf_alloc(&iso_rx_pool, timeout);
@@ -728,11 +727,10 @@ void bt_iso_recv(struct bt_conn *iso, struct net_buf *buf, uint8_t flags)
728727

729728
bt_conn_reset_rx_state(iso);
730729
}
731-
#endif /* CONFIG_BT_ISO_UNICAST) || defined(CONFIG_BT_ISO_SYNC_RECEIVER */
730+
#endif /* CONFIG_BT_ISO_RX */
732731

733-
#if defined(CONFIG_BT_ISO_UNICAST) || defined(CONFIG_BT_ISO_BROADCASTER)
734-
static uint16_t iso_chan_max_data_len(const struct bt_iso_chan *chan,
735-
uint32_t ts)
732+
#if defined(CONFIG_BT_ISO_TX)
733+
static uint16_t iso_chan_max_data_len(const struct bt_iso_chan *chan)
736734
{
737735
size_t max_controller_data_len;
738736
uint16_t max_data_len;
@@ -787,7 +785,7 @@ int bt_iso_chan_send(struct bt_iso_chan *chan, struct net_buf *buf,
787785
return -EMSGSIZE;
788786
}
789787

790-
max_data_len = iso_chan_max_data_len(chan, ts);
788+
max_data_len = iso_chan_max_data_len(chan);
791789
if (buf->len > max_data_len) {
792790
LOG_DBG("Cannot send %u octets, maximum %u", buf->len, max_data_len);
793791
return -EMSGSIZE;
@@ -935,7 +933,7 @@ int bt_iso_chan_get_tx_sync(const struct bt_iso_chan *chan, struct bt_iso_tx_inf
935933

936934
return 0;
937935
}
938-
#endif /* CONFIG_BT_ISO_UNICAST) || CONFIG_BT_ISO_BROADCASTER */
936+
#endif /* CONFIG_BT_ISO_TX */
939937

940938
#if defined(CONFIG_BT_ISO_UNICAST)
941939
int bt_iso_chan_disconnect(struct bt_iso_chan *chan)

subsys/bluetooth/shell/iso.c

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,15 @@
2424

2525
#include "bt.h"
2626

27+
#if defined(CONFIG_BT_ISO_TX)
28+
#define DEFAULT_IO_QOS \
29+
{ \
30+
.sdu = 40u, .phy = BT_GAP_LE_PHY_2M, .rtn = 2u, \
31+
}
32+
2733
#define TX_BUF_TIMEOUT K_SECONDS(1)
2834

35+
static struct bt_iso_chan_io_qos iso_tx_qos = DEFAULT_IO_QOS;
2936
static uint32_t cis_sn_last;
3037
static uint32_t bis_sn_last;
3138
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,
6168

6269
return (uint32_t)next_sn;
6370
}
71+
#endif /* CONFIG_BT_ISO_TX */
6472

73+
#if defined(CONFIG_BT_ISO_RX)
6574
static void iso_recv(struct bt_iso_chan *chan, const struct bt_iso_recv_info *info,
6675
struct net_buf *buf)
6776
{
@@ -70,6 +79,7 @@ static void iso_recv(struct bt_iso_chan *chan, const struct bt_iso_recv_info *in
7079
chan, buf->len, info->seq_num, info->ts);
7180
}
7281
}
82+
#endif /* CONFIG_BT_ISO_RX */
7383

7484
static void iso_connected(struct bt_iso_chan *chan)
7585
{
@@ -85,13 +95,15 @@ static void iso_connected(struct bt_iso_chan *chan)
8595
return;
8696
}
8797

98+
#if defined(CONFIG_BT_ISO_TX)
8899
if (iso_info.type == BT_ISO_CHAN_TYPE_CONNECTED) {
89100
cis_sn_last = 0U;
90101
cis_sn_last_updated_ticks = k_uptime_ticks();
91102
} else {
92103
bis_sn_last = 0U;
93104
bis_sn_last_updated_ticks = k_uptime_ticks();
94105
}
106+
#endif /* CONFIG_BT_ISO_TX */
95107
}
96108

97109
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)
101113
}
102114

103115
static struct bt_iso_chan_ops iso_ops = {
104-
.recv = iso_recv,
105-
.connected = iso_connected,
106-
.disconnected = iso_disconnected,
116+
#if defined(CONFIG_BT_ISO_RX)
117+
.recv = iso_recv,
118+
#endif /* CONFIG_BT_ISO_RX */
119+
.connected = iso_connected,
120+
.disconnected = iso_disconnected,
107121
};
108122

109-
#define DEFAULT_IO_QOS \
110-
{ \
111-
.sdu = 40u, \
112-
.phy = BT_GAP_LE_PHY_2M, \
113-
.rtn = 2u, \
114-
}
115-
116-
static struct bt_iso_chan_io_qos iso_tx_qos = DEFAULT_IO_QOS;
117-
118123
#if defined(CONFIG_BT_ISO_UNICAST)
119124
static uint32_t cis_sdu_interval_us;
120125

@@ -935,7 +940,8 @@ static int cmd_big_term(const struct shell *sh, size_t argc, char *argv[])
935940
SHELL_STATIC_SUBCMD_SET_CREATE(iso_cmds,
936941
#if defined(CONFIG_BT_ISO_UNICAST)
937942
#if defined(CONFIG_BT_ISO_CENTRAL)
938-
SHELL_CMD_ARG(cig_create, NULL, "[dir=tx,rx,txrx] [C to P interval] [P to C interval] "
943+
SHELL_CMD_ARG(cig_create, NULL,
944+
"[dir=tx,rx,txrx] [C to P interval] [P to C interval] "
939945
"[packing] [framing] [C to P latency] [P to C latency] [sdu] [phy] [rtn]",
940946
cmd_cig_create, 1, 10),
941947
SHELL_CMD_ARG(cig_term, NULL, "Terminate the CIG", cmd_cig_term, 1, 0),
@@ -952,10 +958,10 @@ SHELL_STATIC_SUBCMD_SET_CREATE(iso_cmds,
952958
SHELL_CMD_ARG(listen, NULL, "<dir=tx,rx,txrx>", cmd_listen, 2, 0),
953959
#endif /* CONFIG_BT_SMP */
954960
#endif /* CONFIG_BT_ISO_PERIPHERAL */
955-
SHELL_CMD_ARG(send, NULL, "Send to ISO Channel [count]",
956-
cmd_send, 1, 1),
957-
SHELL_CMD_ARG(disconnect, NULL, "Disconnect ISO Channel",
958-
cmd_disconnect, 1, 0),
961+
#if defined(CONFIG_BT_ISO_TX)
962+
SHELL_CMD_ARG(send, NULL, "Send to ISO Channel [count]", cmd_send, 1, 1),
963+
#endif /* CONFIG_BT_ISO_TX */
964+
SHELL_CMD_ARG(disconnect, NULL, "Disconnect ISO Channel", cmd_disconnect, 1, 0),
959965
SHELL_CMD_ARG(tx_sync_read_cis, NULL, "Read CIS TX sync info", cmd_tx_sync_read_cis, 1, 0),
960966
#endif /* CONFIG_BT_ISO_UNICAST */
961967
#if defined(CONFIG_BT_ISO_BROADCASTER)
@@ -965,8 +971,10 @@ SHELL_STATIC_SUBCMD_SET_CREATE(iso_cmds,
965971
SHELL_CMD_ARG(tx_sync_read_bis, NULL, "Read BIS TX sync info", cmd_tx_sync_read_bis, 1, 0),
966972
#endif /* CONFIG_BT_ISO_BROADCASTER */
967973
#if defined(CONFIG_BT_ISO_SYNC_RECEIVER)
968-
SHELL_CMD_ARG(sync-big, NULL, "Synchronize to a BIG as a receiver <BIS bitfield> [mse] "
969-
"[timeout] [enc <broadcast code>]", cmd_big_sync, 2, 4),
974+
SHELL_CMD_ARG(sync-big, NULL,
975+
"Synchronize to a BIG as a receiver <BIS bitfield> [mse] "
976+
"[timeout] [enc <broadcast code>]",
977+
cmd_big_sync, 2, 4),
970978
#endif /* CONFIG_BT_ISO_SYNC_RECEIVER */
971979
#if defined(CONFIG_BT_ISO_BROADCAST)
972980
SHELL_CMD_ARG(term-big, NULL, "Terminate a BIG", cmd_big_term, 1, 0),

0 commit comments

Comments
 (0)