1 /*
2 * Copyright (c) 2025 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6 #include <stddef.h>
7 #include <stdint.h>
8
9 #include <zephyr/bluetooth/addr.h>
10 #include <zephyr/bluetooth/gap.h>
11 #include <zephyr/bluetooth/hci_types.h>
12 #include <zephyr/logging/log.h>
13 #include <zephyr/sys/util_macro.h>
14
15 #include "babblekit/testcase.h"
16 #include "bstests.h"
17
18 #include "btp/btp.h"
19 #include "bsim_btp.h"
20
21 LOG_MODULE_REGISTER(bsim_csip_peripheral, CONFIG_BSIM_BTTESTER_LOG_LEVEL);
22
test_csip_peripheral(void)23 static void test_csip_peripheral(void)
24 {
25 char addr_str[BT_ADDR_LE_STR_LEN];
26 bt_addr_le_t remote_addr;
27
28 bsim_btp_uart_init();
29
30 bsim_btp_wait_for_evt(BTP_SERVICE_ID_CORE, BTP_CORE_EV_IUT_READY, NULL);
31
32 bsim_btp_core_register(BTP_SERVICE_ID_GAP);
33 bsim_btp_core_register(BTP_SERVICE_ID_CSIP);
34 bsim_btp_core_register(BTP_SERVICE_ID_CSIS);
35
36 bsim_btp_gap_set_discoverable(BTP_GAP_GENERAL_DISCOVERABLE);
37 bsim_btp_gap_start_advertising(0U, 0U, NULL, BT_HCI_OWN_ADDR_PUBLIC);
38 bsim_btp_wait_for_gap_device_connected(&remote_addr);
39 bt_addr_le_to_str(&remote_addr, addr_str, sizeof(addr_str));
40 LOG_INF("Device %s connected", addr_str);
41 bsim_btp_wait_for_gap_device_disconnected(NULL);
42 LOG_INF("Device %s disconnected", addr_str);
43
44 TEST_PASS("PASSED\n");
45 }
46
47 static const struct bst_test_instance test_sample[] = {
48 {
49 .test_id = "csip_peripheral",
50 .test_descr = "Smoketest for the CSIP peripheral BT Tester behavior",
51 .test_main_f = test_csip_peripheral,
52 },
53 BSTEST_END_MARKER,
54 };
55
test_csip_peripheral_install(struct bst_test_list * tests)56 struct bst_test_list *test_csip_peripheral_install(struct bst_test_list *tests)
57 {
58 return bst_add_tests(tests, test_sample);
59 }
60