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/bluetooth.h>
10 #include <zephyr/bluetooth/conn.h>
11 #include <zephyr/toolchain.h>
12
13 #include <stdint.h>
14 #include <string.h>
15
peripheral(void)16 void peripheral(void)
17 {
18 bs_bt_utils_setup();
19
20 int id_a;
21 int id_b;
22 bt_addr_le_t central;
23
24 id_a = bt_id_create(NULL, NULL);
25 ASSERT(id_a >= 0, "bt_id_create id_a failed (err %d)\n", id_a);
26
27 id_b = bt_id_create(NULL, NULL);
28 ASSERT(id_b >= 0, "bt_id_create id_b failed (err %d)\n", id_b);
29
30 printk("== Bonding id a ==\n");
31 advertise_connectable(id_a, NULL);
32 wait_connected();
33 /* Central should bond here, and trigger a disconnect. */
34 wait_disconnected();
35 central = *bt_conn_get_dst(g_conn);
36 clear_g_conn();
37
38 printk("== Bonding id b ==\n");
39 advertise_connectable(id_b, NULL);
40 wait_connected();
41 /* Central should bond here. */
42 BUILD_ASSERT(!IS_ENABLED(CONFIG_BT_ID_UNPAIR_MATCHING_BONDS), "");
43 WAIT_FOR_FLAG(flag_pairing_failed);
44 PASS("PASS\n");
45 }
46