Skip to content

Commit 9b3a3ee

Browse files
cvinayakcarlescufi
authored andcommitted
Bluetooth: Controller: Add additional LE Channel Selection tests
Add additional custom LE Channel Selection #2 tests to cover event and subevent mapping. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent c3e6edd commit 9b3a3ee

File tree

1 file changed

+84
-2
lines changed

1 file changed

+84
-2
lines changed

subsys/bluetooth/controller/ll_sw/lll_chan.c

Lines changed: 84 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,8 @@ void lll_chan_sel_2_ut(void)
340340
uint8_t const chan_map_1_37_used = 37U;
341341
uint8_t chan_map_2[] = {0x00, 0x06, 0xE0, 0x00, 0x1E};
342342
uint8_t const chan_map_2_9_used = 9U;
343+
uint8_t chan_map_3[] = {0x06, 0x00, 0x00, 0x00, 0x00};
344+
uint8_t const chan_map_3_2_used = 2U;
343345
uint16_t const chan_id = 0x305F;
344346
uint8_t m;
345347

@@ -357,7 +359,7 @@ void lll_chan_sel_2_ut(void)
357359
m = lll_chan_sel_2(3, chan_id, chan_map_1, chan_map_1_37_used);
358360
LL_ASSERT(m == 21U);
359361

360-
/* Section 3.1 Sample Data 2 (9 used channels) */
362+
/* Section 3.2 Sample Data 2 (9 used channels) */
361363
m = lll_chan_sel_2(6, chan_id, chan_map_2, chan_map_2_9_used);
362364
LL_ASSERT(m == 23U);
363365

@@ -367,6 +369,18 @@ void lll_chan_sel_2_ut(void)
367369
m = lll_chan_sel_2(8, chan_id, chan_map_2, chan_map_2_9_used);
368370
LL_ASSERT(m == 34U);
369371

372+
/* FIXME: Use Sample Data from Spec, if one is added.
373+
* Below is a random sample to cover implementation in this file.
374+
*/
375+
/* Section x.x Sample Data 3 (2 used channels) */
376+
m = lll_chan_sel_2(11U, chan_id, chan_map_3, chan_map_3_2_used);
377+
LL_ASSERT(m == 1U);
378+
379+
m = lll_chan_sel_2(12U, chan_id, chan_map_3, chan_map_3_2_used);
380+
LL_ASSERT(m == 2U);
381+
382+
m = lll_chan_sel_2(13U, chan_id, chan_map_3, chan_map_3_2_used);
383+
LL_ASSERT(m == 1U);
370384

371385
#if defined(CONFIG_BT_CTLR_ISO)
372386
uint16_t prn_subevent_lu;
@@ -473,7 +487,7 @@ void lll_chan_sel_2_ut(void)
473487
LL_ASSERT(remap_idx == 8U);
474488
LL_ASSERT(m == 8U);
475489

