1 /* Copyright (c) 2024 Nordic Semiconductor ASA
2  * SPDX-License-Identifier: Apache-2.0
3  */
4 
5 #include <zephyr/bluetooth/addr.h>
6 #include <zephyr/bluetooth/bluetooth.h>
7 #include <zephyr/kernel.h>
8 #include <zephyr/logging/log.h>
9 #include <zephyr/sys/atomic.h>
10 #include <zephyr/sys/atomic_builtin.h>
11 
12 #include "testlib/log_utils.h"
13 #include "babblekit/flags.h"
14 #include "babblekit/testcase.h"
15 
16 LOG_MODULE_REGISTER(peer, LOG_LEVEL_DBG);
17 
18 extern unsigned long runtime_log_level;
19 
entrypoint_peer(void)20 void entrypoint_peer(void)
21 {
22 	int err;
23 
24 	TEST_START("peer");
25 
26 	/* Set the log level given by the `log_level` CLI argument */
27 	bt_testlib_log_level_set("peer", runtime_log_level);
28 
29 	err = bt_enable(NULL);
30 	TEST_ASSERT(!err, "Bluetooth init failed (err %d)\n", err);
31 
32 	LOG_DBG("Bluetooth initialised");
33 
34 	struct bt_le_ext_adv *adv;
35 
36 	struct bt_le_adv_param adv_param = BT_LE_ADV_PARAM_INIT(
37 		BT_LE_ADV_OPT_EXT_ADV, BT_GAP_ADV_FAST_INT_MIN_1, BT_GAP_ADV_FAST_INT_MAX_1, NULL);
38 
39 	err = bt_le_ext_adv_create(&adv_param, NULL, &adv);
40 	TEST_ASSERT(!err, "Failed to create advertising set: %d", err);
41 	LOG_DBG("Created extended advertising set.");
42 
43 	err = bt_le_ext_adv_start(adv, BT_LE_EXT_ADV_START_DEFAULT);
44 	TEST_ASSERT(!err, "Failed to start extended advertising: %d", err);
45 	LOG_DBG("Started extended advertising.");
46 
47 	TEST_PASS("Tester done");
48 }
49