3131extern enum bst_result_t bst_result ;
3232static struct bt_iso_chan iso_chans [CONFIG_BT_ISO_MAX_CHAN ];
3333static struct bt_iso_chan * default_chan = & iso_chans [0 ];
34+ static struct bt_iso_cig_param cig_param ;
3435static struct bt_iso_cig * cig ;
3536static uint16_t seq_num ;
3637static volatile size_t enqueue_cnt ;
37- static uint32_t latency_ms = 10U ; /* 10ms */
38+ static uint32_t latency_ms = 10U ; /* 10ms */
3839static uint32_t interval_us = 10U * USEC_PER_MSEC ; /* 10 ms */
3940NET_BUF_POOL_FIXED_DEFINE (tx_pool , ENQUEUE_COUNT , BT_ISO_SDU_BUF_SIZE (CONFIG_BT_ISO_TX_MTU ),
4041 CONFIG_BT_CONN_TX_USER_DATA_SIZE , NULL );
@@ -122,13 +123,72 @@ static void iso_connected(struct bt_iso_chan *chan)
122123 .pid = BT_ISO_DATA_PATH_HCI ,
123124 .format = BT_HCI_CODING_FORMAT_TRANSPARENT ,
124125 };
126+ struct bt_iso_info info ;
125127 int err ;
126128
127129 printk ("ISO Channel %p connected\n" , chan );
128130
129131 seq_num = 0U ;
130132 enqueue_cnt = ENQUEUE_COUNT ;
131133
134+ err = bt_iso_chan_get_info (chan , & info );
135+ TEST_ASSERT (err == 0 , "Failed to get CIS info: %d" , err );
136+
137+ TEST_ASSERT (info .type == BT_ISO_CHAN_TYPE_CENTRAL );
138+ TEST_ASSERT (info .can_send || info .can_recv );
139+ TEST_ASSERT (IN_RANGE (info .iso_interval , BT_ISO_ISO_INTERVAL_MIN , BT_ISO_ISO_INTERVAL_MAX ),
140+ "Invalid ISO interval 0x%04x" , info .iso_interval );
141+ TEST_ASSERT (IN_RANGE (info .max_subevent , BT_ISO_NSE_MIN , BT_ISO_NSE_MAX ),
142+ "Invalid subevent number 0x%02x" , info .max_subevent );
143+ TEST_ASSERT (IN_RANGE (info .unicast .cig_sync_delay , BT_HCI_LE_CIG_SYNC_DELAY_MIN ,
144+ BT_HCI_LE_CIG_SYNC_DELAY_MAX ),
145+ "Invalid CIG sync delay 0x%06x" , info .unicast .cig_sync_delay );
146+ TEST_ASSERT (IN_RANGE (info .unicast .cis_sync_delay , BT_HCI_LE_CIS_SYNC_DELAY_MIN ,
147+ BT_HCI_LE_CIS_SYNC_DELAY_MAX ),
148+ "Invalid CIS sync delay 0x%06x" , info .unicast .cis_sync_delay );
149+
150+ if (info .can_send ) {
151+ const struct bt_iso_unicast_tx_info * central = & info .unicast .central ;
152+
153+ TEST_ASSERT ((info .iso_interval % cig_param .c_to_p_interval ) == 0U ,
154+ "ISO interval %u shall be a multiple of the SDU interval %u" ,
155+ info .iso_interval , cig_param .c_to_p_interval );
156+ TEST_ASSERT (IN_RANGE (central -> latency , BT_HCI_LE_TRANSPORT_LATENCY_C_TO_P_MIN ,
157+ BT_HCI_LE_TRANSPORT_LATENCY_C_TO_P_MAX ),
158+ "Invalid transport latency 0x%06x" , central -> latency );
159+ TEST_ASSERT ((central -> flush_timeout % info .iso_interval ) == 0U ,
160+ "Flush timeout in ms %u shall be a multiple of the ISO interval %u" ,
161+ central -> flush_timeout , info .iso_interval );
162+ TEST_ASSERT (IN_RANGE (central -> max_pdu , BT_ISO_CONNECTED_PDU_MIN , BT_ISO_PDU_MAX ),
163+ "Invalid max PDU 0x%04x" , central -> max_pdu );
164+ TEST_ASSERT (central -> phy == BT_GAP_LE_PHY_1M || central -> phy == BT_GAP_LE_PHY_2M ||
165+ central -> phy == BT_GAP_LE_PHY_CODED ,
166+ "Invalid PHY 0x%02x" , central -> phy );
167+ TEST_ASSERT (IN_RANGE (central -> bn , BT_ISO_BN_MIN , BT_ISO_BN_MAX ),
168+ "Invalid BN 0x%02x" , central -> bn );
169+ }
170+ if (info .can_recv ) {
171+ const struct bt_iso_unicast_tx_info * peripheral = & info .unicast .peripheral ;
172+
173+ TEST_ASSERT ((info .iso_interval % cig_param .p_to_c_interval ) == 0U ,
174+ "ISO interval %u shall be a multiple of the SDU interval %u" ,
175+ info .iso_interval , cig_param .p_to_c_interval );
176+ TEST_ASSERT (IN_RANGE (peripheral -> latency , BT_HCI_LE_TRANSPORT_LATENCY_P_TO_C_MIN ,
177+ BT_HCI_LE_TRANSPORT_LATENCY_P_TO_C_MAX ),
178+ "Invalid transport latency 0x%06x" , peripheral -> latency );
179+ TEST_ASSERT ((peripheral -> flush_timeout % info .iso_interval ) == 0U ,
180+ "Flush timeout in ms %u shall be a multiple of the ISO interval %u" ,
181+ peripheral -> flush_timeout , info .iso_interval );
182+ TEST_ASSERT (IN_RANGE (peripheral -> max_pdu , BT_ISO_CONNECTED_PDU_MIN , BT_ISO_PDU_MAX ),
183+ "Invalid max PDU 0x%04x" , peripheral -> max_pdu );
184+ TEST_ASSERT (peripheral -> phy == BT_GAP_LE_PHY_1M ||
185+ peripheral -> phy == BT_GAP_LE_PHY_2M ||
186+ peripheral -> phy == BT_GAP_LE_PHY_CODED ,
187+ "Invalid PHY 0x%02x" , peripheral -> phy );
188+ TEST_ASSERT (IN_RANGE (peripheral -> bn , BT_ISO_BN_MIN , BT_ISO_BN_MAX ),
189+ "Invalid BN 0x%02x" , peripheral -> bn );
190+ }
191+
132192 if (chan == default_chan ) {
133193 /* Start send timer */
134194 k_work_schedule (& iso_send_work , K_MSEC (0 ));
@@ -212,68 +272,66 @@ static void init(void)
212272 }
213273}
214274
215- static void set_cig_defaults (struct bt_iso_cig_param * param )
275+ static void set_cig_defaults (void )
216276{
217- param -> cis_channels = & default_chan ;
218- param -> num_cis = 1U ;
219- param -> sca = BT_GAP_SCA_UNKNOWN ;
220- param -> packing = BT_ISO_PACKING_SEQUENTIAL ;
221- param -> framing = BT_ISO_FRAMING_UNFRAMED ;
222- param -> c_to_p_latency = latency_ms ; /* ms */
223- param -> p_to_c_latency = latency_ms ; /* ms */
224- param -> c_to_p_interval = interval_us ; /* us */
225- param -> p_to_c_interval = interval_us ; /* us */
226-
277+ cig_param .cis_channels = & default_chan ;
278+ cig_param .num_cis = 1U ;
279+ cig_param .sca = BT_GAP_SCA_UNKNOWN ;
280+ cig_param .packing = BT_ISO_PACKING_SEQUENTIAL ;
281+ cig_param .framing = BT_ISO_FRAMING_UNFRAMED ;
282+ cig_param .c_to_p_latency = latency_ms ; /* ms */
283+ cig_param .p_to_c_latency = latency_ms ; /* ms */
284+ cig_param .c_to_p_interval = interval_us ; /* us */
285+ cig_param .p_to_c_interval = interval_us ; /* us */
227286}
228287
229288static void create_cig (size_t iso_channels )
230289{
231290 struct bt_iso_chan * channels [ARRAY_SIZE (iso_chans )];
232- struct bt_iso_cig_param param ;
233291 int err ;
234292
235293 for (size_t i = 0U ; i < iso_channels ; i ++ ) {
236294 channels [i ] = & iso_chans [i ];
237295 }
238296
239- set_cig_defaults (& param );
240- param .num_cis = iso_channels ;
241- param .cis_channels = channels ;
297+ set_cig_defaults ();
298+ cig_param .num_cis = iso_channels ;
299+ cig_param .cis_channels = channels ;
242300
243- err = bt_iso_cig_create (& param , & cig );
301+ err = bt_iso_cig_create (& cig_param , & cig );
244302 if (err != 0 ) {
245303 TEST_FAIL ("Failed to create CIG (%d)" , err );
246304
247305 return ;
248306 }
249307}
250308
251- static int reconfigure_cig_interval (struct bt_iso_cig_param * param )
309+ static int reconfigure_cig_interval (void )
252310{
253311 int err ;
254312
255313 /* Test modifying CIG parameter without any CIS */
256- param -> num_cis = 0U ;
257- param -> c_to_p_interval = 7500 ; /* us */
258- param -> p_to_c_interval = param -> c_to_p_interval ;
259- err = bt_iso_cig_reconfigure (cig , param );
314+ cig_param . num_cis = 0U ;
315+ cig_param . c_to_p_interval = 7500 ; /* us */
316+ cig_param . p_to_c_interval = cig_param . c_to_p_interval ;
317+ err = bt_iso_cig_reconfigure (cig , & cig_param );
260318 if (err != 0 ) {
261319 TEST_FAIL ("Failed to reconfigure CIG to new interval (%d)" , err );
262320
263321 return err ;
264322 }
265323
266- err = bt_iso_cig_reconfigure (cig , param );
324+ err = bt_iso_cig_reconfigure (cig , & cig_param );
267325 if (err != 0 ) {
268326 TEST_FAIL ("Failed to reconfigure CIG to same interval (%d)" , err );
269327
270328 return err ;
271329 }
272330
273331 /* Test modifying to different values for both intervals */
274- param -> c_to_p_interval = 5000 ; /* us */
275- param -> p_to_c_interval = 2500 ; /* us */
276- err = bt_iso_cig_reconfigure (cig , param );
332+ cig_param . c_to_p_interval = 5000 ; /* us */
333+ cig_param . p_to_c_interval = 2500 ; /* us */
334+ err = bt_iso_cig_reconfigure (cig , & cig_param );
277335 if (err != 0 ) {
278336 TEST_FAIL ("Failed to reconfigure CIG to new interval (%d)" , err );
279337
@@ -283,24 +341,24 @@ static int reconfigure_cig_interval(struct bt_iso_cig_param *param)
283341 return 0 ;
284342}
285343
286- static int reconfigure_cig_latency (struct bt_iso_cig_param * param )
344+ static int reconfigure_cig_latency (void )
287345{
288346 int err ;
289347
290348 /* Test modifying CIG latency without any CIS */
291- param -> num_cis = 0U ;
292- param -> c_to_p_latency = 20 ; /* ms */
293- param -> p_to_c_latency = param -> c_to_p_latency ;
294- err = bt_iso_cig_reconfigure (cig , param );
349+ cig_param . num_cis = 0U ;
350+ cig_param . c_to_p_latency = 20 ; /* ms */
351+ cig_param . p_to_c_latency = cig_param . c_to_p_latency ;
352+ err = bt_iso_cig_reconfigure (cig , & cig_param );
295353 if (err != 0 ) {
296354 TEST_FAIL ("Failed to reconfigure CIG latency (%d)" , err );
297355
298356 return err ;
299357 }
300358
301- param -> c_to_p_latency = 30 ; /* ms */
302- param -> p_to_c_latency = 40 ; /* ms */
303- err = bt_iso_cig_reconfigure (cig , param );
359+ cig_param . c_to_p_latency = 30 ; /* ms */
360+ cig_param . p_to_c_latency = 40 ; /* ms */
361+ err = bt_iso_cig_reconfigure (cig , & cig_param );
304362 if (err != 0 ) {
305363 TEST_FAIL ("Failed to reconfigure CIG for different latencies (%d)" , err );
306364
@@ -313,42 +371,41 @@ static int reconfigure_cig_latency(struct bt_iso_cig_param *param)
313371static void reconfigure_cig (void )
314372{
315373 struct bt_iso_chan * channels [2 ];
316- struct bt_iso_cig_param param ;
317374 int err ;
318375
319376 for (size_t i = 0U ; i < ARRAY_SIZE (channels ); i ++ ) {
320377 channels [i ] = & iso_chans [i ];
321378 }
322379
323- set_cig_defaults (& param );
380+ set_cig_defaults ();
324381
325382 /* Test modifying existing CIS */
326383 default_chan -> qos -> tx -> rtn ++ ;
327384
328- err = bt_iso_cig_reconfigure (cig , & param );
385+ err = bt_iso_cig_reconfigure (cig , & cig_param );
329386 if (err != 0 ) {
330387 TEST_FAIL ("Failed to reconfigure CIS to new RTN (%d)" , err );
331388
332389 return ;
333390 }
334391
335392 /* Test modifying interval parameter */
336- err = reconfigure_cig_interval (& param );
393+ err = reconfigure_cig_interval ();
337394 if (err != 0 ) {
338395 return ;
339396 }
340397
341398 /* Test modifying latency parameter */
342- err = reconfigure_cig_latency (& param );
399+ err = reconfigure_cig_latency ();
343400 if (err != 0 ) {
344401 return ;
345402 }
346403
347404 /* Add CIS to the CIG and restore all other parameters */
348- set_cig_defaults (& param );
349- param .cis_channels = & channels [1 ];
405+ set_cig_defaults ();
406+ cig_param .cis_channels = & channels [1 ];
350407
351- err = bt_iso_cig_reconfigure (cig , & param );
408+ err = bt_iso_cig_reconfigure (cig , & cig_param );
352409 if (err != 0 ) {
353410 TEST_FAIL ("Failed to reconfigure CIG with new CIS and original parameters (%d)" ,
354411 err );
0 commit comments