Bluetooth: ISO: Add Kconfig for ISO central/peripheral

Add two new Kconfigs: BT_ISO_CENTRAL and BT_ISO_PERIPHERAL
that is used to do central or peripheral only builds,
similar to the BT_CENTRAL or BT_PERIPHERAL Kconfigs.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
Emil Gydesen 2021-12-02 14:00:55 +01:00 committed by Marti Bolivar
commit 3f247b212b
10 changed files with 62 additions and 20 deletions

View file

@ -1,4 +1,3 @@
CONFIG_BT=y
CONFIG_BT_DEBUG_LOG=y
CONFIG_BT_CENTRAL=y
CONFIG_BT_ISO_UNICAST=y
CONFIG_BT_ISO_CENTRAL=y

View file

@ -3,9 +3,8 @@ CONFIG_CONSOLE_GETCHAR=y
CONFIG_BT_DEVICE_NAME="ISO Connected Throughput"
CONFIG_BT=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_CENTRAL=y
CONFIG_BT_ISO_UNICAST=y
CONFIG_BT_ISO_CENTRAL=y
CONFIG_BT_ISO_PERIPHERAL=y
CONFIG_BT_ISO_MAX_CHAN=2
CONFIG_BT_ISO_TX_BUF_COUNT=4

View file

@ -1,5 +1,4 @@
CONFIG_BT=y
CONFIG_BT_DEBUG_LOG=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_DEVICE_NAME="Zephyr ISO server"
CONFIG_BT_ISO_UNICAST=y
CONFIG_BT_ISO_PERIPHERAL=y

View file

@ -6,16 +6,32 @@
config BT_ISO
bool
select EXPERIMENTAL
# TODO: Split between client (central) and server (peripheral)
config BT_ISO_UNICAST
bool "Bluetooth Isochronous Channel Unicast Support [EXPERIMENTAL]"
bool
depends on BT_CONN
select BT_ISO
select EXPERIMENTAL
help
This option enables support for Bluetooth Unicast
Isochronous channels.
config BT_ISO_PERIPHERAL
bool "Bluetooth Isochronous Channel Unicast Peripheral Support [EXPERIMENTAL]"
select BT_PERIPHERAL
select BT_ISO_UNICAST
help
This option enables support for Bluetooth Unicast
Isochronous channels for the peripheral role.
config BT_ISO_CENTRAL
bool "Bluetooth Isochronous Channel Unicast Central Support [EXPERIMENTAL]"
select BT_CENTRAL
select BT_ISO_UNICAST
help
This option enables support for Bluetooth Broadcast
Isochronous channels.
Isochronous channels for the central role.
config BT_ISO_BROADCAST
bool
@ -35,7 +51,6 @@ config BT_ISO_SYNC_RECEIVER
select BT_ISO_BROADCAST
select BT_OBSERVER
select BT_PER_ADV_SYNC
select EXPERIMENTAL
help
This option enables support for the Bluetooth Isochronous
Synchronized Receiver.

View file

@ -17,6 +17,7 @@ config BT_AUDIO_UNICAST_SERVER
select EXPERIMENTAL
select BT_PERIPHERAL
select BT_AUDIO_UNICAST
select BT_ISO_PERIPHERAL
select BT_GATT_DYNAMIC_DB
select BT_GATT_CACHING
select BT_PACS
@ -29,6 +30,7 @@ config BT_AUDIO_UNICAST_CLIENT
bool "Bluetooth Unicast Audio Client Support [EXPERIMENTAL]"
select EXPERIMENTAL
select BT_AUDIO_UNICAST
select BT_ISO_CENTRAL
select BT_CENTRAL
select BT_GATT_CLIENT
select BT_GATT_AUTO_DISCOVER_CCC

View file

