1 /* common.h - Common test code */ 2 3 /* 4 * Copyright (c) 2022 Nordic Semiconductor 5 * 6 * SPDX-License-Identifier: Apache-2.0 7 */ 8 9 #include <stddef.h> 10 11 #include <zephyr/types.h> 12 #include <zephyr/sys/printk.h> 13 #include <zephyr/sys/util.h> 14 #include <zephyr/sys/byteorder.h> 15 16 #include <zephyr/bluetooth/bluetooth.h> 17 #include <zephyr/bluetooth/conn.h> 18 #include <zephyr/bluetooth/att.h> 19 20 #include "bs_types.h" 21 #include "bs_tracing.h" 22 #include "bstests.h" 23 #include "bs_pc_backchannel.h" 24 25 extern enum bst_result_t bst_result; 26 27 #define CREATE_FLAG(flag) static atomic_t flag = (atomic_t)false 28 #define SET_FLAG(flag) (void)atomic_set(&flag, (atomic_t)true) 29 #define WAIT_FOR_FLAG(flag) \ 30 while (!(bool)atomic_get(&flag)) { \ 31 (void)k_sleep(K_MSEC(1)); \ 32 } 33 34 #define FAIL(...) \ 35 do { \ 36 bst_result = Failed; \ 37 bs_trace_error_time_line(__VA_ARGS__); \ 38 } while (0) 39 40 #define PASS(...) \ 41 do { \ 42 bst_result = Passed; \ 43 bs_trace_info_time(1, __VA_ARGS__); \ 44 } while (0) 45 46 extern volatile int num_eatt_channels; 47 extern struct bt_conn *default_conn; 48 49 void central_setup_and_connect(void); 50 void peripheral_setup_and_connect(void); 51 void wait_for_disconnect(void); 52 void disconnect(void); 53 void test_init(void); 54 void test_tick(bs_time_t HW_device_time); 55 void backchannel_init(void); 56 void backchannel_sync_send(void); 57 void backchannel_sync_wait(void); 58