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 "babblekit/testcase.h"
10 #include "common.h"
11 
test_peripheral_main(void)12 static void test_peripheral_main(void)
13 {
14 	peripheral_setup_and_connect();
15 
16 	while (bt_eatt_count(default_conn) < CONFIG_BT_EATT_MAX) {
17 		k_sleep(K_MSEC(10));
18 	}
19 
20 	/* Do not disconnect until the central also has connected all channels */
21 	k_sleep(K_MSEC(1000));
22 
23 	disconnect();
24 
25 	TEST_PASS("EATT Peripheral tests Passed");
26 }
27 
test_central_main(void)28 static void test_central_main(void)
29 {
30 	central_setup_and_connect();
31 
32 	while (bt_eatt_count(default_conn) < CONFIG_BT_EATT_MAX) {
33 		k_sleep(K_MSEC(10));
34 	}
35 
36 	wait_for_disconnect();
37 
38 	TEST_PASS("EATT Central tests Passed");
39 }
40 
41 static const struct bst_test_instance test_def[] = {
42 	{
43 		.test_id = "peripheral_autoconnect",
44 		.test_descr = "Peripheral autoconnect",
45 		.test_main_f = test_peripheral_main,
46 	},
47 	{
48 		.test_id = "central_autoconnect",
49 		.test_descr = "Central autoconnect",
50 		.test_main_f = test_central_main,
51 	},
52 	BSTEST_END_MARKER,
53 };
54 
test_main_autoconnect_install(struct bst_test_list * tests)55 struct bst_test_list *test_main_autoconnect_install(struct bst_test_list *tests)
56 {
57 	return bst_add_tests(tests, test_def);
58 }
59