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 )
28- NET_BUF_POOL_FIXED_DEFINE (iso_tx_pool , CONFIG_BT_ISO_TX_BUF_COUNT ,
29- BT_ISO_SDU_BUF_SIZE (CONFIG_BT_ISO_TX_MTU ), NULL );
30- #endif /* CONFIG_BT_ISO_UNICAST || CONFIG_BT_ISO_BROADCAST */
27+ #define iso_chan (_iso ) ((_iso)->iso.chan);
3128
3229#if defined(CONFIG_BT_ISO_UNICAST ) || defined(CONFIG_BT_ISO_SYNC_RECEIVER )
3330NET_BUF_POOL_FIXED_DEFINE (iso_rx_pool , CONFIG_BT_ISO_RX_BUF_COUNT ,
@@ -36,9 +33,11 @@ NET_BUF_POOL_FIXED_DEFINE(iso_rx_pool, CONFIG_BT_ISO_RX_BUF_COUNT,
3633static struct bt_iso_recv_info iso_info_data [CONFIG_BT_ISO_RX_BUF_COUNT ];
3734#define iso_info (buf ) (&iso_info_data[net_buf_id(buf)])
3835#endif /* CONFIG_BT_ISO_UNICAST || CONFIG_BT_ISO_SYNC_RECEIVER */
39- #define iso_chan (_iso ) ((_iso)->iso.chan);
4036
4137#if defined(CONFIG_BT_ISO_UNICAST ) || defined(CONFIG_BT_ISO_BROADCAST )
38+ NET_BUF_POOL_FIXED_DEFINE (iso_tx_pool , CONFIG_BT_ISO_TX_BUF_COUNT ,
39+ BT_ISO_SDU_BUF_SIZE (CONFIG_BT_ISO_TX_MTU ), NULL );
40+
4241#if CONFIG_BT_ISO_TX_FRAG_COUNT > 0
4342NET_BUF_POOL_FIXED_DEFINE (iso_frag_pool , CONFIG_BT_ISO_TX_FRAG_COUNT ,
4443 BT_ISO_SDU_BUF_SIZE (CONFIG_BT_ISO_TX_MTU ), NULL );
@@ -61,20 +60,6 @@ static struct bt_iso_big *lookup_big_by_handle(uint8_t big_handle);
6160/* Prototype */
6261int hci_le_remove_cig (uint8_t cig_id );
6362
64- #if defined(CONFIG_BT_ISO_UNICAST ) || defined(CONFIG_BT_ISO_SYNC_RECEIVER )
65- struct net_buf * bt_iso_get_rx (k_timeout_t timeout )
66- {
67- struct net_buf * buf = net_buf_alloc (& iso_rx_pool , timeout );
68-
69- if (buf ) {
70- net_buf_reserve (buf , BT_BUF_RESERVE );
71- bt_buf_set_type (buf , BT_BUF_ISO_IN );
72- }
73-
74- return buf ;
75- }
76- #endif /* CONFIG_BT_ISO_UNICAST || CONFIG_BT_ISO_SYNC_RECEIVER */
77-
7863#if defined(CONFIG_BT_ISO_UNICAST ) || defined(CONFIG_BT_ISO_BROADCASTER )
7964static void bt_iso_send_cb (struct bt_conn * iso , void * user_data )
8065{
@@ -542,6 +527,18 @@ void bt_iso_chan_set_state(struct bt_iso_chan *chan, uint8_t state)
542527#endif /* CONFIG_BT_DEBUG_ISO */
543528
544529#if defined(CONFIG_BT_ISO_UNICAST ) || defined(CONFIG_BT_ISO_SYNC_RECEIVER )
530+ struct net_buf * bt_iso_get_rx (k_timeout_t timeout )
531+ {
532+ struct net_buf * buf = net_buf_alloc (& iso_rx_pool , timeout );
533+
534+ if (buf ) {
535+ net_buf_reserve (buf , BT_BUF_RESERVE );
536+ bt_buf_set_type (buf , BT_BUF_ISO_IN );
537+ }
538+
539+ return buf ;
540+ }
541+
545542void bt_iso_recv (struct bt_conn * iso , struct net_buf * buf , uint8_t flags )
546543{
547544 struct bt_hci_iso_data_hdr * hdr ;
@@ -1665,6 +1662,64 @@ int bt_iso_big_create(struct bt_le_ext_adv *padv, struct bt_iso_big_create_param
16651662
16661663 return err ;
16671664}
1665+
1666+ void hci_le_big_complete (struct net_buf * buf )
1667+ {
1668+ struct bt_hci_evt_le_big_complete * evt = (void * )buf -> data ;
1669+ struct bt_iso_big * big ;
1670+
1671+ if (evt -> big_handle >= ARRAY_SIZE (bigs )) {
1672+ BT_WARN ("Invalid BIG handle" );
1673+
1674+ big = big_lookup_flag (BT_BIG_PENDING );
1675+ if (big ) {
1676+ big_disconnect (big , evt -> status ? evt -> status : BT_HCI_ERR_UNSPECIFIED );
1677+ cleanup_big (big );
1678+ }
1679+
1680+ return ;
1681+ }
1682+
1683+ big = lookup_big_by_handle (evt -> big_handle );
1684+ atomic_clear_bit (big -> flags , BT_BIG_PENDING );
1685+
1686+ BT_DBG ("BIG[%u] %p completed, status %u" , big -> handle , big , evt -> status );
1687+
1688+ if (evt -> status || evt -> num_bis != big -> num_bis ) {
1689+ if (evt -> status == BT_HCI_ERR_SUCCESS && evt -> num_bis != big -> num_bis ) {
1690+ BT_ERR ("Invalid number of BIS created, was %u expected %u" ,
1691+ evt -> num_bis , big -> num_bis );
1692+ }
1693+ big_disconnect (big , evt -> status ? evt -> status : BT_HCI_ERR_UNSPECIFIED );
1694+ cleanup_big (big );
1695+ return ;
1696+ }
1697+
1698+ for (int i = 0 ; i < big -> num_bis ; i ++ ) {
1699+ struct bt_iso_chan * bis = big -> bis [i ];
1700+
1701+ bis -> iso -> handle = sys_le16_to_cpu (evt -> handle [i ]);
1702+ bt_conn_set_state (bis -> iso , BT_CONN_CONNECTED );
1703+ }
1704+ }
1705+
1706+ void hci_le_big_terminate (struct net_buf * buf )
1707+ {
1708+ struct bt_hci_evt_le_big_terminate * evt = (void * )buf -> data ;
1709+ struct bt_iso_big * big ;
1710+
1711+ if (evt -> big_handle >= ARRAY_SIZE (bigs )) {
1712+ BT_WARN ("Invalid BIG handle" );
1713+ return ;
1714+ }
1715+
1716+ big = lookup_big_by_handle (evt -> big_handle );
1717+
1718+ BT_DBG ("BIG[%u] %p terminated" , big -> handle , big );
1719+
1720+ big_disconnect (big , evt -> reason );
1721+ cleanup_big (big );
1722+ }
16681723#endif /* CONFIG_BT_ISO_BROADCASTER */
16691724
16701725static int hci_le_terminate_big (struct bt_iso_big * big )
@@ -1763,66 +1818,6 @@ int bt_iso_big_terminate(struct bt_iso_big *big)
17631818 return err ;
17641819}
17651820
1766- #if defined(CONFIG_BT_ISO_BROADCASTER )
1767- void hci_le_big_complete (struct net_buf * buf )
1768- {
1769- struct bt_hci_evt_le_big_complete * evt = (void * )buf -> data ;
1770- struct bt_iso_big * big ;
1771-
1772- if (evt -> big_handle >= ARRAY_SIZE (bigs )) {
1773- BT_WARN ("Invalid BIG handle" );
1774-
1775- big = big_lookup_flag (BT_BIG_PENDING );
1776- if (big ) {
1777- big_disconnect (big , evt -> status ? evt -> status : BT_HCI_ERR_UNSPECIFIED );
1778- cleanup_big (big );
1779- }
1780-
1781- return ;
1782- }
1783-
1784- big = lookup_big_by_handle (evt -> big_handle );
1785- atomic_clear_bit (big -> flags , BT_BIG_PENDING );
1786-
1787- BT_DBG ("BIG[%u] %p completed, status %u" , big -> handle , big , evt -> status );
1788-
1789- if (evt -> status || evt -> num_bis != big -> num_bis ) {
1790- if (evt -> status == BT_HCI_ERR_SUCCESS && evt -> num_bis != big -> num_bis ) {
1791- BT_ERR ("Invalid number of BIS created, was %u expected %u" ,
1792- evt -> num_bis , big -> num_bis );
1793- }
1794- big_disconnect (big , evt -> status ? evt -> status : BT_HCI_ERR_UNSPECIFIED );
1795- cleanup_big (big );
1796- return ;
1797- }
1798-
1799- for (int i = 0 ; i < big -> num_bis ; i ++ ) {
1800- struct bt_iso_chan * bis = big -> bis [i ];
1801-
1802- bis -> iso -> handle = sys_le16_to_cpu (evt -> handle [i ]);
1803- bt_conn_set_state (bis -> iso , BT_CONN_CONNECTED );
1804- }
1805- }
1806-
1807- void hci_le_big_terminate (struct net_buf * buf )
1808- {
1809- struct bt_hci_evt_le_big_terminate * evt = (void * )buf -> data ;
1810- struct bt_iso_big * big ;
1811-
1812- if (evt -> big_handle >= ARRAY_SIZE (bigs )) {
1813- BT_WARN ("Invalid BIG handle" );
1814- return ;
1815- }
1816-
1817- big = lookup_big_by_handle (evt -> big_handle );
1818-
1819- BT_DBG ("BIG[%u] %p terminated" , big -> handle , big );
1820-
1821- big_disconnect (big , evt -> reason );
1822- cleanup_big (big );
1823- }
1824- #endif /* CONFIG_BT_ISO_BROADCASTER */
1825-
18261821#if defined(CONFIG_BT_ISO_SYNC_RECEIVER )
18271822void hci_le_big_sync_established (struct net_buf * buf )
18281823{
0 commit comments