1 /*
2 * Copyright (c) 2023 Nordic Semiconductor
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7 #include <stddef.h>
8 #include <stdint.h>
9 #include <string.h>
10
11 #include <zephyr/kernel.h>
12
13 #include <zephyr/sys/printk.h>
14
15 #include "common.h"
16 #include "time_machine.h"
17
18 #include <zephyr/logging/log.h>
19 LOG_MODULE_REGISTER(bt_bsim_mtu_update, LOG_LEVEL_DBG);
20
21 extern void run_peripheral_sample(uint8_t *notify_data, size_t notify_data_size, uint16_t seconds);
22
23 uint8_t notify_data[100] = {};
24
test_peripheral_main(void)25 static void test_peripheral_main(void)
26 {
27 notify_data[13] = 0x7f;
28 notify_data[99] = 0x55;
29
30 run_peripheral_sample(notify_data, sizeof(notify_data), PERIPHERAL_NOTIFY_TIME);
31
32 PASS("MTU Update test passed\n");
33 }
34
test_tick(bs_time_t HW_device_time)35 void test_tick(bs_time_t HW_device_time)
36 {
37 if (bst_result != Passed) {
38 FAIL("Test failed (not passed after %i seconds)\n", WAIT_TIME);
39 }
40 }
41
test_mtu_update_init(void)42 static void test_mtu_update_init(void)
43 {
44 bst_ticker_set_next_tick_absolute(WAIT_TIME);
45 bst_result = In_progress;
46 }
47
48 static const struct bst_test_instance test_def[] = {
49 {
50 .test_id = "peripheral",
51 .test_descr = "Peripheral GATT MTU Update",
52 .test_pre_init_f = test_mtu_update_init,
53 .test_tick_f = test_tick,
54 .test_main_f = test_peripheral_main
55 },
56 BSTEST_END_MARKER
57 };
58
test_mtu_update_install(struct bst_test_list * tests)59 struct bst_test_list *test_mtu_update_install(struct bst_test_list *tests)
60 {
61 return bst_add_tests(tests, test_def);
62 }
63
64 bst_test_install_t test_installers[] = {
65 test_mtu_update_install,
66 NULL
67 };
68
main(void)69 int main(void)
70 {
71 bst_main();
72 return 0;
73 }
74