Skip to content

Commit 5652d59

Browse files
andrzej-kaczmarekcarlescufi
authored andcommitted
tests: Bluetooth: bsim: Add test for initaiting conn on ext adv
advx will do connectable advertising using ext adv, scanx will try to connect. Signed-off-by: Andrzej Kaczmarek <[email protected]>
1 parent 1d2babf commit 5652d59

File tree

1 file changed

+60
-0
lines changed
  • tests/bluetooth/bsim_bt/bsim_test_advx/src

1 file changed

+60
-0
lines changed

tests/bluetooth/bsim_bt/bsim_test_advx/src/main.c

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,45 @@ static void test_advx_main(void)
201201
}
202202
printk("success.\n");
203203

204+
k_sleep(K_MSEC(100));
205+
206+
is_connected = false;
207+
is_disconnected = false;
208+
209+
printk("Connectable extended advertising...");
210+
printk("Create advertising set...");
211+
err = bt_le_ext_adv_create(BT_LE_EXT_ADV_CONN_NAME, &adv_callbacks, &adv);
212+
if (err) {
213+
goto exit;
214+
}
215+
printk("success.\n");
216+
217+
printk("Start advertising...");
218+
err = bt_le_ext_adv_start(adv, &ext_adv_param);
219+
if (err) {
220+
goto exit;
221+
}
222+
printk("success.\n");
223+
224+
printk("Waiting for connection...");
225+
while (!is_connected) {
226+
k_sleep(K_MSEC(100));
227+
}
228+
229+
printk("Waiting for disconnect...");
230+
while (!is_disconnected) {
231+
k_sleep(K_MSEC(100));
232+
}
233+
234+
printk("Removing connectable adv aux set...");
235+
err = bt_le_ext_adv_delete(adv);
236+
if (err) {
237+
goto exit;
238+
}
239+
printk("success.\n");
240+
241+
k_sleep(K_MSEC(1000));
242+
204243
printk("Starting non-connectable advertising...");
205244
err = bt_le_adv_start(BT_LE_ADV_NCONN, ad, ARRAY_SIZE(ad), NULL, 0);
206245
if (err) {
@@ -961,6 +1000,27 @@ static void test_scanx_main(void)
9611000
k_sleep(K_MSEC(100));
9621001
}
9631002

1003+
is_connected = false;
1004+
is_disconnected = false;
1005+
connection_to_test = true;
1006+
1007+
printk("Start scanning...");
1008+
err = bt_le_scan_start(&scan_param, scan_cb);
1009+
if (err) {
1010+
goto exit;
1011+
}
1012+
printk("success.\n");
1013+
1014+
printk("Waiting for connection...");
1015+
while (!is_connected) {
1016+
k_sleep(K_MSEC(100));
1017+
}
1018+
1019+
printk("Waiting for disconnect...");
1020+
while (!is_disconnected) {
1021+
k_sleep(K_MSEC(100));
1022+
}
1023+
9641024
printk("Start scanning for a duration...");
9651025
is_scan_timeout = false;
9661026
scan_param.interval = 0x08;

0 commit comments

Comments
 (0)