476-
/* Section 3.1 Sample Data 2 (9 used channels) */
490+
/* Section 3.2 Sample Data 2 (9 used channels) */
477491
/* BIS subevent 1, event counter 6 */
478492
m = lll_chan_iso_event(6, chan_id, chan_map_2, chan_map_2_9_used, &prn_s, &remap_idx);
479493
LL_ASSERT((prn_s ^ chan_id) == 10975);
@@ -536,6 +550,74 @@ void lll_chan_sel_2_ut(void)
536550
m = lll_chan_iso_subevent(chan_id, chan_map_2, chan_map_2_9_used, &prn_s, &remap_idx);
537551
LL_ASSERT(remap_idx == 1U);
538552
LL_ASSERT(m == 10U);
553+
554+
/* FIXME: Use Sample Data from Spec, if one is added.
555+
* Below is a random sample to cover implementation in this file.
556+
*/
557+
/* Section x.x Sample Data 3 (2 used channels) */
558+
/* BIS subevent 1, event counter 11 */
559+
m = lll_chan_iso_event(11U, chan_id, chan_map_3, chan_map_3_2_used, &prn_s, &remap_idx);
560+
LL_ASSERT((prn_s ^ chan_id) == 8628U);
561+
LL_ASSERT(remap_idx == 0U);
562+
LL_ASSERT(m == 1U);
563+
564+
/* BIS subvent 2 */
565+
m = lll_chan_iso_subevent(chan_id, chan_map_3, chan_map_3_2_used, &prn_s, &remap_idx);
566+
LL_ASSERT(remap_idx == 1U);
567+
LL_ASSERT(m == 2U);
568+
569+
/* BIS subvent 3 */
570+
m = lll_chan_iso_subevent(chan_id, chan_map_3, chan_map_3_2_used, &prn_s, &remap_idx);
571+
LL_ASSERT(remap_idx == 0U);
572+
LL_ASSERT(m == 1U);
573+
574+
/* BIS subvent 4 */
575+
m = lll_chan_iso_subevent(chan_id, chan_map_3, chan_map_3_2_used, &prn_s, &remap_idx);
576+
LL_ASSERT(remap_idx == 1U);
577+
LL_ASSERT(m == 2U);
578+
579+
/* BIS subevent 1, event counter 12 */
580+
m = lll_chan_iso_event(12U, chan_id, chan_map_3, chan_map_3_2_used, &prn_s, &remap_idx);
581+
LL_ASSERT((prn_s ^ chan_id) == 34748U);
582+
LL_ASSERT(remap_idx == 1U);
583+
LL_ASSERT(m == 2U);
584+
585+
/* BIS subvent 2 */
586+
m = lll_chan_iso_subevent(chan_id, chan_map_3, chan_map_3_2_used, &prn_s, &remap_idx);
587+
LL_ASSERT(remap_idx == 0U);
588+
LL_ASSERT(m == 1U);
589+
590+
/* BIS subvent 3 */
591+
m = lll_chan_iso_subevent(chan_id, chan_map_3, chan_map_3_2_used, &prn_s, &remap_idx);
592+
LL_ASSERT(remap_idx == 1U);
593+
LL_ASSERT(m == 2U);
594+
595+
/* BIS subvent 4 */
596+
m = lll_chan_iso_subevent(chan_id, chan_map_3, chan_map_3_2_used, &prn_s, &remap_idx);
597+
LL_ASSERT(remap_idx == 0U);
598+
LL_ASSERT(m == 1U);
599+
600+
/* BIS subevent 1, event counter 13 */
601+
m = lll_chan_iso_event(13U, chan_id, chan_map_3, chan_map_3_2_used, &prn_s, &remap_idx);
602+
LL_ASSERT((prn_s ^ chan_id) == 22072U);
603+
LL_ASSERT(remap_idx == 0U);
604+
LL_ASSERT(m == 1U);
605+
606+
/* BIS subvent 2 */
607+
m = lll_chan_iso_subevent(chan_id, chan_map_3, chan_map_3_2_used, &prn_s, &remap_idx);
608+
LL_ASSERT(remap_idx == 1U);
609+
LL_ASSERT(m == 2U);
610+
611+
/* BIS subvent 3 */
612+
m = lll_chan_iso_subevent(chan_id, chan_map_3, chan_map_3_2_used, &prn_s, &remap_idx);
613+
LL_ASSERT(remap_idx == 0U);
614+
LL_ASSERT(m == 1U);
615+
616+
/* BIS subvent 4 */
617+
m = lll_chan_iso_subevent(chan_id, chan_map_3, chan_map_3_2_used, &prn_s, &remap_idx);
618+
LL_ASSERT(remap_idx == 1U);
619+
LL_ASSERT(m == 2U);
620+
539621
#endif /* CONFIG_BT_CTLR_ISO */
540622
}
541623
#endif /* CONFIG_BT_CTLR_TEST */

0 commit comments

Comments
 (0)