1 /* Copyright (c) 2023 Nordic Semiconductor ASA
2  * SPDX-License-Identifier: Apache-2.0
3  */
4 
5 #include <zephyr/kernel.h>
6 
7 #include <zephyr/bluetooth/bluetooth.h>
8 #include <zephyr/settings/settings.h>
9 
10 #include <zephyr/logging/log.h>
11 
12 #include "bs_tracing.h"
13 #include "bstests.h"
14 
15 #define FAIL(...)                                                                                  \
16 	do {                                                                                       \
17 		bst_result = Failed;                                                               \
18 		bs_trace_error_time_line(__VA_ARGS__);                                             \
19 	} while (0)
20 
21 #define PASS(...)                                                                                  \
22 	do {                                                                                       \
23 		bst_result = Passed;                                                               \
24 		bs_trace_info_time(1, __VA_ARGS__);                                                \
25 	} while (0)
26 
27 extern enum bst_result_t bst_result;
28 
29 #define CREATE_FLAG(flag) static atomic_t flag = (atomic_t) false
30 #define SET_FLAG(flag)	  (void)atomic_set(&flag, (atomic_t) true)
31 #define GET_FLAG(flag)	  (bool)atomic_get(&flag)
32 #define UNSET_FLAG(flag)  (void)atomic_set(&flag, (atomic_t) false)
33 #define WAIT_FOR_FLAG(flag)                                                                        \
34 	while (!(bool)atomic_get(&flag)) {                                                         \
35 		(void)k_sleep(K_MSEC(1));                                                          \
36 	}
37 
38 LOG_MODULE_DECLARE(bt_bsim_ccc_store, LOG_LEVEL_DBG);
39 
40 #define DUMMY_SERVICE_TYPE    BT_UUID_128_ENCODE(0x2e2b8dc3, 0x06e0, 0x4f93, 0x9bb2, 0x734091c356f0)
41 #define BT_UUID_DUMMY_SERVICE BT_UUID_DECLARE_128(DUMMY_SERVICE_TYPE)
42 
43 #define DUMMY_SERVICE_NOTIFY_TYPE                                                                  \
44 	BT_UUID_128_ENCODE(0x2e2b8dc3, 0x06e0, 0x4f93, 0x9bb2, 0x734091c356f3)
45 #define BT_UUID_DUMMY_SERVICE_NOTIFY BT_UUID_DECLARE_128(DUMMY_SERVICE_NOTIFY_TYPE)
46 
47 #define VAL_HANDLE 18
48 #define CCC_HANDLE 19
49 
50 #define BC_MSG_SIZE 2
51 
52 #define CLIENT_ID 0
53 #define SERVER_ID 1
54 
55 void backchannel_sync_send(uint channel, uint device_nbr);
56 void backchannel_sync_wait(uint channel, uint device_nbr);
57