From 9b3a3ee79bd568499d49fe75a580eeda8aea1530 Mon Sep 17 00:00:00 2001 From: Vinayak Kariappa Chettimada Date: Thu, 16 Mar 2023 10:01:19 +0530 Subject: [PATCH] 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 --- subsys/bluetooth/controller/ll_sw/lll_chan.c | 86 +++++++++++++++++++- 1 file changed, 84 insertions(+), 2 deletions(-) diff --git a/subsys/bluetooth/controller/ll_sw/lll_chan.c b/subsys/bluetooth/controller/ll_sw/lll_chan.c index 5a2c47ce207569..c5b7a3f719e083 100644 --- a/subsys/bluetooth/controller/ll_sw/lll_chan.c +++ b/subsys/bluetooth/controller/ll_sw/lll_chan.c @@ -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; @@ -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); @@ -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; @@ -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); @@ -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 */