Skip to content

Commit

Permalink
tests: Bluetooth: bsim: Add test for initaiting conn on ext adv
Browse files Browse the repository at this point in the history
advx will do connectable advertising using ext adv, scanx will try
to connect.

Signed-off-by: Andrzej Kaczmarek <[email protected]>
  • Loading branch information
andrzej-kaczmarek authored and carlescufi committed May 5, 2021
1 parent 1d2babf commit 5652d59
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions tests/bluetooth/bsim_bt/bsim_test_advx/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,45 @@ static void test_advx_main(void)
}
printk("success.\n");

k_sleep(K_MSEC(100));

is_connected = false;
is_disconnected = false;

printk("Connectable extended advertising...");
printk("Create advertising set...");
err = bt_le_ext_adv_create(BT_LE_EXT_ADV_CONN_NAME, &adv_callbacks, &adv);
if (err) {
goto exit;
}
printk("success.\n");

printk("Start advertising...");
err = bt_le_ext_adv_start(adv, &ext_adv_param);
if (err) {
goto exit;
}
printk("success.\n");

printk("Waiting for connection...");
while (!is_connected) {
k_sleep(K_MSEC(100));
}

printk("Waiting for disconnect...");
while (!is_disconnected) {
k_sleep(K_MSEC(100));
}

printk("Removing connectable adv aux set...");
err = bt_le_ext_adv_delete(adv);
if (err) {
goto exit;
}
printk("success.\n");

k_sleep(K_MSEC(1000));

printk("Starting non-connectable advertising...");
err = bt_le_adv_start(BT_LE_ADV_NCONN, ad, ARRAY_SIZE(ad), NULL, 0);
if (err) {
Expand Down Expand Up @@ -961,6 +1000,27 @@ static void test_scanx_main(void)
k_sleep(K_MSEC(100));
}

is_connected = false;
is_disconnected = false;
connection_to_test = true;

printk("Start scanning...");
err = bt_le_scan_start(&scan_param, scan_cb);
if (err) {
goto exit;
}
printk("success.\n");

printk("Waiting for connection...");
while (!is_connected) {
k_sleep(K_MSEC(100));
}

printk("Waiting for disconnect...");
while (!is_disconnected) {
k_sleep(K_MSEC(100));
}

printk("Start scanning for a duration...");
is_scan_timeout = false;
scan_param.interval = 0x08;
Expand Down

0 comments on commit 5652d59

Please sign in to comment.