@@ -71,67 +71,11 @@ struct bt_iso_chan iso_chan = {
7171 .qos = & iso_qos ,
7272};
7373
74- static struct bt_iso_cig * cig ;
75-
76- NET_BUF_POOL_FIXED_DEFINE (tx_pool , 1 , BT_ISO_SDU_BUF_SIZE (CONFIG_BT_ISO_TX_MTU ), 8 ,
77- NULL );
78-
79- static int iso_accept (const struct bt_iso_accept_info * info ,
80- struct bt_iso_chan * * chan )
81- {
82- shell_print (ctx_shell , "Incoming request from %p with CIG ID 0x%02X and CIS ID 0x%02X" ,
83- info -> acl , info -> cig_id , info -> cis_id );
84-
85- if (iso_chan .iso ) {
86- shell_print (ctx_shell , "No channels available" );
87- return - ENOMEM ;
88- }
89-
90- * chan = & iso_chan ;
91-
92- return 0 ;
93- }
94-
95- struct bt_iso_server iso_server = {
96- .sec_level = BT_SECURITY_L1 ,
97- .accept = iso_accept ,
98- };
99-
100- static int cmd_listen (const struct shell * sh , size_t argc , char * argv [])
101- {
102- int err ;
103- static struct bt_iso_chan_io_qos * tx_qos , * rx_qos ;
104-
105- if (!strcmp ("tx" , argv [1 ])) {
106- tx_qos = & iso_tx_qos ;
107- rx_qos = NULL ;
108- } else if (!strcmp ("rx" , argv [1 ])) {
109- tx_qos = NULL ;
110- rx_qos = & iso_rx_qos ;
111- } else if (!strcmp ("txrx" , argv [1 ])) {
112- tx_qos = & iso_tx_qos ;
113- rx_qos = & iso_rx_qos ;
114- } else {
115- shell_error (sh , "Invalid argument - use tx, rx or txrx" );
116- return - ENOEXEC ;
117- }
74+ NET_BUF_POOL_FIXED_DEFINE (tx_pool , 1 , BT_ISO_SDU_BUF_SIZE (CONFIG_BT_ISO_TX_MTU ),
75+ 8 , NULL );
11876
119- if (argc > 2 ) {
120- iso_server .sec_level = * argv [2 ] - '0' ;
121- }
122-
123- err = bt_iso_server_register (& iso_server );
124- if (err ) {
125- shell_error (sh , "Unable to register ISO cap (err %d)" ,
126- err );
127- return err ;
128- }
129-
130- /* Setup peripheral iso data direction only if register is success */
131- iso_chan .qos -> tx = tx_qos ;
132- iso_chan .qos -> rx = rx_qos ;
133- return err ;
134- }
77+ #if defined(CONFIG_BT_ISO_CENTRAL )
78+ static struct bt_iso_cig * cig ;
13579
13680static int cmd_cig_create (const struct shell * sh , size_t argc , char * argv [])
13781{
@@ -272,7 +216,67 @@ static int cmd_connect(const struct shell *sh, size_t argc, char *argv[])
272216
273217 return 0 ;
274218}
219+ #endif /* CONFIG_BT_ISO_CENTRAL */
220+
221+ #if defined(CONFIG_BT_ISO_PERIPHERAL )
222+
223+ static int iso_accept (const struct bt_iso_accept_info * info ,
224+ struct bt_iso_chan * * chan )
225+ {
226+ shell_print (ctx_shell , "Incoming request from %p with CIG ID 0x%02X and CIS ID 0x%02X" ,
227+ info -> acl , info -> cig_id , info -> cis_id );
228+
229+ if (iso_chan .iso ) {
230+ shell_print (ctx_shell , "No channels available" );
231+ return - ENOMEM ;
232+ }
233+
234+ * chan = & iso_chan ;
235+
236+ return 0 ;
237+ }
238+
239+ struct bt_iso_server iso_server = {
240+ .sec_level = BT_SECURITY_L1 ,
241+ .accept = iso_accept ,
242+ };
243+
244+ static int cmd_listen (const struct shell * sh , size_t argc , char * argv [])
245+ {
246+ int err ;
247+ static struct bt_iso_chan_io_qos * tx_qos , * rx_qos ;
248+
249+ if (!strcmp ("tx" , argv [1 ])) {
250+ tx_qos = & iso_tx_qos ;
251+ rx_qos = NULL ;
252+ } else if (!strcmp ("rx" , argv [1 ])) {
253+ tx_qos = NULL ;
254+ rx_qos = & iso_rx_qos ;
255+ } else if (!strcmp ("txrx" , argv [1 ])) {
256+ tx_qos = & iso_tx_qos ;
257+ rx_qos = & iso_rx_qos ;
258+ } else {
259+ shell_error (sh , "Invalid argument - use tx, rx or txrx" );
260+ return - ENOEXEC ;
261+ }
275262
263+ if (argc > 2 ) {
264+ iso_server .sec_level = * argv [2 ] - '0' ;
265+ }
266+
267+ err = bt_iso_server_register (& iso_server );
268+ if (err ) {
269+ shell_error (sh , "Unable to register ISO cap (err %d)" ,
270+ err );
271+ return err ;
272+ }
273+
274+ /* Setup peripheral iso data direction only if register is success */
275+ iso_chan .qos -> tx = tx_qos ;
276+ iso_chan .qos -> rx = rx_qos ;
277+ return err ;
278+ }
279+ #endif /* CONFIG_BT_ISO_PERIPHERAL */
276280
277281static int cmd_send (const struct shell * sh , size_t argc , char * argv [])
278282{
@@ -529,11 +533,15 @@ static int cmd_big_term(const struct shell *sh, size_t argc, char *argv[])
529533
530534SHELL_STATIC_SUBCMD_SET_CREATE (iso_cmds ,
531535#if defined(CONFIG_BT_ISO_UNICAST )
536+ #if defined(CONFIG_BT_ISO_CENTRAL )
532537 SHELL_CMD_ARG (cig_create , NULL , "[dir=tx,rx,txrx] [interval] [packing] [framing] "
533538 "[latency] [sdu] [phy] [rtn]" , cmd_cig_create , 1 , 8 ),
534539 SHELL_CMD_ARG (cig_term , NULL , "Terminate the CIG" , cmd_cig_term , 1 , 0 ),
535540 SHELL_CMD_ARG (connect , NULL , "Connect ISO Channel" , cmd_connect , 1 , 0 ),
541+ #endif /* CONFIG_BT_ISO_CENTRAL */
542+ #if defined(CONFIG_BT_ISO_PERIPHERAL )
536543 SHELL_CMD_ARG (listen , NULL , "<dir=tx,rx,txrx> [security level]" , cmd_listen , 2 , 1 ),
544+ #endif /* CONFIG_BT_ISO_PERIPHERAL */
537545 SHELL_CMD_ARG (send , NULL , "Send to ISO Channel [count]" ,
538546 cmd_send , 1 , 1 ),
539547 SHELL_CMD_ARG (disconnect , NULL , "Disconnect ISO Channel" ,
0 commit comments