4 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
6 * @author: Anupam Roy (anupam.r@samsung.com)
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #ifndef __BLUETOOTH_MESH_API_H
23 #define __BLUETOOTH_MESH_API_H
29 #include <bluetooth-api.h>
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 #define BLUETOOTH_MESH_MODEL_MSG_LENGTH_MAX 32
44 BLUETOOTH_MESH_NODE_KEY_ADD,
45 BLUETOOTH_MESH_NODE_KEY_UPDATE,
46 BLUETOOTH_MESH_NODE_KEY_DELETE,
47 } bluetooth_mesh_node_key_conf_e;
50 BLUETOOTH_MESH_MODEL_SUB_ADD,
51 BLUETOOTH_MESH_MODEL_SUB_DELETE,
52 BLUETOOTH_MESH_MODEL_SUB_DELETE_ALL,
53 BLUETOOTH_MESH_MODEL_SUB_OVERWRITE,
54 } bluetooth_mesh_model_sub_op_e;
66 } bluetooth_mesh_model_t;
71 } bluetooth_mesh_element_t;
78 } bluetooth_mesh_vendor_info_t;
85 } bluetooth_mesh_features_t;
88 bluetooth_mesh_vendor_info_t vendor_info;
89 uint16_t num_elements;
90 uint16_t primary_unicast;
96 } bluetooth_mesh_node_t;
100 char token[BLUETOOTH_MESH_NETWORK_TOKEN_STRING_LENGTH +1];
101 } bluetooth_mesh_token_t;
104 char name[BLUETOOTH_MESH_NETWORK_NAME_STRING_MAX +1];
105 } bluetooth_mesh_network_name_t;
108 bluetooth_mesh_network_name_t name;
109 bluetooth_mesh_token_t token;
110 char uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
111 char app_cred[BLUETOOTH_MESH_APP_UNIQUE_CRED_STRING_LENGTH + 1];
112 } bluetooth_mesh_network_t;
115 char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
117 char dev_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
120 } bluetooth_mesh_scan_result_t;
124 } bluetooth_mesh_scan_param_t;
132 } bluetooth_mesh_provisioner_caps_t;
135 char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
136 char dev_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
140 } bluetooth_mesh_node_discover_t;
143 char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
144 char dev_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
147 bluetooth_mesh_vendor_info_t vendor_info;
148 bluetooth_mesh_features_t features;
149 } bluetooth_mesh_node_features_t;
152 char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
156 } bluetooth_mesh_node_ttl_info_t;
159 char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
160 uint16_t primary_unicast;
165 uint16_t **appkey_list;
166 int appkeylist_count;
169 /* For Subscription Configuration */
170 bluetooth_mesh_model_sub_op_e op;
176 /* For Publication Configuration */
181 } bluetooth_mesh_model_configure_t;
184 char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
185 uint16_t primary_unicast;
191 char msg[BLUETOOTH_MESH_MODEL_MSG_LENGTH_MAX + 1];
192 } bluetooth_mesh_model_msg_t;
195 char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
198 char label_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH +1];
199 } bluetooth_mesh_network_group_info_t;
202 char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
203 char dev_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
204 uint16_t primary_unicast;
208 bluetooth_mesh_node_key_conf_e op;
209 } bluetooth_mesh_key_configure_t;
212 char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
213 char dev_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
214 } bluetooth_mesh_provisioning_request_t;
219 char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
220 char dev_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
223 } bluetooth_mesh_provisioning_result_t;
226 char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
229 } bluetooth_mesh_authentication_request_t;
232 uint16_t primary_unicast;
233 char dev_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
234 } bluetooth_mesh_node_info_t;
237 * Mesh Event handler callback
239 typedef void (*mesh_cb_func_ptr)(int, mesh_event_param_t *, void *);
244 int bluetooth_mesh_init(mesh_cb_func_ptr callback_ptr, void *user_data);
249 int bluetooth_mesh_deinit(void);
252 * Create Local Mesh Network
254 int bluetooth_mesh_network_create(const char *net_name,
255 bluetooth_mesh_node_t *node, uint16_t total_models,
256 bluetooth_mesh_model_t **models,
257 bluetooth_mesh_network_t *network);
259 int bluetooth_mesh_network_destroy(bluetooth_mesh_network_t *network);
262 * Load already created Network
264 int bluetooth_mesh_network_load(const char *token,
265 bluetooth_mesh_network_t *network);
268 * Scan for Unprovisioned Devices
270 int bluetooth_mesh_network_scan(bluetooth_mesh_network_t *network,
271 bluetooth_mesh_scan_param_t *scan_param);
274 * Cancel the ongoing Scan
276 int bluetooth_mesh_network_cancel_scan(bluetooth_mesh_network_t *network);
279 * Set Local Network Provisioning Capabilities
281 int bluetooth_mesh_network_set_capabilities(
282 bluetooth_mesh_network_t *network,
283 bluetooth_mesh_provisioner_caps_t *caps);
288 int bluetooth_mesh_network_provision_device(
289 bluetooth_mesh_provisioning_request_t *req);
292 * Reply to Authentication request
294 int bluetooth_mesh_authentication_reply(int auth_type,
295 const char *auth_val, gboolean reply);
298 * Set Local Mesh Network name
300 int bluetooth_mesh_network_set_name(bluetooth_mesh_network_t *network);
303 * Add Subnet key in local Network
305 int bluetooth_mesh_network_add_netkey(bluetooth_mesh_network_t *network,
306 uint16_t *netkey_idx);
309 * Delete Subnet key in local Network
311 int bluetooth_mesh_network_delete_netkey(
312 bluetooth_mesh_network_t *network, uint16_t netkey_idx);
315 * Update Subnet key in local Network
317 int bluetooth_mesh_network_update_netkey(bluetooth_mesh_network_t *network,
318 uint16_t netkey_idx);
321 * Add Application Key in local Network
323 int bluetooth_mesh_network_add_appkey(bluetooth_mesh_network_t *network,
324 uint16_t netkey_idx, uint16_t *appkey_index);
327 * Update Application Key in local Network
329 int bluetooth_mesh_network_update_appkey(bluetooth_mesh_network_t *network,
330 uint16_t netkey_index, uint16_t appkey_idx);
333 * Delete Application Key in local Network
335 int bluetooth_mesh_network_delete_appkey(bluetooth_mesh_network_t *network,
336 uint16_t netkey_index, uint16_t appkey_idx);
339 * Get All Netkeys in Local Network
341 int bluetooth_mesh_network_get_all_netkey(bluetooth_mesh_network_t *network,
342 GPtrArray **netkeys);
345 * Get All Appkeys Bound to a Netkey in Local Network
348 int bluetooth_mesh_netkey_get_all_appkey(bluetooth_mesh_network_t *network,
349 uint16_t netkey_idx, GPtrArray **appkeys);
352 * Get All nodes's basic information, that are added in the local Network
354 int bluetooth_mesh_network_get_all_nodes(bluetooth_mesh_network_t *network,
358 * Get all Model information
360 int bluetooth_mesh_element_get_all_models(bluetooth_mesh_network_t *network,
361 uint16_t node_addr, int elem_idx, GPtrArray **models);
365 * Get All Netkeys bound to a node
367 int bluetooth_mesh_node_get_all_netkeys(bluetooth_mesh_node_discover_t *req,
368 GPtrArray **netkeys);
371 * Get All Application Keys bound to a node
373 int bluetooth_mesh_node_get_all_appkeys(bluetooth_mesh_node_discover_t *req,
374 GPtrArray **appkeys);
377 * Discover remote node exported informations (E.g: Models)
379 int bluetooth_mesh_browse_remote_node(bluetooth_mesh_node_discover_t *req);
382 * Configure Key to a node
384 int bluetooth_mesh_node_configure_key(bluetooth_mesh_key_configure_t *req);
387 * Confiure Appplication key to a model of a node
389 int bluetooth_mesh_model_configure_appkey(
390 bluetooth_mesh_model_configure_t *req);
393 * Send message to a model of a node
395 int bluetooth_mesh_model_send_msg(
396 bluetooth_mesh_model_msg_t *req);
399 * Get all application keys added to a model of a node
401 int bluetooth_mesh_model_get_all_appkeys(
402 bluetooth_mesh_model_configure_t *req);
405 * Get full subscription list added to a Model in a node
407 int bluetooth_mesh_model_get_subscriptopn_list(
408 bluetooth_mesh_model_configure_t *req);
411 * Get/Set Time To Live value of a node
413 int bluetooth_mesh_node_ttl_execute(
414 bluetooth_mesh_node_ttl_info_t *req);
417 * Get all groups available in local Network
419 int bluetooth_mesh_network_get_all_groups(
420 bluetooth_mesh_network_t *network,
424 * Create a group in a network
426 int bluetooth_mesh_network_create_group(bluetooth_mesh_network_t *network,
427 bool is_virtual, uint16_t grp_addr,
428 bluetooth_mesh_network_group_info_t *info);
431 * Remove a group in a network
433 int bluetooth_mesh_network_remove_group(bluetooth_mesh_network_t *network,
434 bluetooth_mesh_network_group_info_t *req);
437 * Configure a Mesh group to a Mesh odel
439 int bluetooth_mesh_model_configure_group_sub(
440 bluetooth_mesh_model_configure_t *req);
443 * Confgure Virtual group to a Mesh Model
445 int bluetooth_mesh_model_configure_virtual_group_sub(
446 bluetooth_mesh_model_configure_t *req);
449 * Set Publication Information to a model of a node
451 int bluetooth_mesh_model_set_publication(bluetooth_mesh_model_configure_t *req);
454 * Get Publication Information from a model of a node
456 int bluetooth_mesh_model_get_publication(bluetooth_mesh_model_configure_t *req);
459 * Browse Vendor specific features from node
461 int bluetooth_mesh_node_browse_vendor_features(bluetooth_mesh_node_features_t *req);
466 #endif /* __BLUETOOTH_MESH_API_H */