Skip to content

Commit

Permalink
tests: Bluetooth: Add advanced BIG create BSIM test
Browse files Browse the repository at this point in the history
Extended the ISO broadcaster BSIM test with an additional
step to create a BIG using the test parameters.

Since this isn't properly implemented in the controller,
CONFIG_BT_ISO_ADVANCED has not been enabled in the
prj.conf yet.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
  • Loading branch information
Thalley authored and fabiobaltieri committed Jul 31, 2023
1 parent 076df4e commit 5555ac3
Showing 1 changed file with 59 additions and 3 deletions.
62 changes: 59 additions & 3 deletions tests/bsim/bluetooth/ll/bis/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ static const struct bt_data per_ad_data2[] = {
static uint8_t chan_map[] = { 0x1F, 0XF1, 0x1F, 0xF1, 0x1F };

static bool volatile is_iso_connected;
static uint8_t volatile is_iso_disconnected;
static bool volatile deleting_pa_sync;
static void iso_connected(struct bt_iso_chan *chan);
static void iso_disconnected(struct bt_iso_chan *chan, uint8_t reason);
Expand Down Expand Up @@ -260,7 +261,7 @@ static void terminate_ll_big(uint8_t big_handle)

static void create_big(struct bt_le_ext_adv *adv, struct bt_iso_big **big)
{
struct bt_iso_big_create_param big_create_param;
struct bt_iso_big_create_param big_create_param = { 0 };
int err;

printk("Creating BIG...\n");
Expand Down Expand Up @@ -290,6 +291,47 @@ static void create_big(struct bt_le_ext_adv *adv, struct bt_iso_big **big)
printk("ISO connected\n");
}

#if defined(CONFIG_BT_ISO_ADVANCED)
static void create_advanced_big(struct bt_le_ext_adv *adv, struct bt_iso_big **big)
{
struct bt_iso_big_create_param big_create_param;
int err;

printk("Creating BIG...\n");
big_create_param.bis_channels = bis_channels;
big_create_param.num_bis = BIS_ISO_CHAN_COUNT;
big_create_param.encryption = false;
big_create_param.interval = 10000; /* us */
big_create_param.packing = 0; /* 0 - sequential; 1 - interleaved */
big_create_param.framing = 0; /* 0 - unframed; 1 - framed */
big_create_param.irc = BT_ISO_IRC_MIN;
big_create_param.pto = BT_ISO_PTO_MIN;
big_create_param.iso_interval = big_create_param.interval / 1250U; /* N * 10 ms */

iso_tx_qos.sdu = 502; /* bytes */
iso_tx_qos.phy = BT_GAP_LE_PHY_2M;
iso_tx_qos.max_pdu = BT_ISO_PDU_MAX;
iso_tx_qos.burst_number = BT_ISO_BN_MIN;

bis_iso_qos.tx = &iso_tx_qos;
bis_iso_qos.rx = NULL;
bis_iso_qos.num_subevents = BT_ISO_NSE_MIN;

err = bt_iso_big_create(adv, &big_create_param, big);
if (err) {
FAIL("Could not create BIG: %d\n", err);
return;
}
printk("success.\n");

printk("Wait for ISO connected callback...");
while (!is_iso_connected) {
k_sleep(K_MSEC(100));
}
printk("ISO connected\n");
}
#endif /* CONFIG_BT_ISO_ADVANCED */

static void terminate_big(struct bt_iso_big *big)
{
int err;
Expand All @@ -301,6 +343,12 @@ static void terminate_big(struct bt_iso_big *big)
return;
}
printk("success.\n");

printk("Wait for ISO disconnected callback...");
while (is_iso_disconnected == 0U) {
k_sleep(K_MSEC(100));
}
printk("ISO disconnected\n");
}

static void send_iso_data(void)
Expand Down Expand Up @@ -391,6 +439,16 @@ static void test_iso_main(void)
terminate_big(big);
big = NULL;

#if defined(CONFIG_BT_ISO_ADVANCED)
/* Quick check to just verify that creating a BIG using advanced/test
* parameters work
*/
create_advanced_big(adv, &big);

terminate_big(big);
big = NULL;
#endif /* CONFIG_BT_ISO_ADVANCED */

k_sleep(K_MSEC(10000));

teardown_ext_adv(adv);
Expand Down Expand Up @@ -427,8 +485,6 @@ static void iso_connected(struct bt_iso_chan *chan)
is_iso_connected = true;
}

static uint8_t volatile is_iso_disconnected;

static void iso_disconnected(struct bt_iso_chan *chan, uint8_t reason)
{
printk("ISO Channel %p disconnected with reason 0x%02x\n", chan, reason);
Expand Down

0 comments on commit 5555ac3

Please sign in to comment.