@ -2226,8 +2226,10 @@ static const struct event_handler meta_events[] = {
#if defined(CONFIG_BT_ISO_UNICAST)
EVENT_HANDLER(BT_HCI_EVT_LE_CIS_ESTABLISHED, hci_le_cis_established,
sizeof(struct bt_hci_evt_le_cis_established)),
#if defined(CONFIG_BT_ISO_PERIPHERAL)
EVENT_HANDLER(BT_HCI_EVT_LE_CIS_REQ, hci_le_cis_req,
sizeof(struct bt_hci_evt_le_cis_req)),
#endif /* (CONFIG_BT_ISO_PERIPHERAL) */
#endif /* (CONFIG_BT_ISO_UNICAST) */
#if defined(CONFIG_BT_ISO_BROADCASTER)
EVENT_HANDLER(BT_HCI_EVT_LE_BIG_COMPLETE,

View file

@ -47,12 +47,15 @@ NET_BUF_POOL_FIXED_DEFINE(iso_frag_pool, CONFIG_BT_ISO_TX_FRAG_COUNT,
struct bt_conn iso_conns[CONFIG_BT_ISO_MAX_CHAN];
/* TODO: Allow more than one server? */
#if defined(CONFIG_BT_ISO_UNICAST)
#if defined(CONFIG_BT_ISO_CENTRAL)
struct bt_iso_cig cigs[CONFIG_BT_ISO_MAX_CIG];
static struct bt_iso_server *iso_server;
static struct bt_iso_cig *get_cig(const struct bt_iso_chan *iso_chan);
#endif /* CONFIG_BT_ISO_UNICAST */
#endif /* CONFIG_BT_ISO_CENTRAL */
#if defined(CONFIG_BT_ISO_PERIPHERAL)
static struct bt_iso_server *iso_server;
#endif /* CONFIG_BT_ISO_PERIPHERAL */
#if defined(CONFIG_BT_ISO_BROADCAST)
struct bt_iso_big bigs[CONFIG_BT_ISO_MAX_BIG];
@ -216,6 +219,7 @@ static int hci_le_setup_iso_data_path(const struct bt_conn *iso, uint8_t dir,
return err;
}
#if defined(CONFIG_BT_ISO_CENTRAL)
static int hci_le_remove_iso_data_path(struct bt_conn *iso, uint8_t dir)
{
struct bt_hci_cp_le_remove_iso_path *cp;
@ -246,6 +250,7 @@ static int hci_le_remove_iso_data_path(struct bt_conn *iso, uint8_t dir)
return err;
}
#endif /* CONFIG_BT_ISO_CENTRAL */
static void bt_iso_chan_add(struct bt_conn *iso, struct bt_iso_chan *chan)
{
@ -388,10 +393,14 @@ void bt_iso_connected(struct bt_conn *iso)
}
}
#if defined(CONFIG_BT_ISO_CENTRAL)
static void bt_iso_remove_data_path(struct bt_conn *iso)
{
BT_DBG("%p", iso);
/* TODO: Removing the ISO data path is never used for broadcast:
* Remove the following broadcast implementation?
*/
if ((IS_ENABLED(CONFIG_BT_ISO_BROADCASTER) &&
iso->iso.info.type == BT_ISO_CHAN_TYPE_BROADCASTER) ||
(IS_ENABLED(CONFIG_BT_ISO_SYNC_RECEIVER) &&
@ -431,6 +440,7 @@ static void bt_iso_remove_data_path(struct bt_conn *iso)
iso->iso.info.type);
}
}
#endif /* CONFIG_BT_ISO_CENTRAL */
static void bt_iso_chan_disconnected(struct bt_iso_chan *chan, uint8_t reason)
{
@ -450,14 +460,13 @@ static void bt_iso_chan_disconnected(struct bt_iso_chan *chan, uint8_t reason)
if (chan->iso->role == BT_HCI_ROLE_PERIPHERAL) {
bt_conn_unref(chan->iso);
chan->iso = NULL;
#if defined(CONFIG_BT_ISO_CENTRAL)
} else {
/* ISO data paths are automatically removed when the
* peripheral disconnects, so we only need to
* move it for the central
*/
bt_iso_remove_data_path(chan->iso);
#if defined(CONFIG_BT_ISO_UNICAST)
bool is_chan_connected;
struct bt_iso_cig *cig;
struct bt_iso_chan *cis_chan;
@ -478,7 +487,7 @@ static void bt_iso_chan_disconnected(struct bt_iso_chan *chan, uint8_t reason)
if (!is_chan_connected) {
cig->state = BT_ISO_CIG_STATE_INACTIVE;
}
#endif /* CONFIG_BT_ISO_UNICAST */
#endif /* CONFIG_BT_ISO_CENTRAL */
}
}
@ -779,6 +788,7 @@ int bt_iso_chan_send(struct bt_iso_chan *chan, struct net_buf *buf)
return bt_conn_send_cb(iso_conn, buf, bt_iso_send_cb, NULL);
}
#if defined(CONFIG_BT_ISO_CENTRAL) || defined(CONFIG_BT_ISO_BROADCASTER)
static bool valid_chan_io_qos(const struct bt_iso_chan_io_qos *io_qos,
bool is_tx)
{
@ -798,9 +808,11 @@ static bool valid_chan_io_qos(const struct bt_iso_chan_io_qos *io_qos,
return true;
}
#endif /* CONFIG_BT_ISO_CENTRAL || CONFIG_BT_ISO_BROADCASTER */
#endif /* CONFIG_BT_ISO_UNICAST) || CONFIG_BT_ISO_BROADCASTER */
#if defined(CONFIG_BT_ISO_UNICAST)
#if defined(CONFIG_BT_ISO_PERIPHERAL)
static int iso_accept(struct bt_conn *acl, struct bt_conn *iso)
{
struct bt_iso_accept_info accept_info;
@ -834,7 +846,9 @@ static int iso_accept(struct bt_conn *acl, struct bt_conn *iso)
return 0;
}
#endif /* CONFIG_BT_ISO_PERIPHERAL */
#if defined(CONFIG_BT_ISO_CENTRAL)
static bool valid_chan_qos(const struct bt_iso_chan_qos *qos)
{
if (qos->rx != NULL) {
@ -856,6 +870,7 @@ static bool valid_chan_qos(const struct bt_iso_chan_qos *qos)
return true;
}
#endif /* CONFIG_BT_ISO_CENTRAL */
void bt_iso_cleanup_acl(struct bt_conn *iso)
{
@ -961,6 +976,7 @@ void hci_le_cis_established(struct net_buf *buf)
bt_conn_unref(iso);
}
#if defined(CONFIG_BT_ISO_PERIPHERAL)
int hci_le_reject_cis(uint16_t handle, uint8_t reason)
{
struct bt_hci_cp_le_reject_cis *cp;
@ -1072,7 +1088,9 @@ void hci_le_cis_req(struct net_buf *buf)
return;
}
}
#endif /* CONFIG_BT_ISO_PERIPHERAL */
#if defined(CONFIG_BT_ISO_CENTRAL)
static int hci_le_remove_cig(uint8_t cig_id)
{
struct bt_hci_cp_le_remove_cig *req;
@ -1091,7 +1109,9 @@ static int hci_le_remove_cig(uint8_t cig_id)
return bt_hci_cmd_send_sync(BT_HCI_OP_LE_REMOVE_CIG, buf, NULL);
}
#endif /* CONFIG_BT_ISO_CENTRAL */
#if defined(CONFIG_BT_ISO_PERIPHERAL)
struct bt_conn *bt_conn_add_iso(struct bt_conn *acl)
{
struct bt_conn *iso = iso_new();
@ -1105,7 +1125,9 @@ struct bt_conn *bt_conn_add_iso(struct bt_conn *acl)
return iso;
}
#endif /* CONFIG_BT_ISO_PERIPHERAL */
#if defined(CONFIG_BT_ISO_CENTRAL)
static struct net_buf *hci_le_set_cig_params(const struct bt_iso_cig *cig,
const struct bt_iso_cig_param *param)
{
@ -1641,6 +1663,7 @@ int bt_iso_chan_connect(const struct bt_iso_connect_param *param, size_t count)
return 0;
}
#endif /* CONFIG_BT_ISO_CENTRAL */
int bt_iso_chan_disconnect(struct bt_iso_chan *chan)
{
@ -1662,6 +1685,7 @@ int bt_iso_chan_disconnect(struct bt_iso_chan *chan)
return bt_conn_disconnect(chan->iso, BT_HCI_ERR_REMOTE_USER_TERM_CONN);
}
#if defined(CONFIG_BT_ISO_PERIPHERAL)
int bt_iso_server_register(struct bt_iso_server *server)
{
CHECKIF(!server) {
@ -1695,6 +1719,7 @@ int bt_iso_server_register(struct bt_iso_server *server)
return 0;
}
#endif /* CONFIG_BT_ISO_PERIPHERAL */
#endif /* CONFIG_BT_ISO_UNICAST */
#if defined(CONFIG_BT_ISO_BROADCAST)

View file

@ -2,6 +2,6 @@ CONFIG_BT=y
CONFIG_BT_CTLR=y
CONFIG_BT_CENTRAL=y
CONFIG_BT_LL_SW_SPLIT=y
CONFIG_BT_ISO_UNICAST=y
CONFIG_BT_ISO_CENTRAL=y
CONFIG_BT_CTLR_CENTRAL_ISO=y
CONFIG_ZTEST=y

View file

@ -2,6 +2,6 @@ CONFIG_BT=y
CONFIG_BT_CTLR=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_LL_SW_SPLIT=y
CONFIG_BT_ISO_UNICAST=y
CONFIG_BT_ISO_PERIPHERAL=y
CONFIG_BT_CTLR_PERIPHERAL_ISO=y
CONFIG_ZTEST=y

View file

@ -49,4 +49,5 @@ CONFIG_BT_AUTO_PHY_UPDATE=y
CONFIG_BT_ISO_BROADCASTER=y
CONFIG_BT_ISO_SYNC_RECEIVER=y
CONFIG_BT_ISO_UNICAST=y
CONFIG_BT_ISO_CENTRAL=y
CONFIG_BT_ISO_PERIPHERAL=y