1 /* main_connect.c - Application main entry point */
2
3 /*
4 * Copyright (c) 2022 Nordic Semiconductor
5 *
6 * SPDX-License-Identifier: Apache-2.0
7 */
8
9 #include "common.h"
10
test_peripheral_main(void)11 static void test_peripheral_main(void)
12 {
13 peripheral_setup_and_connect();
14
15 while (bt_eatt_count(default_conn) < CONFIG_BT_EATT_MAX) {
16 k_sleep(K_MSEC(10));
17 }
18
19 /* Do not disconnect until the central also has connected all channels */
20 k_sleep(K_MSEC(1000));
21
22 disconnect();
23
24 PASS("EATT Peripheral tests Passed\n");
25 }
26
test_central_main(void)27 static void test_central_main(void)
28 {
29 central_setup_and_connect();
30
31 while (bt_eatt_count(default_conn) < CONFIG_BT_EATT_MAX) {
32 k_sleep(K_MSEC(10));
33 }
34
35 wait_for_disconnect();
36
37 PASS("EATT Central tests Passed\n");
38 }
39
40 static const struct bst_test_instance test_def[] = {
41 {
42 .test_id = "peripheral_autoconnect",
43 .test_descr = "Peripheral autoconnect",
44 .test_pre_init_f = test_init,
45 .test_tick_f = test_tick,
46 .test_main_f = test_peripheral_main,
47 },
48 {
49 .test_id = "central_autoconnect",
50 .test_descr = "Central autoconnect",
51 .test_pre_init_f = test_init,
52 .test_tick_f = test_tick,
53 .test_main_f = test_central_main,
54 },
55 BSTEST_END_MARKER,
56 };
57
test_main_autoconnect_install(struct bst_test_list * tests)58 struct bst_test_list *test_main_autoconnect_install(struct bst_test_list *tests)
59 {
60 return bst_add_tests(tests, test_def);
61 }
62