2424#define LOG_MODULE_NAME bt_iso
2525#include "common/log.h"
2626
27+ #if defined(CONFIG_BT_ISO_UNICAST ) || defined(CONFIG_BT_ISO_BROADCAST )
2728NET_BUF_POOL_FIXED_DEFINE (iso_tx_pool , CONFIG_BT_ISO_TX_BUF_COUNT ,
2829 BT_ISO_SDU_BUF_SIZE (CONFIG_BT_ISO_TX_MTU ), NULL );
30+ #endif /* CONFIG_BT_ISO_UNICAST || CONFIG_BT_ISO_BROADCAST */
31+
32+ #if defined(CONFIG_BT_ISO_UNICAST ) || defined(CONFIG_BT_ISO_SYNC_RECEIVER )
2933NET_BUF_POOL_FIXED_DEFINE (iso_rx_pool , CONFIG_BT_ISO_RX_BUF_COUNT ,
3034 CONFIG_BT_ISO_RX_MTU , NULL );
3135
3236static struct bt_iso_recv_info iso_info_data [CONFIG_BT_ISO_RX_BUF_COUNT ];
3337#define iso_info (buf ) (&iso_info_data[net_buf_id(buf)])
38+ #endif /* CONFIG_BT_ISO_UNICAST || CONFIG_BT_ISO_SYNC_RECEIVER */
3439#define iso_chan (_iso ) ((_iso)->iso.chan);
3540
41+ #if defined(CONFIG_BT_ISO_UNICAST ) || defined(CONFIG_BT_ISO_BROADCAST )
3642#if CONFIG_BT_ISO_TX_FRAG_COUNT > 0
3743NET_BUF_POOL_FIXED_DEFINE (iso_frag_pool , CONFIG_BT_ISO_TX_FRAG_COUNT ,
3844 BT_ISO_SDU_BUF_SIZE (CONFIG_BT_ISO_TX_MTU ), NULL );
3945#endif /* CONFIG_BT_ISO_TX_FRAG_COUNT > 0 */
46+ #endif /* CONFIG_BT_ISO_UNICAST || CONFIG_BT_ISO_BROADCAST */
4047
4148struct bt_conn iso_conns [CONFIG_BT_ISO_MAX_CHAN ];
4249
@@ -49,11 +56,12 @@ static struct bt_iso_server *iso_server;
4956struct bt_iso_big bigs [CONFIG_BT_ISO_MAX_BIG ];
5057
5158static struct bt_iso_big * lookup_big_by_handle (uint8_t big_handle );
52- #endif /* defined( CONFIG_BT_ISO_BROADCAST) */
59+ #endif /* CONFIG_BT_ISO_BROADCAST */
5360
5461/* Prototype */
5562int hci_le_remove_cig (uint8_t cig_id );
5663
64+ #if defined(CONFIG_BT_ISO_UNICAST ) || defined(CONFIG_BT_ISO_SYNC_RECEIVER )
5765struct net_buf * bt_iso_get_rx (k_timeout_t timeout )
5866{
5967 struct net_buf * buf = net_buf_alloc (& iso_rx_pool , timeout );
@@ -65,7 +73,9 @@ struct net_buf *bt_iso_get_rx(k_timeout_t timeout)
6573
6674 return buf ;
6775}
76+ #endif /* CONFIG_BT_ISO_UNICAST || CONFIG_BT_ISO_SYNC_RECEIVER */
6877
78+ #if defined(CONFIG_BT_ISO_UNICAST ) || defined(CONFIG_BT_ISO_BROADCASTER )
6979static void bt_iso_send_cb (struct bt_conn * iso , void * user_data )
7080{
7181 struct bt_iso_chan * chan = iso -> iso .chan ;
@@ -79,6 +89,7 @@ static void bt_iso_send_cb(struct bt_conn *iso, void *user_data)
7989 ops -> sent (chan );
8090 }
8191}
92+ #endif /* CONFIG_BT_ISO_UNICAST || CONFIG_BT_ISO_BROADCASTER */
8293
8394void hci_iso (struct net_buf * buf )
8495{
@@ -530,6 +541,7 @@ void bt_iso_chan_set_state(struct bt_iso_chan *chan, uint8_t state)
530541}
531542#endif /* CONFIG_BT_DEBUG_ISO */
532543
544+ #if defined(CONFIG_BT_ISO_UNICAST ) || defined(CONFIG_BT_ISO_SYNC_RECEIVER )
533545void bt_iso_recv (struct bt_conn * iso , struct net_buf * buf , uint8_t flags )
534546{
535547 struct bt_hci_iso_data_hdr * hdr ;
@@ -671,7 +683,9 @@ void bt_iso_recv(struct bt_conn *iso, struct net_buf *buf, uint8_t flags)
671683
672684 bt_conn_reset_rx_state (iso );
673685}
686+ #endif /* CONFIG_BT_ISO_UNICAST) || defined(CONFIG_BT_ISO_SYNC_RECEIVER */
674687
688+ #if defined(CONFIG_BT_ISO_UNICAST ) || defined(CONFIG_BT_ISO_BROADCASTER )
675689int bt_iso_chan_send (struct bt_iso_chan * chan , struct net_buf * buf )
676690{
677691 struct bt_hci_iso_data_hdr * hdr ;
@@ -697,6 +711,7 @@ int bt_iso_chan_send(struct bt_iso_chan *chan, struct net_buf *buf)
697711
698712 return bt_conn_send_cb (chan -> iso , buf , bt_iso_send_cb , NULL );
699713}
714+ #endif /* CONFIG_BT_ISO_UNICAST) || CONFIG_BT_ISO_BROADCASTER */
700715
701716static bool valid_chan_io_qos (const struct bt_iso_chan_io_qos * io_qos ,
702717 bool is_tx )
@@ -1484,13 +1499,13 @@ static int big_init_bis(struct bt_iso_big *big, bool broadcaster)
14841499 return - EINVAL ;
14851500 }
14861501
1487- if (broadcaster ) {
1502+ if (IS_ENABLED ( CONFIG_BT_ISO_BROADCASTER ) && broadcaster ) {
14881503 CHECKIF (bis -> qos -> tx == NULL ||
14891504 !valid_chan_io_qos (bis -> qos -> tx , true)) {
14901505 BT_DBG ("Invalid BIS QOS" );
14911506 return - EINVAL ;
14921507 }
1493- } else {
1508+ } else if ( IS_ENABLED ( CONFIG_BT_ISO_SYNC_RECEIVER )) {
14941509 CHECKIF (bis -> qos -> rx == NULL ) {
14951510 BT_DBG ("Invalid BIS QOS" );
14961511 return - EINVAL ;
@@ -1514,6 +1529,7 @@ static int big_init_bis(struct bt_iso_big *big, bool broadcaster)
15141529 return 0 ;
15151530}
15161531
1532+ #if defined(CONFIG_BT_ISO_BROADCASTER )
15171533static int hci_le_create_big (struct bt_le_ext_adv * padv , struct bt_iso_big * big ,
15181534 struct bt_iso_big_create_param * param )
15191535{
@@ -1649,6 +1665,7 @@ int bt_iso_big_create(struct bt_le_ext_adv *padv, struct bt_iso_big_create_param
16491665
16501666 return err ;
16511667}
1668+ #endif /* CONFIG_BT_ISO_BROADCASTER */
16521669
16531670static int hci_le_terminate_big (struct bt_iso_big * big )
16541671{
@@ -1717,7 +1734,7 @@ int bt_iso_big_terminate(struct bt_iso_big *big)
17171734 /* They all have the same QOS dir so we can just check the first */
17181735 broadcaster = big -> bis [0 ]-> qos -> tx ? true : false;
17191736
1720- if (broadcaster ) {
1737+ if (IS_ENABLED ( CONFIG_BT_ISO_BROADCASTER ) && broadcaster ) {
17211738 err = hci_le_terminate_big (big );
17221739
17231740 /* Wait for BT_HCI_EVT_LE_BIG_TERMINATE before cleaning up
@@ -1728,13 +1745,15 @@ int bt_iso_big_terminate(struct bt_iso_big *big)
17281745 bt_iso_chan_set_state (big -> bis [i ], BT_ISO_DISCONNECT );
17291746 }
17301747 }
1731- } else {
1748+ } else if ( IS_ENABLED ( CONFIG_BT_ISO_SYNC_RECEIVER )) {
17321749 err = hci_le_big_sync_term (big );
17331750
17341751 if (!err ) {
17351752 big_disconnect (big , BT_HCI_ERR_LOCALHOST_TERM_CONN );
17361753 cleanup_big (big );
17371754 }
1755+ } else {
1756+ err = - EINVAL ;
17381757 }
17391758
17401759 if (err ) {
@@ -1744,6 +1763,7 @@ int bt_iso_big_terminate(struct bt_iso_big *big)
17441763 return err ;
17451764}
17461765
1766+ #if defined(CONFIG_BT_ISO_BROADCASTER )
17471767void hci_le_big_complete (struct net_buf * buf )
17481768{
17491769 struct bt_hci_evt_le_big_complete * evt = (void * )buf -> data ;
@@ -1801,7 +1821,9 @@ void hci_le_big_terminate(struct net_buf *buf)
18011821 big_disconnect (big , evt -> reason );
18021822 cleanup_big (big );
18031823}
1824+ #endif /* CONFIG_BT_ISO_BROADCASTER */
18041825
1826+ #if defined(CONFIG_BT_ISO_SYNC_RECEIVER )
18051827void hci_le_big_sync_established (struct net_buf * buf )
18061828{
18071829 struct bt_hci_evt_le_big_sync_established * evt = (void * )buf -> data ;
@@ -1989,4 +2011,5 @@ int bt_iso_big_sync(struct bt_le_per_adv_sync *sync, struct bt_iso_big_sync_para
19892011
19902012 return 0 ;
19912013}
1992- #endif /* defined(CONFIG_BT_ISO_BROADCAST) */
2014+ #endif /* CONFIG_BT_ISO_SYNC_RECEIVER */
2015+ #endif /* CONFIG_BT_ISO_BROADCAST */
0 commit comments