1 /** @file
2  *  @brief Bluetooth Mesh Configuration Client Model APIs.
3  */
4 
5 /*
6  * Copyright (c) 2017 Intel Corporation
7  * Additional Copyright (c) 2018 Espressif Systems (Shanghai) PTE LTD
8  *
9  * SPDX-License-Identifier: Apache-2.0
10  */
11 #ifndef _BLE_MESH_CFG_CLI_H_
12 #define _BLE_MESH_CFG_CLI_H_
13 
14 #include "client_common.h"
15 
16 /**
17  * @brief Bluetooth Mesh
18  * @defgroup bt_mesh_cfg_cli Bluetooth Mesh Configuration Client Model
19  * @ingroup bt_mesh
20  * @{
21  */
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /* Config client model common structure */
28 typedef bt_mesh_client_user_data_t      bt_mesh_config_client_t;
29 typedef bt_mesh_client_internal_data_t  config_internal_data_t;
30 
31 extern const struct bt_mesh_model_op bt_mesh_cfg_cli_op[];
32 extern const struct bt_mesh_model_cb bt_mesh_cfg_cli_cb;
33 
34 #define BLE_MESH_MODEL_CFG_CLI(cli_data)            \
35         BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_CFG_CLI,   \
36             bt_mesh_cfg_cli_op, NULL, cli_data, &bt_mesh_cfg_cli_cb)
37 
38 int bt_mesh_cfg_comp_data_get(bt_mesh_client_common_param_t *param, uint8_t page);
39 
40 int bt_mesh_cfg_beacon_get(bt_mesh_client_common_param_t *param);
41 
42 int bt_mesh_cfg_beacon_set(bt_mesh_client_common_param_t *param, uint8_t val);
43 
44 int bt_mesh_cfg_ttl_get(bt_mesh_client_common_param_t *param);
45 
46 int bt_mesh_cfg_ttl_set(bt_mesh_client_common_param_t *param, uint8_t val);
47 
48 int bt_mesh_cfg_friend_get(bt_mesh_client_common_param_t *param);
49 
50 int bt_mesh_cfg_friend_set(bt_mesh_client_common_param_t *param, uint8_t val);
51 
52 int bt_mesh_cfg_gatt_proxy_get(bt_mesh_client_common_param_t *param);
53 
54 int bt_mesh_cfg_gatt_proxy_set(bt_mesh_client_common_param_t *param, uint8_t val);
55 
56 int bt_mesh_cfg_relay_get(bt_mesh_client_common_param_t *param);
57 
58 int bt_mesh_cfg_relay_set(bt_mesh_client_common_param_t *param,
59                           uint8_t relay, uint8_t retransmit);
60 
61 int bt_mesh_cfg_net_key_add(bt_mesh_client_common_param_t *param,
62                             uint16_t net_idx, const uint8_t net_key[16]);
63 
64 int bt_mesh_cfg_app_key_add(bt_mesh_client_common_param_t *param,
65                             uint16_t net_idx, uint16_t app_idx,
66                             const uint8_t app_key[16]);
67 
68 int bt_mesh_cfg_mod_app_bind(bt_mesh_client_common_param_t *param,
69                              uint16_t elem_addr, uint16_t app_idx,
70                              uint16_t mod_id, uint16_t cid);
71 
72 struct bt_mesh_cfg_mod_pub {
73     uint16_t addr;
74     uint16_t app_idx;
75     bool     cred_flag;
76     uint8_t  ttl;
77     uint8_t  period;
78     uint8_t  transmit;
79 };
80 
81 int bt_mesh_cfg_mod_pub_get(bt_mesh_client_common_param_t *param,
82                             uint16_t elem_addr, uint16_t mod_id, uint16_t cid);
83 
84 int bt_mesh_cfg_mod_pub_set(bt_mesh_client_common_param_t *param,
85                             uint16_t elem_addr, uint16_t mod_id, uint16_t cid,
86                             struct bt_mesh_cfg_mod_pub *pub);
87 
88 int bt_mesh_cfg_mod_sub_add(bt_mesh_client_common_param_t *param,
89                             uint16_t elem_addr, uint16_t sub_addr,
90                             uint16_t mod_id, uint16_t cid);
91 
92 int bt_mesh_cfg_mod_sub_del(bt_mesh_client_common_param_t *param,
93                             uint16_t elem_addr, uint16_t sub_addr,
94                             uint16_t mod_id, uint16_t cid);
95 
96 int bt_mesh_cfg_mod_sub_overwrite(bt_mesh_client_common_param_t *param,
97                                   uint16_t elem_addr, uint16_t sub_addr,
98                                   uint16_t mod_id, uint16_t cid);
99 
100 int bt_mesh_cfg_mod_sub_va_add(bt_mesh_client_common_param_t *param,
101                                uint16_t elem_addr, const uint8_t label[16],
102                                uint16_t mod_id, uint16_t cid);
103 
104 int bt_mesh_cfg_mod_sub_va_del(bt_mesh_client_common_param_t *param,
105                                uint16_t elem_addr, const uint8_t label[16],
106                                uint16_t mod_id, uint16_t cid);
107 
108 int bt_mesh_cfg_mod_sub_va_overwrite(bt_mesh_client_common_param_t *param,
109                                      uint16_t elem_addr, const uint8_t label[16],
110                                      uint16_t mod_id, uint16_t cid);
111 
112 struct bt_mesh_cfg_hb_sub {
113     uint16_t src;
114     uint16_t dst;
115     uint8_t  period;
116 };
117 
118 int bt_mesh_cfg_hb_sub_set(bt_mesh_client_common_param_t *param,
119                            struct bt_mesh_cfg_hb_sub *sub);
120 
121 int bt_mesh_cfg_hb_sub_get(bt_mesh_client_common_param_t *param);
122 
123 struct bt_mesh_cfg_hb_pub {
124     uint16_t dst;
125     uint8_t  count;
126     uint8_t  period;
127     uint8_t  ttl;
128     uint16_t feat;
129     uint16_t net_idx;
130 };
131 
132 int bt_mesh_cfg_hb_pub_set(bt_mesh_client_common_param_t *param,
133                            struct bt_mesh_cfg_hb_pub *pub);
134 
135 int bt_mesh_cfg_hb_pub_get(bt_mesh_client_common_param_t *param);
136 
137 int bt_mesh_cfg_node_reset(bt_mesh_client_common_param_t *param);
138 
139 /* Configuration Client Status Message Context */
140 
141 struct bt_mesh_cfg_comp_data_status {
142     uint8_t page;
143     struct net_buf_simple *comp_data;
144 };
145 
146 struct bt_mesh_cfg_relay_status {
147     uint8_t relay;
148     uint8_t retransmit;
149 };
150 
151 struct bt_mesh_cfg_netkey_status {
152     uint8_t  status;
153     uint16_t net_idx;
154 };
155 
156 struct bt_mesh_cfg_appkey_status {
157     uint8_t  status;
158     uint16_t net_idx;
159     uint16_t app_idx;
160 };
161 
162 struct bt_mesh_cfg_mod_app_status {
163     uint8_t  status;
164     uint16_t elem_addr;
165     uint16_t app_idx;
166     uint16_t cid;
167     uint16_t mod_id;
168 };
169 
170 struct bt_mesh_cfg_mod_pub_status {
171     uint8_t  status;
172     uint16_t elem_addr;
173     uint16_t addr;
174     uint16_t app_idx;
175     bool     cred_flag;
176     uint8_t  ttl;
177     uint8_t  period;
178     uint8_t  transmit;
179     uint16_t cid;
180     uint16_t mod_id;
181 };
182 
183 struct bt_mesh_cfg_mod_sub_status {
184     uint8_t  status;
185     uint16_t elem_addr;
186     uint16_t sub_addr;
187     uint16_t cid;
188     uint16_t mod_id;
189 };
190 
191 struct bt_mesh_cfg_hb_sub_status {
192     uint8_t  status;
193     uint16_t src;
194     uint16_t dst;
195     uint8_t  period;
196     uint8_t  count;
197     uint8_t  min;
198     uint8_t  max;
199 };
200 
201 struct bt_mesh_cfg_hb_pub_status {
202     uint8_t  status;
203     uint16_t dst;
204     uint8_t  count;
205     uint8_t  period;
206     uint8_t  ttl;
207     uint16_t feat;
208     uint16_t net_idx;
209 };
210 
211 struct bt_mesh_cfg_mod_sub_list {
212     uint8_t  status;
213     uint16_t elem_addr;
214     uint16_t cid;
215     uint16_t mod_id;
216     struct net_buf_simple *addr;
217 };
218 
219 struct bt_mesh_cfg_net_key_list {
220     struct net_buf_simple *net_idx;
221 };
222 
223 struct bt_mesh_cfg_app_key_list {
224     uint8_t  status;
225     uint16_t net_idx;
226     struct net_buf_simple *app_idx;
227 };
228 
229 struct bt_mesh_cfg_node_id_status {
230     uint8_t  status;
231     uint16_t net_idx;
232     uint8_t  identity;
233 };
234 
235 struct bt_mesh_cfg_mod_app_list {
236     uint8_t  status;
237     uint16_t elem_addr;
238     uint16_t cid;
239     uint16_t mod_id;
240     struct net_buf_simple *app_idx;
241 };
242 
243 struct bt_mesh_cfg_key_refresh_status {
244     uint8_t  status;
245     uint16_t net_idx;
246     uint8_t  phase;
247 };
248 
249 struct bt_mesh_cfg_lpn_pollto_status {
250     uint16_t lpn_addr;
251     int32_t  timeout;
252 };
253 
254 int bt_mesh_cfg_mod_pub_va_set(bt_mesh_client_common_param_t *param,
255                                uint16_t elem_addr, uint16_t mod_id,
256                                uint16_t cid, const uint8_t label[16],
257                                struct bt_mesh_cfg_mod_pub *pub);
258 
259 int bt_mesh_cfg_mod_sub_del_all(bt_mesh_client_common_param_t *param,
260                                 uint16_t elem_addr, uint16_t mod_id, uint16_t cid);
261 
262 int bt_mesh_cfg_mod_sub_get(bt_mesh_client_common_param_t *param,
263                             uint16_t elem_addr, uint16_t mod_id);
264 
265 int bt_mesh_cfg_mod_sub_get_vnd(bt_mesh_client_common_param_t *param,
266                                 uint16_t elem_addr, uint16_t mod_id, uint16_t cid);
267 
268 int bt_mesh_cfg_net_key_update(bt_mesh_client_common_param_t *param,
269                                uint16_t net_idx, const uint8_t net_key[16]);
270 
271 int bt_mesh_cfg_net_key_delete(bt_mesh_client_common_param_t *param, uint16_t net_idx);
272 
273 int bt_mesh_cfg_net_key_get(bt_mesh_client_common_param_t *param);
274 
275 int bt_mesh_cfg_app_key_update(bt_mesh_client_common_param_t *param,
276                                uint16_t net_idx, uint16_t app_idx,
277                                const uint8_t app_key[16]);
278 
279 int bt_mesh_cfg_app_key_delete(bt_mesh_client_common_param_t *param,
280                                uint16_t net_idx, uint16_t app_idx);
281 
282 int bt_mesh_cfg_app_key_get(bt_mesh_client_common_param_t *param, uint16_t net_idx);
283 
284 int bt_mesh_cfg_node_identity_get(bt_mesh_client_common_param_t *param, uint16_t net_idx);
285 
286 int bt_mesh_cfg_node_identity_set(bt_mesh_client_common_param_t *param,
287                                   uint16_t net_idx, uint8_t identity);
288 
289 int bt_mesh_cfg_mod_app_unbind(bt_mesh_client_common_param_t *param,
290                                uint16_t elem_addr, uint16_t app_idx,
291                                uint16_t mod_id, uint16_t cid);
292 
293 int bt_mesh_cfg_mod_app_get(bt_mesh_client_common_param_t *param,
294                             uint16_t elem_addr, uint16_t mod_id);
295 
296 int bt_mesh_cfg_mod_app_get_vnd(bt_mesh_client_common_param_t *param,
297                                 uint16_t elem_addr, uint16_t mod_id, uint16_t cid);
298 
299 int bt_mesh_cfg_kr_phase_get(bt_mesh_client_common_param_t *param, uint16_t net_idx);
300 
301 int bt_mesh_cfg_kr_phase_set(bt_mesh_client_common_param_t *param,
302                              uint16_t net_idx, uint8_t transition);
303 
304 int bt_mesh_cfg_lpn_timeout_get(bt_mesh_client_common_param_t *param, uint16_t lpn_addr);
305 
306 int bt_mesh_cfg_net_transmit_get(bt_mesh_client_common_param_t *param);
307 
308 int bt_mesh_cfg_net_transmit_set(bt_mesh_client_common_param_t *param, uint8_t transmit);
309 
310 #ifdef __cplusplus
311 }
312 #endif
313 
314 /**
315  * @}
316  */
317 
318 #endif /* __BLE_MESH_CFG_CLI_H */
319