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 15 #define TESTER_CENTRAL_ID 1 16 #define TESTER_PERIPHERAL_ID 2 17 tester_central_procedure(void)18void tester_central_procedure(void) 19 { 20 bs_bt_utils_setup(); 21 backchannel_init(TESTER_PERIPHERAL_ID); 22 printk("central tester start\n"); 23 24 /* connect to DUT as central */ 25 scan_connect_to_first_result(); 26 wait_connected(); 27 backchannel_sync_send(); 28 /* DUT is peripheral */ 29 30 /* wait until DUT connects to peripheral, and that it has disconnected 31 * from it afterwards. 32 */ 33 backchannel_sync_wait(); 34 35 printk("disconnect central\n"); 36 disconnect(); 37 38 /* DUT starts advertising again (with scanner's NRPA) 39 * should give wrong address 40 */ 41 scan_expect_same_address(); 42 43 /* PASS/FAIL is called in the `device_found` callback. */ 44 } 45 tester_peripheral_procedure(void)46void tester_peripheral_procedure(void) 47 { 48 bs_bt_utils_setup(); 49 backchannel_init(TESTER_CENTRAL_ID); 50 printk("peripheral tester start\n"); 51 52 /* wait for central to connect to DUT */ 53 backchannel_sync_wait(); 54 55 /* connect to DUT as peripheral */ 56 advertise_connectable(0, 0); 57 wait_connected(); 58 /* DUT is central & peripheral */ 59 60 printk("disconnect peripheral\n"); 61 disconnect(); 62 /* DUT starts scanning again (using NRPA) */ 63 backchannel_sync_send(); 64 65 PASS("PASS\n"); 66 } 67 tester_procedure_2(void)68void tester_procedure_2(void) 69 { 70 bs_bt_utils_setup(); 71 72 printk("Tester start\n"); 73 74 scan_connect_to_first_result(); 75 wait_connected(); 76 77 /* Verify DUT advertiser was able to resume after the connection was 78 * established. 79 */ 80 scan_expect_same_address(); 81 82 WAIT_FOR_FLAG(flag_test_end); 83 } 84