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
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;
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;
65 } bluetooth_mesh_model_t;
70 } bluetooth_mesh_element_t;
77 } bluetooth_mesh_vendor_info_t;
84 } bluetooth_mesh_features_t;
87 bluetooth_mesh_vendor_info_t vendor_info;
88 uint16_t num_elements;
89 uint16_t primary_unicast;
95 } bluetooth_mesh_node_t;
99 char token[BLUETOOTH_MESH_NETWORK_TOKEN_STRING_LENGTH +1];
100 } bluetooth_mesh_token_t;
103 char name[BLUETOOTH_MESH_NETWORK_NAME_STRING_MAX +1];
104 } bluetooth_mesh_network_name_t;
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;
114 char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
116 char dev_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
119 } bluetooth_mesh_scan_result_t;
123 } bluetooth_mesh_scan_param_t;
131 } bluetooth_mesh_provisioner_caps_t;
134 char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
135 char dev_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
139 } bluetooth_mesh_node_discover_t;
142 char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
143 char dev_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
146 bluetooth_mesh_vendor_info_t vendor_info;
147 bluetooth_mesh_features_t features;
148 } bluetooth_mesh_node_features_t;
151 char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
155 } bluetooth_mesh_node_ttl_info_t;
158 char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
159 uint16_t primary_unicast;
164 uint16_t **appkey_list;
165 int appkeylist_count;
168 /* For Subscription Configuration */
169 bluetooth_mesh_model_sub_op_e op;
175 /* For Publication Configuration */
180 } bluetooth_mesh_model_configure_t;
183 char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
186 char label_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH +1];
187 } bluetooth_mesh_network_group_info_t;
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;
196 bluetooth_mesh_node_key_conf_e op;
197 } bluetooth_mesh_key_configure_t;
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;
207 char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
208 char dev_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
211 } bluetooth_mesh_provisioning_result_t;
214 char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
217 } bluetooth_mesh_authentication_request_t;
220 uint16_t primary_unicast;
221 char dev_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
222 } bluetooth_mesh_node_info_t;
225 * Mesh Event handler callback
227 typedef void (*mesh_cb_func_ptr)(int, mesh_event_param_t *, void *);
232 int bluetooth_mesh_init(mesh_cb_func_ptr callback_ptr, void *user_data);
237 int bluetooth_mesh_deinit(void);
240 * Create Local Mesh Network
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);
248 * Load already created Network
250 int bluetooth_mesh_network_load(const char *token,
251 bluetooth_mesh_network_t *network);
254 * Scan for Unprovisioned Devices
256 int bluetooth_mesh_network_scan(bluetooth_mesh_network_t *network,
257 bluetooth_mesh_scan_param_t *scan_param);
260 * Cancel the ongoing Scan
262 int bluetooth_mesh_network_cancel_scan(bluetooth_mesh_network_t *network);
265 * Set Local Network Provisioning Capabilities
267 int bluetooth_mesh_network_set_capabilities(
268 bluetooth_mesh_network_t *network,
269 bluetooth_mesh_provisioner_caps_t *caps);
274 int bluetooth_mesh_network_provision_device(
275 bluetooth_mesh_provisioning_request_t *req);
278 * Reply to Authentication request
280 int bluetooth_mesh_authentication_reply(int auth_type,
281 const char *auth_val, gboolean reply);
284 * Set Local Mesh Network name
286 int bluetooth_mesh_network_set_name(bluetooth_mesh_network_t *network);
289 * Add Subnet key in local Network
291 int bluetooth_mesh_network_add_netkey(bluetooth_mesh_network_t *network,
292 uint16_t *netkey_idx);
295 * Delete Subnet key in local Network
297 int bluetooth_mesh_network_delete_netkey(
298 bluetooth_mesh_network_t *network, uint16_t netkey_idx);
301 * Update Subnet key in local Network
303 int bluetooth_mesh_network_update_netkey(bluetooth_mesh_network_t *network,
304 uint16_t netkey_idx);
307 * Add Application Key in local Network
309 int bluetooth_mesh_network_add_appkey(bluetooth_mesh_network_t *network,
310 uint16_t netkey_idx, uint16_t *appkey_index);
313 * Update Application Key in local Network
315 int bluetooth_mesh_network_update_appkey(bluetooth_mesh_network_t *network,
316 uint16_t netkey_index, uint16_t appkey_idx);
319 * Delete Application Key in local Network
321 int bluetooth_mesh_network_delete_appkey(bluetooth_mesh_network_t *network,
322 uint16_t netkey_index, uint16_t appkey_idx);
325 * Get All Netkeys in Local Network
327 int bluetooth_mesh_network_get_all_netkey(bluetooth_mesh_network_t *network,
328 GPtrArray **netkeys);
331 * Get All Appkeys Bound to a Netkey in Local Network
334 int bluetooth_mesh_netkey_get_all_appkey(bluetooth_mesh_network_t *network,
335 uint16_t netkey_idx, GPtrArray **appkeys);
338 * Get All nodes's basic information, that are added in the local Network
340 int bluetooth_mesh_network_get_all_nodes(bluetooth_mesh_network_t *network,
344 * Get all Model information
346 int bluetooth_mesh_element_get_all_models(bluetooth_mesh_network_t *network,
347 uint16_t node_addr, int elem_idx, GPtrArray **models);
351 * Get All Netkeys bound to a node
353 int bluetooth_mesh_node_get_all_netkeys(bluetooth_mesh_node_discover_t *req,
354 GPtrArray **netkeys);
357 * Get All Application Keys bound to a node
359 int bluetooth_mesh_node_get_all_appkeys(bluetooth_mesh_node_discover_t *req,
360 GPtrArray **appkeys);
363 * Discover remote node exported informations (E.g: Models)
365 int bluetooth_mesh_browse_remote_node(bluetooth_mesh_node_discover_t *req);
368 * Configure Key to a node
370 int bluetooth_mesh_node_configure_key(bluetooth_mesh_key_configure_t *req);
373 * Confiure Appplication key to a model of a node
375 int bluetooth_mesh_model_configure_appkey(
376 bluetooth_mesh_model_configure_t *req);
379 * Get all application keys added to a model of a node
381 int bluetooth_mesh_model_get_all_appkeys(
382 bluetooth_mesh_model_configure_t *req);
385 * Get full subscription list added to a Model in a node
387 int bluetooth_mesh_model_get_subscriptopn_list(
388 bluetooth_mesh_model_configure_t *req);
391 * Get/Set Time To Live value of a node
393 int bluetooth_mesh_node_ttl_execute(
394 bluetooth_mesh_node_ttl_info_t *req);
397 * Get all groups available in local Network
399 int bluetooth_mesh_network_get_all_groups(
400 bluetooth_mesh_network_t *network,
404 * Create a group in a network
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);
411 * Remove a group in a network
413 int bluetooth_mesh_network_remove_group(bluetooth_mesh_network_t *network,
414 bluetooth_mesh_network_group_info_t *req);
417 * Configure a Mesh group to a Mesh odel
419 int bluetooth_mesh_model_configure_group_sub(
420 bluetooth_mesh_model_configure_t *req);
423 * Confgure Virtual group to a Mesh Model
425 int bluetooth_mesh_model_configure_virtual_group_sub(
426 bluetooth_mesh_model_configure_t *req);
429 * Set Publication Information to a model of a node
431 int bluetooth_mesh_model_set_publication(bluetooth_mesh_model_configure_t *req);
434 * Get Publication Information from a model of a node
436 int bluetooth_mesh_model_get_publication(bluetooth_mesh_model_configure_t *req);
439 * Browse Vendor specific features from node
441 int bluetooth_mesh_node_browse_vendor_features(bluetooth_mesh_node_features_t *req);
446 #endif /* __BLUETOOTH_MESH_API_H */