1 /* 2 * Copyright (c) 2021 Nordic Semiconductor ASA 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #include <zephyr/kernel.h> 8 #include <stddef.h> 9 #include <zephyr/ztest.h> 10 11 #include <zephyr/bluetooth/bluetooth.h> 12 #include <zephyr/bluetooth/hci.h> 13 #include <host/hci_core.h> 14 15 #include <util/util.h> 16 #include <util/memq.h> 17 #include <util/dbuf.h> 18 19 #include <pdu_df.h> 20 #include <lll/pdu_vendor.h> 21 #include <pdu.h> 22 #include <lll.h> 23 #include <lll_scan.h> 24 #include <lll/lll_df_types.h> 25 #include <lll_sync.h> 26 #include <lll_conn.h> 27 #include <ull_tx_queue.h> 28 #include <ull_scan_types.h> 29 #include <ull_scan_internal.h> 30 #include <ull_conn_types.h> 31 #include <ull_conn_internal.h> 32 #include <ull_sync_types.h> 33 #include <ull_sync_internal.h> 34 35 struct bt_le_per_adv_sync *g_per_sync; 36 37 static struct bt_le_per_adv_sync_param g_sync_create_param; 38 common_create_per_sync_set(void)39void common_create_per_sync_set(void) 40 { 41 struct ll_scan_set *scan; 42 struct ll_sync_set *sync; 43 int err; 44 45 bt_addr_le_copy(&g_sync_create_param.addr, BT_ADDR_LE_NONE); 46 g_sync_create_param.options = 0; 47 g_sync_create_param.sid = 0; 48 g_sync_create_param.skip = 0; 49 g_sync_create_param.timeout = 0xa; 50 51 err = bt_le_per_adv_sync_create(&g_sync_create_param, &g_per_sync); 52 zassert_equal(err, 0, "Failed to create periodic sync set"); 53 54 /* Below code makes fake sync enable and provides appropriate handle value to 55 * g_per_sync->handle. There is no complete sync established procedure, 56 * because it is not required to test DF functionality. 57 */ 58 scan = ull_scan_set_get(SCAN_HANDLE_1M); 59 sync = scan->periodic.sync; 60 g_per_sync->handle = ull_sync_handle_get(sync); 61 sync->lll.phy = PHY_2M; 62 /* timeout_reload member is used by controller to check if sync was established. */ 63 sync->timeout_reload = 1; 64 } 65