31
31
extern enum bst_result_t bst_result ;
32
32
static struct bt_iso_chan iso_chans [CONFIG_BT_ISO_MAX_CHAN ];
33
33
static struct bt_iso_chan * default_chan = & iso_chans [0 ];
34
+ static struct bt_iso_cig_param cig_param ;
34
35
static struct bt_iso_cig * cig ;
35
36
static uint16_t seq_num ;
36
37
static volatile size_t enqueue_cnt ;
37
- static uint32_t latency_ms = 10U ; /* 10ms */
38
+ static uint32_t latency_ms = 10U ; /* 10ms */
38
39
static uint32_t interval_us = 10U * USEC_PER_MSEC ; /* 10 ms */
39
40
NET_BUF_POOL_FIXED_DEFINE (tx_pool , ENQUEUE_COUNT , BT_ISO_SDU_BUF_SIZE (CONFIG_BT_ISO_TX_MTU ),
40
41
CONFIG_BT_CONN_TX_USER_DATA_SIZE , NULL );
@@ -122,13 +123,72 @@ static void iso_connected(struct bt_iso_chan *chan)
122
123
.pid = BT_ISO_DATA_PATH_HCI ,
123
124
.format = BT_HCI_CODING_FORMAT_TRANSPARENT ,
124
125
};
126
+ struct bt_iso_info info ;
125
127
int err ;
126
128
127
129
printk ("ISO Channel %p connected\n" , chan );
128
130
129
131
seq_num = 0U ;
130
132
enqueue_cnt = ENQUEUE_COUNT ;
131
133
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_CONNECTED );
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
+
132
192
if (chan == default_chan ) {
133
193
/* Start send timer */
134
194
k_work_schedule (& iso_send_work , K_MSEC (0 ));
@@ -207,68 +267,66 @@ static void init(void)
207
267
}
208
268
}
209
269
210
- static void set_cig_defaults (struct bt_iso_cig_param * param )
270
+ static void set_cig_defaults (void )
211
271
{
212
- param -> cis_channels = & default_chan ;
213
- param -> num_cis = 1U ;
214
- param -> sca = BT_GAP_SCA_UNKNOWN ;
215
- param -> packing = BT_ISO_PACKING_SEQUENTIAL ;
216
- param -> framing = BT_ISO_FRAMING_UNFRAMED ;
217
- param -> c_to_p_latency = latency_ms ; /* ms */
218
- param -> p_to_c_latency = latency_ms ; /* ms */
219
- param -> c_to_p_interval = interval_us ; /* us */
220
- param -> p_to_c_interval = interval_us ; /* us */
221
-
272
+ cig_param .cis_channels = & default_chan ;
273
+ cig_param .num_cis = 1U ;
274
+ cig_param .sca = BT_GAP_SCA_UNKNOWN ;
275
+ cig_param .packing = BT_ISO_PACKING_SEQUENTIAL ;
276
+ cig_param .framing = BT_ISO_FRAMING_UNFRAMED ;
277
+ cig_param .c_to_p_latency = latency_ms ; /* ms */
278
+ cig_param .p_to_c_latency = latency_ms ; /* ms */
279
+ cig_param .c_to_p_interval = interval_us ; /* us */
280
+ cig_param .p_to_c_interval = interval_us ; /* us */
222
281
}
223
282
224
283
static void create_cig (size_t iso_channels )
225
284
{
226
285
struct bt_iso_chan * channels [ARRAY_SIZE (iso_chans )];
227
- struct bt_iso_cig_param param ;
228
286
int err ;
229
287
230
288
for (size_t i = 0U ; i < iso_channels ; i ++ ) {
231
289
channels [i ] = & iso_chans [i ];
232
290
}
233
291
234
- set_cig_defaults (& param );
235
- param .num_cis = iso_channels ;
236
- param .cis_channels = channels ;
292
+ set_cig_defaults ();
293
+ cig_param .num_cis = iso_channels ;
294
+ cig_param .cis_channels = channels ;
237
295
238
- err = bt_iso_cig_create (& param , & cig );
296
+ err = bt_iso_cig_create (& cig_param , & cig );
239
297
if (err != 0 ) {
240
298
TEST_FAIL ("Failed to create CIG (%d)" , err );
241
299
242
300
return ;
243
301
}
244
302
}
245
303
246
- static int reconfigure_cig_interval (struct bt_iso_cig_param * param )
304
+ static int reconfigure_cig_interval (void )
247
305
{
248
306
int err ;
249
307
250
308
/* Test modifying CIG parameter without any CIS */
251
- param -> num_cis = 0U ;
252
- param -> c_to_p_interval = 7500 ; /* us */
253
- param -> p_to_c_interval = param -> c_to_p_interval ;
254
- err = bt_iso_cig_reconfigure (cig , param );
309
+ cig_param . num_cis = 0U ;
310
+ cig_param . c_to_p_interval = 7500 ; /* us */
311
+ cig_param . p_to_c_interval = cig_param . c_to_p_interval ;
312
+ err = bt_iso_cig_reconfigure (cig , & cig_param );
255
313
if (err != 0 ) {
256
314
TEST_FAIL ("Failed to reconfigure CIG to new interval (%d)" , err );
257
315
258
316
return err ;
259
317
}
260
318
261
- err = bt_iso_cig_reconfigure (cig , param );
319
+ err = bt_iso_cig_reconfigure (cig , & cig_param );
262
320
if (err != 0 ) {
263
321
TEST_FAIL ("Failed to reconfigure CIG to same interval (%d)" , err );
264
322
265
323
return err ;
266
324
}
267
325
268
326
/* Test modifying to different values for both intervals */
269
- param -> c_to_p_interval = 5000 ; /* us */
270
- param -> p_to_c_interval = 2500 ; /* us */
271
- err = bt_iso_cig_reconfigure (cig , param );
327
+ cig_param . c_to_p_interval = 5000 ; /* us */
328
+ cig_param . p_to_c_interval = 2500 ; /* us */
329
+ err = bt_iso_cig_reconfigure (cig , & cig_param );
272
330
if (err != 0 ) {
273
331
TEST_FAIL ("Failed to reconfigure CIG to new interval (%d)" , err );
274
332
@@ -278,24 +336,24 @@ static int reconfigure_cig_interval(struct bt_iso_cig_param *param)
278
336
return 0 ;
279
337
}
280
338
281
- static int reconfigure_cig_latency (struct bt_iso_cig_param * param )
339
+ static int reconfigure_cig_latency (void )
282
340
{
283
341
int err ;
284
342
285
343
/* Test modifying CIG latency without any CIS */
286
- param -> num_cis = 0U ;
287
- param -> c_to_p_latency = 20 ; /* ms */
288
- param -> p_to_c_latency = param -> c_to_p_latency ;
289
- err = bt_iso_cig_reconfigure (cig , param );
344
+ cig_param . num_cis = 0U ;
345
+ cig_param . c_to_p_latency = 20 ; /* ms */
346
+ cig_param . p_to_c_latency = cig_param . c_to_p_latency ;
347
+ err = bt_iso_cig_reconfigure (cig , & cig_param );
290
348
if (err != 0 ) {
291
349
TEST_FAIL ("Failed to reconfigure CIG latency (%d)" , err );
292
350
293
351
return err ;
294
352
}
295
353
296
- param -> c_to_p_latency = 30 ; /* ms */
297
- param -> p_to_c_latency = 40 ; /* ms */
298
- err = bt_iso_cig_reconfigure (cig , param );
354
+ cig_param . c_to_p_latency = 30 ; /* ms */
355
+ cig_param . p_to_c_latency = 40 ; /* ms */
356
+ err = bt_iso_cig_reconfigure (cig , & cig_param );
299
357
if (err != 0 ) {
300
358
TEST_FAIL ("Failed to reconfigure CIG for different latencies (%d)" , err );
301
359
@@ -308,42 +366,41 @@ static int reconfigure_cig_latency(struct bt_iso_cig_param *param)
308
366
static void reconfigure_cig (void )
309
367
{
310
368
struct bt_iso_chan * channels [2 ];
311
- struct bt_iso_cig_param param ;
312
369
int err ;
313
370
314
371
for (size_t i = 0U ; i < ARRAY_SIZE (channels ); i ++ ) {
315
372
channels [i ] = & iso_chans [i ];
316
373
}
317
374
318
- set_cig_defaults (& param );
375
+ set_cig_defaults ();
319
376
320
377
/* Test modifying existing CIS */
321
378
default_chan -> qos -> tx -> rtn ++ ;
322
379
323
- err = bt_iso_cig_reconfigure (cig , & param );
380
+ err = bt_iso_cig_reconfigure (cig , & cig_param );
324
381
if (err != 0 ) {
325
382
TEST_FAIL ("Failed to reconfigure CIS to new RTN (%d)" , err );
326
383
327
384
return ;
328
385
}
329
386
330
387
/* Test modifying interval parameter */
331
- err = reconfigure_cig_interval (& param );
388
+ err = reconfigure_cig_interval ();
332
389
if (err != 0 ) {
333
390
return ;
334
391
}
335
392
336
393
/* Test modifying latency parameter */
337
- err = reconfigure_cig_latency (& param );
394
+ err = reconfigure_cig_latency ();
338
395
if (err != 0 ) {
339
396
return ;
340
397
}
341
398
342
399
/* Add CIS to the CIG and restore all other parameters */
343
- set_cig_defaults (& param );
344
- param .cis_channels = & channels [1 ];
400
+ set_cig_defaults ();
401
+ cig_param .cis_channels = & channels [1 ];
345
402
346
- err = bt_iso_cig_reconfigure (cig , & param );
403
+ err = bt_iso_cig_reconfigure (cig , & cig_param );
347
404
if (err != 0 ) {
348
405
TEST_FAIL ("Failed to reconfigure CIG with new CIS and original parameters (%d)" ,
349
406
err );
0 commit comments