1 /**
2  * Common functions and helpers for BSIM ADV tests
3  *
4  * Copyright (c) 2023 Nordic Semiconductor ASA
5  *
6  * SPDX-License-Identifier: Apache-2.0
7  */
8 
9 #include "bs_tracing.h"
10 #include "bs_types.h"
11 #include "bstests.h"
12 #include "time_machine.h"
13 
14 #include <errno.h>
15 
16 #include <zephyr/sys/__assert.h>
17 #include <zephyr/bluetooth/bluetooth.h>
18 #include <zephyr/bluetooth/conn.h>
19 #include <zephyr/bluetooth/gatt.h>
20 #include <zephyr/bluetooth/hci.h>
21 #include <zephyr/bluetooth/uuid.h>
22 #include <zephyr/kernel.h>
23 #include <zephyr/types.h>
24 
25 extern enum bst_result_t bst_result;
26 
27 #define ASSERT(expr, ...)                                                                          \
28 	do {                                                                                       \
29 		if (!(expr)) {                                                                     \
30 			FAIL(__VA_ARGS__);                                                         \
31 		}                                                                                  \
32 	} while (0)
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 #define CENTRAL_SIM_ID 0
47 #define PERIPHERAL_SIM_ID 1
48 
49 void test_tick(bs_time_t HW_device_time);
50 void test_init(void);
51 
52 void backchannel_init(uint peer);
53 void backchannel_sync_send(void);
54 void backchannel_sync_wait(void);
55