Skip to content

Commit

Permalink
Bluetooth: Controller: Add additional LE Channel Selection tests
Browse files Browse the repository at this point in the history
Add additional custom LE Channel Selection #2 tests to cover
event and subevent mapping.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
  • Loading branch information
cvinayak authored and carlescufi committed Mar 17, 2023
1 parent c3e6edd commit 9b3a3ee
Showing 1 changed file with 84 additions and 2 deletions.
86 changes: 84 additions & 2 deletions subsys/bluetooth/controller/ll_sw/lll_chan.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,8 @@ void lll_chan_sel_2_ut(void)
uint8_t const chan_map_1_37_used = 37U;
uint8_t chan_map_2[] = {0x00, 0x06, 0xE0, 0x00, 0x1E};
uint8_t const chan_map_2_9_used = 9U;
uint8_t chan_map_3[] = {0x06, 0x00, 0x00, 0x00, 0x00};
uint8_t const chan_map_3_2_used = 2U;
uint16_t const chan_id = 0x305F;
uint8_t m;

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

/* Section 3.1 Sample Data 2 (9 used channels) */
/* Section 3.2 Sample Data 2 (9 used channels) */
m = lll_chan_sel_2(6, chan_id, chan_map_2, chan_map_2_9_used);
LL_ASSERT(m == 23U);

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

/* FIXME: Use Sample Data from Spec, if one is added.
* Below is a random sample to cover implementation in this file.
*/
/* Section x.x Sample Data 3 (2 used channels) */
m = lll_chan_sel_2(11U, chan_id, chan_map_3, chan_map_3_2_used);
LL_ASSERT(m == 1U);

m = lll_chan_sel_2(12U, chan_id, chan_map_3, chan_map_3_2_used);
LL_ASSERT(m == 2U);

m = lll_chan_sel_2(13U, chan_id, chan_map_3, chan_map_3_2_used);
LL_ASSERT(m == 1U);

#if defined(CONFIG_BT_CTLR_ISO)
uint16_t prn_subevent_lu;
Expand Down Expand Up @@ -473,7 +487,7 @@ void lll_chan_sel_2_ut(void)
LL_ASSERT(remap_idx == 8U);
LL_ASSERT(m == 8U);

/* Section 3.1 Sample Data 2 (9 used channels) */
/* Section 3.2 Sample Data 2 (9 used channels) */
/* BIS subevent 1, event counter 6 */
m = lll_chan_iso_event(6, chan_id, chan_map_2, chan_map_2_9_used, &prn_s, &remap_idx);
LL_ASSERT((prn_s ^ chan_id) == 10975);
Expand Down Expand Up @@ -536,6 +550,74 @@ void lll_chan_sel_2_ut(void)
m = lll_chan_iso_subevent(chan_id, chan_map_2, chan_map_2_9_used, &prn_s, &remap_idx);
LL_ASSERT(remap_idx == 1U);
LL_ASSERT(m == 10U);

/* FIXME: Use Sample Data from Spec, if one is added.
* Below is a random sample to cover implementation in this file.
*/
/* Section x.x Sample Data 3 (2 used channels) */
/* BIS subevent 1, event counter 11 */
m = lll_chan_iso_event(11U, chan_id, chan_map_3, chan_map_3_2_used, &prn_s, &remap_idx);
LL_ASSERT((prn_s ^ chan_id) == 8628U);
LL_ASSERT(remap_idx == 0U);
LL_ASSERT(m == 1U);

/* BIS subvent 2 */
m = lll_chan_iso_subevent(chan_id, chan_map_3, chan_map_3_2_used, &prn_s, &remap_idx);
LL_ASSERT(remap_idx == 1U);
LL_ASSERT(m == 2U);

/* BIS subvent 3 */
m = lll_chan_iso_subevent(chan_id, chan_map_3, chan_map_3_2_used, &prn_s, &remap_idx);
LL_ASSERT(remap_idx == 0U);
LL_ASSERT(m == 1U);

/* BIS subvent 4 */
m = lll_chan_iso_subevent(chan_id, chan_map_3, chan_map_3_2_used, &prn_s, &remap_idx);
LL_ASSERT(remap_idx == 1U);
LL_ASSERT(m == 2U);

/* BIS subevent 1, event counter 12 */
m = lll_chan_iso_event(12U, chan_id, chan_map_3, chan_map_3_2_used, &prn_s, &remap_idx);
LL_ASSERT((prn_s ^ chan_id) == 34748U);
LL_ASSERT(remap_idx == 1U);
LL_ASSERT(m == 2U);

/* BIS subvent 2 */
m = lll_chan_iso_subevent(chan_id, chan_map_3, chan_map_3_2_used, &prn_s, &remap_idx);
LL_ASSERT(remap_idx == 0U);
LL_ASSERT(m == 1U);

/* BIS subvent 3 */
m = lll_chan_iso_subevent(chan_id, chan_map_3, chan_map_3_2_used, &prn_s, &remap_idx);
LL_ASSERT(remap_idx == 1U);
LL_ASSERT(m == 2U);

/* BIS subvent 4 */
m = lll_chan_iso_subevent(chan_id, chan_map_3, chan_map_3_2_used, &prn_s, &remap_idx);
LL_ASSERT(remap_idx == 0U);
LL_ASSERT(m == 1U);

/* BIS subevent 1, event counter 13 */
m = lll_chan_iso_event(13U, chan_id, chan_map_3, chan_map_3_2_used, &prn_s, &remap_idx);
LL_ASSERT((prn_s ^ chan_id) == 22072U);
LL_ASSERT(remap_idx == 0U);
LL_ASSERT(m == 1U);

/* BIS subvent 2 */
m = lll_chan_iso_subevent(chan_id, chan_map_3, chan_map_3_2_used, &prn_s, &remap_idx);
LL_ASSERT(remap_idx == 1U);
LL_ASSERT(m == 2U);

/* BIS subvent 3 */
m = lll_chan_iso_subevent(chan_id, chan_map_3, chan_map_3_2_used, &prn_s, &remap_idx);
LL_ASSERT(remap_idx == 0U);
LL_ASSERT(m == 1U);

/* BIS subvent 4 */
m = lll_chan_iso_subevent(chan_id, chan_map_3, chan_map_3_2_used, &prn_s, &remap_idx);
LL_ASSERT(remap_idx == 1U);
LL_ASSERT(m == 2U);

#endif /* CONFIG_BT_CTLR_ISO */
}
#endif /* CONFIG_BT_CTLR_TEST */
Expand Down

0 comments on commit 9b3a3ee

Please sign in to comment.