1 /* 2 * Copyright (c) 2023 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)15void central(void) 16 { 17 bs_bt_utils_setup(); 18 19 printk("== Bonding id a - global bondable mode ==\n"); 20 BUILD_ASSERT(CONFIG_BT_BONDABLE, "CONFIG_BT_BONDABLE must be enabled by default."); 21 enable_bt_conn_set_bondable(false); 22 scan_connect_to_first_result(); 23 wait_connected(); 24 set_security(BT_SECURITY_L2); 25 TAKE_FLAG(flag_pairing_complete); 26 TAKE_FLAG(flag_bonded); 27 disconnect(); 28 wait_disconnected(); 29 unpair(BT_ID_DEFAULT); 30 clear_g_conn(); 31 32 printk("== Bonding id a - bond per-connection ==\n"); 33 enable_bt_conn_set_bondable(true); 34 set_bondable(true); 35 scan_connect_to_first_result(); 36 wait_connected(); 37 set_security(BT_SECURITY_L2); 38 TAKE_FLAG(flag_pairing_complete); 39 TAKE_FLAG(flag_bonded); 40 disconnect(); 41 wait_disconnected(); 42 clear_g_conn(); 43 44 printk("== Bonding id b - bond per-connection ==\n"); 45 scan_connect_to_first_result(); 46 wait_connected(); 47 set_security(BT_SECURITY_L2); 48 TAKE_FLAG(flag_pairing_complete); 49 TAKE_FLAG(flag_not_bonded); 50 disconnect(); 51 wait_disconnected(); 52 clear_g_conn(); 53 54 PASS("PASS\n"); 55 } 56