1 /*
2  * Copyright (c) 2022 Nordic Semiconductor ASA
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include "bs_bt_utils.h"
8 #include <zephyr/bluetooth/addr.h>
9 #include <zephyr/bluetooth/conn.h>
10 
11 #include <stdint.h>
12 
13 #include <zephyr/bluetooth/bluetooth.h>
14 
central(void)15 void central(void)
16 {
17 	bt_addr_le_t id_b;
18 
19 	bs_bt_utils_setup();
20 
21 	printk("== Bonding id a ==\n");
22 	scan_connect_to_first_result();
23 	wait_connected();
24 	set_security(BT_SECURITY_L2);
25 	TAKE_FLAG(flag_pairing_complete);
26 	disconnect();
27 	wait_disconnected();
28 	clear_g_conn();
29 
30 	printk("== Bonding id b ==\n");
31 	scan_connect_to_first_result();
32 	wait_connected();
33 	set_security(BT_SECURITY_L2);
34 	TAKE_FLAG(flag_pairing_complete);
35 	id_b = *bt_conn_get_dst(g_conn);
36 	disconnect();
37 	wait_disconnected();
38 	clear_g_conn();
39 
40 	printk("== Directed connect id b ==\n");
41 	scan_connect_to_first_result();
42 	wait_connected();
43 	ASSERT(bt_addr_le_eq(bt_conn_get_dst(g_conn), &id_b),
44 	       "Unexpected Peer. Did something resolve incorrectly?");
45 
46 	PASS("PASS\n");
47 }
48