1 /* bttester.h - Bluetooth tester headers */
2
3 /*
4 * Copyright (c) 2015-2016 Intel Corporation
5 * Copyright (c) 2022 Codecoup
6 *
7 * SPDX-License-Identifier: Apache-2.0
8 */
9
10 #include <zephyr/types.h>
11 #include <zephyr/sys/util.h>
12 #include <zephyr/bluetooth/addr.h>
13 #include <sys/types.h>
14
tester_set_bit(uint8_t * addr,unsigned int bit)15 static inline void tester_set_bit(uint8_t *addr, unsigned int bit)
16 {
17 uint8_t *p = addr + (bit / 8U);
18
19 *p |= BIT(bit % 8);
20 }
21
tester_test_bit(const uint8_t * addr,unsigned int bit)22 static inline uint8_t tester_test_bit(const uint8_t *addr, unsigned int bit)
23 {
24 const uint8_t *p = addr + (bit / 8U);
25
26 return *p & BIT(bit % 8);
27 }
28
29 void tester_init(void);
30
31 void tester_rsp(uint8_t service, uint8_t opcode, uint8_t status);
32 void tester_rsp_full(uint8_t service, uint8_t opcode, const void *rsp, size_t len);
33 void tester_event(uint8_t service, uint8_t opcode, const void *data, size_t len);
34 int tester_rsp_buffer_lock(void);
35 void tester_rsp_buffer_unlock(void);
36 void tester_rsp_buffer_free(void);
37 void tester_rsp_buffer_allocate(size_t len, uint8_t **data);
38
39 /* Used to indicate that command length is variable and that validation will
40 * be done in handler.
41 */
42 #define BTP_HANDLER_LENGTH_VARIABLE (-1)
43
44 struct btp_handler {
45 uint8_t opcode;
46 uint8_t index;
47 ssize_t expect_len;
48 uint8_t (*func)(const void *cmd, uint16_t cmd_len,
49 void *rsp, uint16_t *rsp_len);
50 };
51
52 void tester_register_command_handlers(uint8_t service,
53 const struct btp_handler *handlers,
54 size_t num);
55
56 uint8_t tester_init_gatt(void);
57 uint8_t tester_unregister_gatt(void);
58
59 uint8_t tester_init_l2cap(void);
60 uint8_t tester_unregister_l2cap(void);
61
62 uint8_t tester_init_mesh(void);
63 uint8_t tester_unregister_mesh(void);
64
65 uint8_t tester_init_vcp(void);
66 uint8_t tester_unregister_vcp(void);
67
68 uint8_t tester_init_vcs(void);
69 uint8_t tester_unregister_vcs(void);
70
71 uint8_t tester_init_aics(void);
72 uint8_t tester_unregister_aics(void);
73
74 uint8_t tester_init_vocs(void);
75 uint8_t tester_unregister_vocs(void);
76
77 uint8_t tester_init_ias(void);
78 uint8_t tester_unregister_ias(void);
79
80 uint8_t tester_init_mmdl(void);
81 uint8_t tester_unregister_mmdl(void);
82
83 uint8_t tester_init_gap(void);
84 uint8_t tester_unregister_gap(void);
85
86 void tester_init_core(void);
87
88 uint8_t tester_init_pacs(void);
89 uint8_t tester_unregister_pacs(void);
90
91 uint8_t tester_init_ascs(void);
92 uint8_t tester_unregister_ascs(void);
93
94 uint8_t tester_init_bap(void);
95 uint8_t tester_unregister_bap(void);
96
97 uint8_t tester_init_has(void);
98 uint8_t tester_unregister_has(void);
99
100 uint8_t tester_init_csis(void);
101 uint8_t tester_unregister_csis(void);
102
103 uint8_t tester_init_csip(void);
104 uint8_t tester_unregister_csip(void);
105
106 uint8_t tester_init_micp(void);
107 uint8_t tester_unregister_micp(void);
108
109 uint8_t tester_init_mics(void);
110 uint8_t tester_unregister_mics(void);
111
112 uint8_t tester_init_ccp(void);
113 uint8_t tester_unregister_ccp(void);
114
115 uint8_t tester_init_vcp(void);
116 uint8_t tester_unregister_vcp(void);
117
118 uint8_t tester_init_cas(void);
119 uint8_t tester_unregister_cas(void);
120
121 uint8_t tester_init_cap(void);
122 uint8_t tester_unregister_cap(void);
123
124 uint8_t tester_init_mcp(void);
125 uint8_t tester_unregister_mcp(void);
126
127 uint8_t tester_init_mcs(void);
128 uint8_t tester_unregister_mcs(void);
129
130 uint8_t tester_init_hap(void);
131 uint8_t tester_unregister_hap(void);
132