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 char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
233 uint16_t primary_unicast;
234 uint16_t num_elements;
235 char dev_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
236 } bluetooth_mesh_node_info_t;
239 * Mesh Event handler callback
241 typedef void (*mesh_cb_func_ptr)(int, mesh_event_param_t *, void *);
246 int bluetooth_mesh_init(mesh_cb_func_ptr callback_ptr, void *user_data);
251 int bluetooth_mesh_deinit(void);
254 * Create Local Mesh Network
256 int bluetooth_mesh_network_create(const char *net_name,
257 bluetooth_mesh_node_t *node, uint16_t total_models,
258 bluetooth_mesh_model_t **models,
259 bluetooth_mesh_network_t *network);
263 * Destroy Local Network Configuration
265 int bluetooth_mesh_network_destroy(bluetooth_mesh_network_t *network);
268 * Unload Local network Configuration
270 int bluetooth_mesh_network_unload(bluetooth_mesh_network_t *network);
273 * Reset a remote Node & remove it from network
275 int bluetooth_mesh_node_reset(bluetooth_mesh_node_info_t *node);
278 * Load already created Network
280 int bluetooth_mesh_network_load(const char *token,
281 bluetooth_mesh_network_t *network);
284 * Scan for Unprovisioned Devices
286 int bluetooth_mesh_network_scan(bluetooth_mesh_network_t *network,
287 bluetooth_mesh_scan_param_t *scan_param);
290 * Cancel the ongoing Scan
292 int bluetooth_mesh_network_cancel_scan(bluetooth_mesh_network_t *network);
295 * Set Local Network Provisioning Capabilities
297 int bluetooth_mesh_network_set_capabilities(
298 bluetooth_mesh_network_t *network,
299 bluetooth_mesh_provisioner_caps_t *caps);
304 int bluetooth_mesh_network_provision_device(
305 bluetooth_mesh_provisioning_request_t *req);
308 * Reply to Authentication request
310 int bluetooth_mesh_authentication_reply(int auth_type,
311 const char *auth_val, gboolean reply);
314 * Set Local Mesh Network name
316 int bluetooth_mesh_network_set_name(bluetooth_mesh_network_t *network);
319 * Add Subnet key in local Network
321 int bluetooth_mesh_network_add_netkey(bluetooth_mesh_network_t *network,
322 uint16_t *netkey_idx);
325 * Delete Subnet key in local Network
327 int bluetooth_mesh_network_delete_netkey(
328 bluetooth_mesh_network_t *network, uint16_t netkey_idx);
331 * Update Subnet key in local Network
333 int bluetooth_mesh_network_update_netkey(bluetooth_mesh_network_t *network,
334 uint16_t netkey_idx);
337 * Add Application Key in local Network
339 int bluetooth_mesh_network_add_appkey(bluetooth_mesh_network_t *network,
340 uint16_t netkey_idx, uint16_t *appkey_index);
343 * Update Application Key in local Network
345 int bluetooth_mesh_network_update_appkey(bluetooth_mesh_network_t *network,
346 uint16_t netkey_index, uint16_t appkey_idx);
349 * Delete Application Key in local Network
351 int bluetooth_mesh_network_delete_appkey(bluetooth_mesh_network_t *network,
352 uint16_t netkey_index, uint16_t appkey_idx);
355 * Get All Netkeys in Local Network
357 int bluetooth_mesh_network_get_all_netkey(bluetooth_mesh_network_t *network,
358 GPtrArray **netkeys);
361 * Get All Appkeys Bound to a Netkey in Local Network
364 int bluetooth_mesh_netkey_get_all_appkey(bluetooth_mesh_network_t *network,
365 uint16_t netkey_idx, GPtrArray **appkeys);
368 * Get All nodes's basic information, that are added in the local Network
370 int bluetooth_mesh_network_get_all_nodes(bluetooth_mesh_network_t *network,
374 * Get all Model information
376 int bluetooth_mesh_element_get_all_models(bluetooth_mesh_network_t *network,
377 uint16_t node_addr, int elem_idx, GPtrArray **models);
381 * Get All Netkeys bound to a node
383 int bluetooth_mesh_node_get_all_netkeys(bluetooth_mesh_node_discover_t *req,
384 GPtrArray **netkeys);
387 * Get All Application Keys bound to a node
389 int bluetooth_mesh_node_get_all_appkeys(bluetooth_mesh_node_discover_t *req,
390 GPtrArray **appkeys);
393 * Discover remote node exported informations (E.g: Models)
395 int bluetooth_mesh_browse_remote_node(bluetooth_mesh_node_discover_t *req);
398 * Configure Key to a node
400 int bluetooth_mesh_node_configure_key(bluetooth_mesh_key_configure_t *req);
403 * Confiure Appplication key to a model of a node
405 int bluetooth_mesh_model_configure_appkey(
406 bluetooth_mesh_model_configure_t *req);
409 * Send message to a model of a node
411 int bluetooth_mesh_model_send_msg(
412 bluetooth_mesh_model_msg_t *req);
415 * Get all application keys added to a model of a node
417 int bluetooth_mesh_model_get_all_appkeys(
418 bluetooth_mesh_model_configure_t *req);
421 * Get full subscription list added to a Model in a node
423 int bluetooth_mesh_model_get_subscriptopn_list(
424 bluetooth_mesh_model_configure_t *req);
427 * Get/Set Time To Live value of a node
429 int bluetooth_mesh_node_ttl_execute(
430 bluetooth_mesh_node_ttl_info_t *req);
433 * Get all groups available in local Network
435 int bluetooth_mesh_network_get_all_groups(
436 bluetooth_mesh_network_t *network,
440 * Create a group in a network
442 int bluetooth_mesh_network_create_group(bluetooth_mesh_network_t *network,
443 bool is_virtual, uint16_t grp_addr,
444 bluetooth_mesh_network_group_info_t *info);
447 * Remove a group in a network
449 int bluetooth_mesh_network_remove_group(bluetooth_mesh_network_t *network,
450 bluetooth_mesh_network_group_info_t *req);
453 * Configure a Mesh group to a Mesh odel
455 int bluetooth_mesh_model_configure_group_sub(
456 bluetooth_mesh_model_configure_t *req);
459 * Confgure Virtual group to a Mesh Model
461 int bluetooth_mesh_model_configure_virtual_group_sub(
462 bluetooth_mesh_model_configure_t *req);
465 * Set Publication Information to a model of a node
467 int bluetooth_mesh_model_set_publication(bluetooth_mesh_model_configure_t *req);
470 * Get Publication Information from a model of a node
472 int bluetooth_mesh_model_get_publication(bluetooth_mesh_model_configure_t *req);
475 * Browse Vendor specific features from node
477 int bluetooth_mesh_node_browse_vendor_features(bluetooth_mesh_node_features_t *req);
482 #endif /* __BLUETOOTH_MESH_API_H */