Add the default deny rule for org.projectx.bt.mesh
[platform/core/connectivity/bluetooth-frwk.git] / include / bluetooth-mesh-api.h
1 /*
2  * Bluetooth-frwk
3  *
4  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
5  *
6  * @author: Anupam Roy (anupam.r@samsung.com)
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *              http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21
22 #ifndef __BLUETOOTH_MESH_API_H
23 #define __BLUETOOTH_MESH_API_H
24
25 #include <stdint.h>
26 #include <glib.h>
27 #include <dlog.h>
28
29 #include <bluetooth-api.h>
30
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35
36 #define BLUETOOTH_MESH_NETWORK_NAME_STRING_MAX  100
37 #define BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH       32
38 #define BLUETOOTH_MESH_NETWORK_TOKEN_STRING_LENGTH      16
39 #define BLUETOOTH_MESH_APP_UNIQUE_CRED_STRING_LENGTH    50
40 #define BLUETOOTH_MESH_AUTH_VALUE_LENGTH_MAX    50
41
42 typedef enum {
43         BLUETOOTH_MESH_NODE_KEY_ADD,
44         BLUETOOTH_MESH_NODE_KEY_UPDATE,
45         BLUETOOTH_MESH_NODE_KEY_DELETE,
46 } bluetooth_mesh_node_key_conf_e;
47
48 typedef enum {
49         BLUETOOTH_MESH_MODEL_SUB_ADD,
50         BLUETOOTH_MESH_MODEL_SUB_DELETE,
51         BLUETOOTH_MESH_MODEL_SUB_DELETE_ALL,
52         BLUETOOTH_MESH_MODEL_SUB_OVERWRITE,
53 } bluetooth_mesh_model_sub_op_e;
54
55 typedef struct {
56         int event;
57         int result;
58         void *param_data;
59         void *user_data;
60 } mesh_event_param_t;
61
62 typedef struct {
63         uint16_t elem_index;
64         uint32_t model_id;
65 } bluetooth_mesh_model_t;
66
67 typedef struct {
68         uint16_t index;
69         uint16_t num_models;
70 } bluetooth_mesh_element_t;
71
72 typedef struct {
73         uint16_t companyid;
74         uint16_t vendorid;
75         uint16_t versionid;
76         uint16_t crpl;
77 } bluetooth_mesh_vendor_info_t;
78
79 typedef struct {
80         int relay;
81         int proxy;
82         int frnd;
83         int lpn;
84 } bluetooth_mesh_features_t;
85
86 typedef struct {
87         bluetooth_mesh_vendor_info_t vendor_info;
88         uint16_t num_elements;
89         uint16_t primary_unicast;
90         uint8_t uuid[16];
91         union {
92                 uint8_t u8[8];
93                 uint64_t u64;
94         } token;
95 } bluetooth_mesh_node_t;
96
97
98 typedef struct {
99         char token[BLUETOOTH_MESH_NETWORK_TOKEN_STRING_LENGTH +1];
100 } bluetooth_mesh_token_t;
101
102 typedef struct {
103         char name[BLUETOOTH_MESH_NETWORK_NAME_STRING_MAX +1];
104 } bluetooth_mesh_network_name_t;
105
106 typedef struct {
107         bluetooth_mesh_network_name_t name;
108         bluetooth_mesh_token_t token;
109         char uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
110         char app_cred[BLUETOOTH_MESH_APP_UNIQUE_CRED_STRING_LENGTH + 1];
111 } bluetooth_mesh_network_t;
112
113 typedef struct {
114         char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
115         int rssi;
116         char dev_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
117         uint8_t oob_info[2];
118         uint8_t uri_hash[4];
119 } bluetooth_mesh_scan_result_t;
120
121 typedef struct {
122         uint16_t scan_time;
123 } bluetooth_mesh_scan_param_t;
124
125
126 typedef struct {
127         bool public_oob;
128         bool static_oob;
129         uint16_t out_oob;
130         uint16_t  in_oob;
131 } bluetooth_mesh_provisioner_caps_t;
132
133 typedef struct {
134         char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
135         char dev_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
136         uint16_t unicast;
137         int count;
138         int netkey_idx;
139 } bluetooth_mesh_node_discover_t;
140
141 typedef struct {
142         char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
143         char dev_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
144         uint16_t unicast;
145         int elem_count;
146         bluetooth_mesh_vendor_info_t vendor_info;
147         bluetooth_mesh_features_t features;
148 } bluetooth_mesh_node_features_t;
149
150 typedef struct {
151         char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
152         uint16_t unicast;
153         uint8_t ttl;
154         bool is_set;
155 } bluetooth_mesh_node_ttl_info_t;
156
157 typedef struct {
158         char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
159         uint16_t primary_unicast;
160         int elem_index;
161         uint32_t model;
162         uint16_t netkey_idx;
163         uint16_t appkey_idx;
164         uint16_t **appkey_list;
165         int appkeylist_count;
166         bool is_bind;
167
168         /* For Subscription Configuration */
169         bluetooth_mesh_model_sub_op_e op;
170         bool is_virtual_sub;
171         uint16_t sub_addr;
172         uint16_t **sub_list;
173         int sublist_count;
174
175         /* For Publication Configuration */
176         uint16_t pub_addr;
177         uint8_t ttl;
178         uint8_t period;
179         uint8_t retransmit;
180 } bluetooth_mesh_model_configure_t;
181
182 typedef struct {
183         char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
184         bool is_virtual;
185         uint16_t group_addr;
186         char label_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH +1];
187 } bluetooth_mesh_network_group_info_t;
188
189 typedef struct {
190         char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
191         char dev_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
192         uint16_t primary_unicast;
193         uint16_t netkey_idx;
194         uint16_t appkey_idx;
195         bool is_netkey;
196         bluetooth_mesh_node_key_conf_e op;
197 } bluetooth_mesh_key_configure_t;
198
199 typedef struct {
200         char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
201         char dev_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
202 } bluetooth_mesh_provisioning_request_t;
203
204 typedef struct {
205         int result;
206         int reason;
207         char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
208         char dev_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
209         uint16_t unicast;
210         uint8_t count;
211 } bluetooth_mesh_provisioning_result_t;
212
213 typedef struct {
214         char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
215         int auth_type;
216         char auth_value[50];
217 } bluetooth_mesh_authentication_request_t;
218
219 typedef struct {
220         uint16_t primary_unicast;
221         char dev_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
222 } bluetooth_mesh_node_info_t;
223
224 /**
225  * Mesh Event handler callback
226  */
227 typedef void (*mesh_cb_func_ptr)(int, mesh_event_param_t *, void *);
228
229 /**
230  * Mesh Init
231  */
232 int bluetooth_mesh_init(mesh_cb_func_ptr callback_ptr, void *user_data);
233
234 /**
235  * Mesh De-Init
236  */
237 int bluetooth_mesh_deinit(void);
238
239 /**
240  * Create Local Mesh Network
241  */
242 int bluetooth_mesh_network_create(const char *net_name,
243                 bluetooth_mesh_node_t *node, uint16_t total_models,
244                         bluetooth_mesh_model_t **models,
245                                 bluetooth_mesh_network_t *network);
246
247 /**
248  * Load already created Network
249  */
250 int bluetooth_mesh_network_load(const char *token,
251                 bluetooth_mesh_network_t *network);
252
253 /**
254  * Scan for Unprovisioned Devices
255  */
256 int bluetooth_mesh_network_scan(bluetooth_mesh_network_t *network,
257                 bluetooth_mesh_scan_param_t *scan_param);
258
259 /**
260  * Cancel the ongoing Scan
261  */
262 int bluetooth_mesh_network_cancel_scan(bluetooth_mesh_network_t *network);
263
264 /**
265  * Set Local Network Provisioning Capabilities
266  */
267 int bluetooth_mesh_network_set_capabilities(
268                 bluetooth_mesh_network_t *network,
269                         bluetooth_mesh_provisioner_caps_t *caps);
270
271 /**
272  * Povision a Device
273 */
274 int bluetooth_mesh_network_provision_device(
275                 bluetooth_mesh_provisioning_request_t *req);
276
277 /**
278  * Reply to Authentication request
279  */
280 int bluetooth_mesh_authentication_reply(int auth_type,
281                 const char *auth_val, gboolean reply);
282
283 /**
284  * Set Local Mesh Network name
285  */
286 int bluetooth_mesh_network_set_name(bluetooth_mesh_network_t *network);
287
288 /**
289  * Add Subnet key in local Network
290  */
291 int bluetooth_mesh_network_add_netkey(bluetooth_mesh_network_t *network,
292                 uint16_t *netkey_idx);
293
294 /**
295  * Delete Subnet key in local Network
296  */
297 int bluetooth_mesh_network_delete_netkey(
298                 bluetooth_mesh_network_t *network, uint16_t netkey_idx);
299
300 /**
301  * Update Subnet key in local Network
302  */
303 int bluetooth_mesh_network_update_netkey(bluetooth_mesh_network_t *network,
304                 uint16_t netkey_idx);
305
306 /**
307  * Add Application Key in local Network
308  */
309 int bluetooth_mesh_network_add_appkey(bluetooth_mesh_network_t *network,
310                 uint16_t netkey_idx, uint16_t *appkey_index);
311
312 /**
313  * Update Application Key in local Network
314  */
315 int bluetooth_mesh_network_update_appkey(bluetooth_mesh_network_t *network,
316                 uint16_t netkey_index, uint16_t appkey_idx);
317
318 /**
319  * Delete Application Key in local Network
320  */
321 int bluetooth_mesh_network_delete_appkey(bluetooth_mesh_network_t *network,
322                 uint16_t netkey_index, uint16_t appkey_idx);
323
324 /**
325  * Get All Netkeys in Local Network
326  */
327 int bluetooth_mesh_network_get_all_netkey(bluetooth_mesh_network_t *network,
328                         GPtrArray **netkeys);
329
330 /**
331  * Get All Appkeys Bound to a Netkey in Local Network
332  * Mesh Init
333  */
334 int bluetooth_mesh_netkey_get_all_appkey(bluetooth_mesh_network_t *network,
335                 uint16_t netkey_idx,  GPtrArray **appkeys);
336
337 /**
338  * Get All nodes's basic information, that are added in the local Network
339  */
340 int bluetooth_mesh_network_get_all_nodes(bluetooth_mesh_network_t *network,
341                 GPtrArray **nodes);
342
343 /**
344  * Get all Model information
345  */
346 int bluetooth_mesh_element_get_all_models(bluetooth_mesh_network_t *network,
347                  uint16_t node_addr, int elem_idx, GPtrArray **models);
348
349
350 /**
351  * Get All Netkeys bound to a node
352  */
353 int bluetooth_mesh_node_get_all_netkeys(bluetooth_mesh_node_discover_t *req,
354                         GPtrArray **netkeys);
355
356 /**
357  * Get All Application Keys bound to a node
358  */
359 int bluetooth_mesh_node_get_all_appkeys(bluetooth_mesh_node_discover_t *req,
360                         GPtrArray **appkeys);
361
362 /**
363  * Discover remote node exported informations (E.g: Models)
364  */
365 int bluetooth_mesh_browse_remote_node(bluetooth_mesh_node_discover_t *req);
366
367 /**
368  * Configure Key to a node
369  */
370 int bluetooth_mesh_node_configure_key(bluetooth_mesh_key_configure_t *req);
371
372 /**
373  * Confiure Appplication key to a model of a node
374  */
375 int bluetooth_mesh_model_configure_appkey(
376                 bluetooth_mesh_model_configure_t *req);
377
378 /**
379  * Get all application keys added to a model of a node
380  */
381 int bluetooth_mesh_model_get_all_appkeys(
382                 bluetooth_mesh_model_configure_t *req);
383
384 /**
385  * Get full subscription list added to a Model in a node
386  */
387 int bluetooth_mesh_model_get_subscriptopn_list(
388                 bluetooth_mesh_model_configure_t *req);
389
390 /**
391  * Get/Set Time To Live value of a node
392  */
393 int bluetooth_mesh_node_ttl_execute(
394                 bluetooth_mesh_node_ttl_info_t *req);
395
396 /**
397  * Get all groups available in local Network
398  */
399 int bluetooth_mesh_network_get_all_groups(
400                 bluetooth_mesh_network_t *network,
401                 GPtrArray **groups);
402
403 /**
404  * Create a group in a network
405  */
406 int bluetooth_mesh_network_create_group(bluetooth_mesh_network_t *network,
407                 bool is_virtual, uint16_t grp_addr,
408                         bluetooth_mesh_network_group_info_t *info);
409
410 /**
411  * Remove a group in a network
412  */
413 int bluetooth_mesh_network_remove_group(bluetooth_mesh_network_t *network,
414                 bluetooth_mesh_network_group_info_t *req);
415
416 /**
417  * Configure a Mesh group to a Mesh odel
418  */
419 int bluetooth_mesh_model_configure_group_sub(
420         bluetooth_mesh_model_configure_t *req);
421
422 /**
423  * Confgure Virtual group to a Mesh Model
424  */
425 int bluetooth_mesh_model_configure_virtual_group_sub(
426                 bluetooth_mesh_model_configure_t *req);
427
428 /**
429  * Set Publication Information to a model of a node
430  */
431 int bluetooth_mesh_model_set_publication(bluetooth_mesh_model_configure_t *req);
432
433 /**
434  * Get Publication Information from a model of a node
435  */
436 int bluetooth_mesh_model_get_publication(bluetooth_mesh_model_configure_t *req);
437
438 /**
439  * Browse Vendor specific features from node
440  */
441 int bluetooth_mesh_node_browse_vendor_features(bluetooth_mesh_node_features_t *req);
442
443 #ifdef __cplusplus
444 }
445 #endif
446 #endif /* __BLUETOOTH_MESH_API_H */