• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * @file testing.h
3  * @brief Internal API for Bluetooth testing.
4  */
5 
6 /*
7  * Copyright (c) 2017 Intel Corporation
8  *
9  * SPDX-License-Identifier: Apache-2.0
10  */
11 
12 #ifndef __BT_TESTING_H
13 #define __BT_TESTING_H
14 
15 #include "slist.h"
16 #include "glue.h"
17 #include "access.h"
18 
19 /**
20  * @brief Bluetooth testing
21  * @defgroup bt_test_cb Bluetooth testing callbacks
22  * @ingroup bluetooth
23  * @{
24  */
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 /** @brief Bluetooth Testing callbacks structure.
31  *
32  *  Callback structure to be used for Bluetooth testing purposes.
33  *  Allows access to Bluetooth stack internals, not exposed by public API.
34  */
35 struct bt_test_cb {
36     void (*mesh_net_recv)(u8_t ttl, u8_t ctl, u16_t src, u16_t dst,
37                           const void *payload, size_t payload_len);
38     void (*mesh_model_bound)(u16_t addr, struct bt_mesh_model *model,
39                              u16_t key_idx);
40     void (*mesh_model_unbound)(u16_t addr, struct bt_mesh_model *model,
41                                u16_t key_idx);
42     void (*mesh_prov_invalid_bearer)(u8_t opcode);
43     void (*mesh_trans_incomp_timer_exp)(void);
44 
45     sys_snode_t node;
46 };
47 
48 /** Register callbacks for Bluetooth testing purposes
49  *
50  *  @param cb bt_test_cb callback structure
51  */
52 void bt_test_cb_register(struct bt_test_cb *cb);
53 
54 /** Unregister callbacks for Bluetooth testing purposes
55  *
56  *  @param cb bt_test_cb callback structure
57  */
58 void bt_test_cb_unregister(struct bt_test_cb *cb);
59 
60 /** Send Friend Subscription List Add message.
61  *
62  *  Used by Low Power node to send the group address for which messages are to
63  *  be stored by Friend node.
64  *
65  *  @param group Group address
66  *
67  *  @return Zero on success or (negative) error code otherwise.
68  */
69 int bt_test_mesh_lpn_group_add(u16_t group);
70 
71 /** Send Friend Subscription List Remove message.
72  *
73  *  Used by Low Power node to remove the group addresses from Friend node
74  *  subscription list. Messages sent to those addresses will not be stored
75  *  by Friend node.
76  *
77  *  @param groups Group addresses
78  *  @param groups_count Group addresses count
79  *
80  *  @return Zero on success or (negative) error code otherwise.
81  */
82 int bt_test_mesh_lpn_group_remove(u16_t *groups, size_t groups_count);
83 
84 /** Clear replay protection list cache.
85  *
86  *  @return Zero on success or (negative) error code otherwise.
87  */
88 int bt_test_mesh_rpl_clear(void);
89 
90 u8_t mod_bind(struct bt_mesh_model *model, u16_t key_idx);
91 u8_t mod_unbind(struct bt_mesh_model *model, u16_t key_idx, bool store);
92 int cmd_mesh_init(int argc, char *argv[]);
93 
94 int bt_test_shell_init(void);
95 int bt_test_bind_app_key_to_model(struct bt_mesh_model *model, u16_t key_idx, u16_t id);
96 
97 /**
98  * @}
99  */
100 
101 #ifdef __cplusplus
102 }
103 #endif
104 
105 #endif /* __BT_TESTING_H */
106