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;
82 } bluetooth_mesh_vendor_info_t;
89 } bluetooth_mesh_features_t;
92 bluetooth_mesh_vendor_info_t vendor_info;
93 uint16_t num_elements;
94 uint16_t primary_unicast;
100 } bluetooth_mesh_node_t;
104 char token[BLUETOOTH_MESH_NETWORK_TOKEN_STRING_LENGTH +1];
105 } bluetooth_mesh_token_t;
108 char name[BLUETOOTH_MESH_NETWORK_NAME_STRING_MAX +1];
109 } bluetooth_mesh_network_name_t;
112 bluetooth_mesh_network_name_t name;
113 bluetooth_mesh_token_t token;
114 char uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
115 char app_cred[BLUETOOTH_MESH_APP_UNIQUE_CRED_STRING_LENGTH + 1];
116 } bluetooth_mesh_network_t;
119 char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
121 char dev_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
124 } bluetooth_mesh_scan_result_t;
128 } bluetooth_mesh_scan_param_t;
136 } bluetooth_mesh_provisioner_caps_t;
139 char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
140 char dev_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
144 } bluetooth_mesh_node_discover_t;
147 char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
148 char dev_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
151 bluetooth_mesh_vendor_info_t vendor_info;
152 bluetooth_mesh_features_t features;
153 } bluetooth_mesh_node_features_t;
156 char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
160 } bluetooth_mesh_node_ttl_info_t;
163 char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
164 uint16_t primary_unicast;
169 uint16_t **appkey_list;
170 int appkeylist_count;
173 /* For Subscription Configuration */
174 bluetooth_mesh_model_sub_op_e op;
180 /* For Publication Configuration */
185 } bluetooth_mesh_model_configure_t;
188 char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
189 uint16_t primary_unicast;
195 char msg[BLUETOOTH_MESH_MODEL_MSG_LENGTH_MAX + 1];
197 } bluetooth_mesh_model_msg_t;
200 char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
203 char label_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH +1];
204 } bluetooth_mesh_network_group_info_t;
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 primary_unicast;
213 bluetooth_mesh_node_key_conf_e op;
214 } bluetooth_mesh_key_configure_t;
217 char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
218 char dev_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
219 } bluetooth_mesh_provisioning_request_t;
224 char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
225 char dev_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
228 } bluetooth_mesh_provisioning_result_t;
231 char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
234 } bluetooth_mesh_authentication_request_t;
237 char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
238 uint16_t primary_unicast;
239 uint16_t num_elements;
240 char dev_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
241 } bluetooth_mesh_node_info_t;
244 * Mesh Event handler callback
246 typedef void (*mesh_cb_func_ptr)(int, mesh_event_param_t *, void *);
251 int bluetooth_mesh_init(mesh_cb_func_ptr callback_ptr, void *user_data);
256 int bluetooth_mesh_deinit(void);
259 * Create Local Mesh Network
261 int bluetooth_mesh_network_create(const char *net_name,
262 bluetooth_mesh_node_t *node, uint16_t total_models,
263 bluetooth_mesh_model_t **models,
264 bluetooth_mesh_network_t *network);
268 * Destroy Local Network Configuration
270 int bluetooth_mesh_network_destroy(bluetooth_mesh_network_t *network);
273 * Unload Local network Configuration
275 int bluetooth_mesh_network_unload(bluetooth_mesh_network_t *network);
278 * Reset a remote Node & remove it from network
280 int bluetooth_mesh_node_reset(bluetooth_mesh_node_info_t *node);
283 * Load already created Network
285 int bluetooth_mesh_network_load(const char *token,
286 bluetooth_mesh_network_t *network);
289 * Create a Remote Unprovisioned Node
291 int bluetooth_mesh_network_join(bluetooth_mesh_node_t *node,
292 uint16_t total_models,
293 bluetooth_mesh_model_t **models);
296 * Cancel the ongoing request
298 int bluetooth_mesh_cancel_join(bluetooth_mesh_node_info_t *node);
301 * Scan for Unprovisioned Devices
303 int bluetooth_mesh_network_scan(bluetooth_mesh_network_t *network,
304 bluetooth_mesh_scan_param_t *scan_param);
307 * Cancel the ongoing Scan
309 int bluetooth_mesh_network_cancel_scan(bluetooth_mesh_network_t *network);
312 * Set Local Network Provisioning Capabilities
314 int bluetooth_mesh_network_set_capabilities(
315 bluetooth_mesh_network_t *network,
316 bluetooth_mesh_provisioner_caps_t *caps);
321 int bluetooth_mesh_network_provision_device(
322 bluetooth_mesh_provisioning_request_t *req);
325 * Reply to Authentication request
327 int bluetooth_mesh_authentication_reply(int auth_type,
328 const char *auth_val, gboolean reply);
331 * Set Local Mesh Network name
333 int bluetooth_mesh_network_set_name(bluetooth_mesh_network_t *network);
336 * Add Subnet key in local Network
338 int bluetooth_mesh_network_add_netkey(bluetooth_mesh_network_t *network,
339 uint16_t *netkey_idx);
342 * Delete Subnet key in local Network
344 int bluetooth_mesh_network_delete_netkey(
345 bluetooth_mesh_network_t *network, uint16_t netkey_idx);
348 * Update Subnet key in local Network
350 int bluetooth_mesh_network_update_netkey(bluetooth_mesh_network_t *network,
351 uint16_t netkey_idx);
354 * Add Application Key in local Network
356 int bluetooth_mesh_network_add_appkey(bluetooth_mesh_network_t *network,
357 uint16_t netkey_idx, uint16_t *appkey_index);
360 * Update Application Key in local Network
362 int bluetooth_mesh_network_update_appkey(bluetooth_mesh_network_t *network,
363 uint16_t netkey_index, uint16_t appkey_idx);
366 * Delete Application Key in local Network
368 int bluetooth_mesh_network_delete_appkey(bluetooth_mesh_network_t *network,
369 uint16_t netkey_index, uint16_t appkey_idx);
372 * Get All Netkeys in Local Network
374 int bluetooth_mesh_network_get_all_netkey(bluetooth_mesh_network_t *network,
375 GPtrArray **netkeys);
378 * Get All Appkeys Bound to a Netkey in Local Network
381 int bluetooth_mesh_netkey_get_all_appkey(bluetooth_mesh_network_t *network,
382 uint16_t netkey_idx, GPtrArray **appkeys);
385 * Get All nodes's basic information, that are added in the local Network
387 int bluetooth_mesh_network_get_all_nodes(bluetooth_mesh_network_t *network,
391 * Get all Model information
393 int bluetooth_mesh_element_get_all_models(bluetooth_mesh_network_t *network,
394 uint16_t node_addr, int elem_idx, GPtrArray **models);
398 * Get All Netkeys bound to a node
400 int bluetooth_mesh_node_get_all_netkeys(bluetooth_mesh_node_discover_t *req,
401 GPtrArray **netkeys);
404 * Get All Application Keys bound to a node
406 int bluetooth_mesh_node_get_all_appkeys(bluetooth_mesh_node_discover_t *req,
407 GPtrArray **appkeys);
410 * Discover remote node exported informations (E.g: Models)
412 int bluetooth_mesh_browse_remote_node(bluetooth_mesh_node_discover_t *req);
415 * Configure Key to a node
417 int bluetooth_mesh_node_configure_key(bluetooth_mesh_key_configure_t *req);
420 * Confiure Appplication key to a model of a node
422 int bluetooth_mesh_model_configure_appkey(
423 bluetooth_mesh_model_configure_t *req);
426 * Send message to a model of a node
428 int bluetooth_mesh_model_send_msg(
429 bluetooth_mesh_model_msg_t *req);
432 * Send response to provisioner node
434 int bluetooth_mesh_model_send_response(
435 bluetooth_mesh_model_msg_t *req);
438 * Get all application keys added to a model of a node
440 int bluetooth_mesh_model_get_all_appkeys(
441 bluetooth_mesh_model_configure_t *req);
444 * Get full subscription list added to a Model in a node
446 int bluetooth_mesh_model_get_subscriptopn_list(
447 bluetooth_mesh_model_configure_t *req);
450 * Get/Set Time To Live value of a node
452 int bluetooth_mesh_node_ttl_execute(
453 bluetooth_mesh_node_ttl_info_t *req);
456 * Get all groups available in local Network
458 int bluetooth_mesh_network_get_all_groups(
459 bluetooth_mesh_network_t *network,
463 * Create a group in a network
465 int bluetooth_mesh_network_create_group(bluetooth_mesh_network_t *network,
466 bool is_virtual, uint16_t grp_addr,
467 bluetooth_mesh_network_group_info_t *info);
470 * Remove a group in a network
472 int bluetooth_mesh_network_remove_group(bluetooth_mesh_network_t *network,
473 bluetooth_mesh_network_group_info_t *req);
476 * Configure a Mesh group to a Mesh odel
478 int bluetooth_mesh_model_configure_group_sub(
479 bluetooth_mesh_model_configure_t *req);
482 * Confgure Virtual group to a Mesh Model
484 int bluetooth_mesh_model_configure_virtual_group_sub(
485 bluetooth_mesh_model_configure_t *req);
488 * Set Publication Information to a model of a node
490 int bluetooth_mesh_model_set_publication(bluetooth_mesh_model_configure_t *req);
493 * Get Publication Information from a model of a node
495 int bluetooth_mesh_model_get_publication(bluetooth_mesh_model_configure_t *req);
498 * Browse Vendor specific features from node
500 int bluetooth_mesh_node_browse_vendor_features(bluetooth_mesh_node_features_t *req);
505 #endif /* __BLUETOOTH_MESH_API_H */