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);
261 int bluetooth_mesh_network_destroy(bluetooth_mesh_network_t *network);
264 * Reset a remote Node & remove it from network
266 int bluetooth_mesh_node_reset(bluetooth_mesh_node_info_t *node);
269 * Load already created Network
271 int bluetooth_mesh_network_load(const char *token,
272 bluetooth_mesh_network_t *network);
275 * Scan for Unprovisioned Devices
277 int bluetooth_mesh_network_scan(bluetooth_mesh_network_t *network,
278 bluetooth_mesh_scan_param_t *scan_param);
281 * Cancel the ongoing Scan
283 int bluetooth_mesh_network_cancel_scan(bluetooth_mesh_network_t *network);
286 * Set Local Network Provisioning Capabilities
288 int bluetooth_mesh_network_set_capabilities(
289 bluetooth_mesh_network_t *network,
290 bluetooth_mesh_provisioner_caps_t *caps);
295 int bluetooth_mesh_network_provision_device(
296 bluetooth_mesh_provisioning_request_t *req);
299 * Reply to Authentication request
301 int bluetooth_mesh_authentication_reply(int auth_type,
302 const char *auth_val, gboolean reply);
305 * Set Local Mesh Network name
307 int bluetooth_mesh_network_set_name(bluetooth_mesh_network_t *network);
310 * Add Subnet key in local Network
312 int bluetooth_mesh_network_add_netkey(bluetooth_mesh_network_t *network,
313 uint16_t *netkey_idx);
316 * Delete Subnet key in local Network
318 int bluetooth_mesh_network_delete_netkey(
319 bluetooth_mesh_network_t *network, uint16_t netkey_idx);
322 * Update Subnet key in local Network
324 int bluetooth_mesh_network_update_netkey(bluetooth_mesh_network_t *network,
325 uint16_t netkey_idx);
328 * Add Application Key in local Network
330 int bluetooth_mesh_network_add_appkey(bluetooth_mesh_network_t *network,
331 uint16_t netkey_idx, uint16_t *appkey_index);
334 * Update Application Key in local Network
336 int bluetooth_mesh_network_update_appkey(bluetooth_mesh_network_t *network,
337 uint16_t netkey_index, uint16_t appkey_idx);
340 * Delete Application Key in local Network
342 int bluetooth_mesh_network_delete_appkey(bluetooth_mesh_network_t *network,
343 uint16_t netkey_index, uint16_t appkey_idx);
346 * Get All Netkeys in Local Network
348 int bluetooth_mesh_network_get_all_netkey(bluetooth_mesh_network_t *network,
349 GPtrArray **netkeys);
352 * Get All Appkeys Bound to a Netkey in Local Network
355 int bluetooth_mesh_netkey_get_all_appkey(bluetooth_mesh_network_t *network,
356 uint16_t netkey_idx, GPtrArray **appkeys);
359 * Get All nodes's basic information, that are added in the local Network
361 int bluetooth_mesh_network_get_all_nodes(bluetooth_mesh_network_t *network,
365 * Get all Model information
367 int bluetooth_mesh_element_get_all_models(bluetooth_mesh_network_t *network,
368 uint16_t node_addr, int elem_idx, GPtrArray **models);
372 * Get All Netkeys bound to a node
374 int bluetooth_mesh_node_get_all_netkeys(bluetooth_mesh_node_discover_t *req,
375 GPtrArray **netkeys);
378 * Get All Application Keys bound to a node
380 int bluetooth_mesh_node_get_all_appkeys(bluetooth_mesh_node_discover_t *req,
381 GPtrArray **appkeys);
384 * Discover remote node exported informations (E.g: Models)
386 int bluetooth_mesh_browse_remote_node(bluetooth_mesh_node_discover_t *req);
389 * Configure Key to a node
391 int bluetooth_mesh_node_configure_key(bluetooth_mesh_key_configure_t *req);
394 * Confiure Appplication key to a model of a node
396 int bluetooth_mesh_model_configure_appkey(
397 bluetooth_mesh_model_configure_t *req);
400 * Send message to a model of a node
402 int bluetooth_mesh_model_send_msg(
403 bluetooth_mesh_model_msg_t *req);
406 * Get all application keys added to a model of a node
408 int bluetooth_mesh_model_get_all_appkeys(
409 bluetooth_mesh_model_configure_t *req);
412 * Get full subscription list added to a Model in a node
414 int bluetooth_mesh_model_get_subscriptopn_list(
415 bluetooth_mesh_model_configure_t *req);
418 * Get/Set Time To Live value of a node
420 int bluetooth_mesh_node_ttl_execute(
421 bluetooth_mesh_node_ttl_info_t *req);
424 * Get all groups available in local Network
426 int bluetooth_mesh_network_get_all_groups(
427 bluetooth_mesh_network_t *network,
431 * Create a group in a network
433 int bluetooth_mesh_network_create_group(bluetooth_mesh_network_t *network,
434 bool is_virtual, uint16_t grp_addr,
435 bluetooth_mesh_network_group_info_t *info);
438 * Remove a group in a network
440 int bluetooth_mesh_network_remove_group(bluetooth_mesh_network_t *network,
441 bluetooth_mesh_network_group_info_t *req);
444 * Configure a Mesh group to a Mesh odel
446 int bluetooth_mesh_model_configure_group_sub(
447 bluetooth_mesh_model_configure_t *req);
450 * Confgure Virtual group to a Mesh Model
452 int bluetooth_mesh_model_configure_virtual_group_sub(
453 bluetooth_mesh_model_configure_t *req);
456 * Set Publication Information to a model of a node
458 int bluetooth_mesh_model_set_publication(bluetooth_mesh_model_configure_t *req);
461 * Get Publication Information from a model of a node
463 int bluetooth_mesh_model_get_publication(bluetooth_mesh_model_configure_t *req);
466 * Browse Vendor specific features from node
468 int bluetooth_mesh_node_browse_vendor_features(bluetooth_mesh_node_features_t *req);
473 #endif /* __BLUETOOTH_MESH_API_H */