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];
196 } bluetooth_mesh_model_msg_t;
199 char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
202 char label_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH +1];
203 } bluetooth_mesh_network_group_info_t;
206 char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
207 char dev_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
208 uint16_t primary_unicast;
212 bluetooth_mesh_node_key_conf_e op;
213 } bluetooth_mesh_key_configure_t;
216 char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
217 char dev_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
218 } bluetooth_mesh_provisioning_request_t;
223 char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
224 char dev_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
227 } bluetooth_mesh_provisioning_result_t;
230 char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
233 } bluetooth_mesh_authentication_request_t;
236 char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
237 uint16_t primary_unicast;
238 uint16_t num_elements;
239 char dev_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
240 } bluetooth_mesh_node_info_t;
243 * Mesh Event handler callback
245 typedef void (*mesh_cb_func_ptr)(int, mesh_event_param_t *, void *);
250 int bluetooth_mesh_init(mesh_cb_func_ptr callback_ptr, void *user_data);
255 int bluetooth_mesh_deinit(void);
258 * Create Local Mesh Network
260 int bluetooth_mesh_network_create(const char *net_name,
261 bluetooth_mesh_node_t *node, uint16_t total_models,
262 bluetooth_mesh_model_t **models,
263 bluetooth_mesh_network_t *network);
267 * Destroy Local Network Configuration
269 int bluetooth_mesh_network_destroy(bluetooth_mesh_network_t *network);
272 * Unload Local network Configuration
274 int bluetooth_mesh_network_unload(bluetooth_mesh_network_t *network);
277 * Reset a remote Node & remove it from network
279 int bluetooth_mesh_node_reset(bluetooth_mesh_node_info_t *node);
282 * Load already created Network
284 int bluetooth_mesh_network_load(const char *token,
285 bluetooth_mesh_network_t *network);
288 * Scan for Unprovisioned Devices
290 int bluetooth_mesh_network_scan(bluetooth_mesh_network_t *network,
291 bluetooth_mesh_scan_param_t *scan_param);
294 * Cancel the ongoing Scan
296 int bluetooth_mesh_network_cancel_scan(bluetooth_mesh_network_t *network);
299 * Set Local Network Provisioning Capabilities
301 int bluetooth_mesh_network_set_capabilities(
302 bluetooth_mesh_network_t *network,
303 bluetooth_mesh_provisioner_caps_t *caps);
308 int bluetooth_mesh_network_provision_device(
309 bluetooth_mesh_provisioning_request_t *req);
312 * Reply to Authentication request
314 int bluetooth_mesh_authentication_reply(int auth_type,
315 const char *auth_val, gboolean reply);
318 * Set Local Mesh Network name
320 int bluetooth_mesh_network_set_name(bluetooth_mesh_network_t *network);
323 * Add Subnet key in local Network
325 int bluetooth_mesh_network_add_netkey(bluetooth_mesh_network_t *network,
326 uint16_t *netkey_idx);
329 * Delete Subnet key in local Network
331 int bluetooth_mesh_network_delete_netkey(
332 bluetooth_mesh_network_t *network, uint16_t netkey_idx);
335 * Update Subnet key in local Network
337 int bluetooth_mesh_network_update_netkey(bluetooth_mesh_network_t *network,
338 uint16_t netkey_idx);
341 * Add Application Key in local Network
343 int bluetooth_mesh_network_add_appkey(bluetooth_mesh_network_t *network,
344 uint16_t netkey_idx, uint16_t *appkey_index);
347 * Update Application Key in local Network
349 int bluetooth_mesh_network_update_appkey(bluetooth_mesh_network_t *network,
350 uint16_t netkey_index, uint16_t appkey_idx);
353 * Delete Application Key in local Network
355 int bluetooth_mesh_network_delete_appkey(bluetooth_mesh_network_t *network,
356 uint16_t netkey_index, uint16_t appkey_idx);
359 * Get All Netkeys in Local Network
361 int bluetooth_mesh_network_get_all_netkey(bluetooth_mesh_network_t *network,
362 GPtrArray **netkeys);
365 * Get All Appkeys Bound to a Netkey in Local Network
368 int bluetooth_mesh_netkey_get_all_appkey(bluetooth_mesh_network_t *network,
369 uint16_t netkey_idx, GPtrArray **appkeys);
372 * Get All nodes's basic information, that are added in the local Network
374 int bluetooth_mesh_network_get_all_nodes(bluetooth_mesh_network_t *network,
378 * Get all Model information
380 int bluetooth_mesh_element_get_all_models(bluetooth_mesh_network_t *network,
381 uint16_t node_addr, int elem_idx, GPtrArray **models);
385 * Get All Netkeys bound to a node
387 int bluetooth_mesh_node_get_all_netkeys(bluetooth_mesh_node_discover_t *req,
388 GPtrArray **netkeys);
391 * Get All Application Keys bound to a node
393 int bluetooth_mesh_node_get_all_appkeys(bluetooth_mesh_node_discover_t *req,
394 GPtrArray **appkeys);
397 * Discover remote node exported informations (E.g: Models)
399 int bluetooth_mesh_browse_remote_node(bluetooth_mesh_node_discover_t *req);
402 * Configure Key to a node
404 int bluetooth_mesh_node_configure_key(bluetooth_mesh_key_configure_t *req);
407 * Confiure Appplication key to a model of a node
409 int bluetooth_mesh_model_configure_appkey(
410 bluetooth_mesh_model_configure_t *req);
413 * Send message to a model of a node
415 int bluetooth_mesh_model_send_msg(
416 bluetooth_mesh_model_msg_t *req);
419 * Get all application keys added to a model of a node
421 int bluetooth_mesh_model_get_all_appkeys(
422 bluetooth_mesh_model_configure_t *req);
425 * Get full subscription list added to a Model in a node
427 int bluetooth_mesh_model_get_subscriptopn_list(
428 bluetooth_mesh_model_configure_t *req);
431 * Get/Set Time To Live value of a node
433 int bluetooth_mesh_node_ttl_execute(
434 bluetooth_mesh_node_ttl_info_t *req);
437 * Get all groups available in local Network
439 int bluetooth_mesh_network_get_all_groups(
440 bluetooth_mesh_network_t *network,
444 * Create a group in a network
446 int bluetooth_mesh_network_create_group(bluetooth_mesh_network_t *network,
447 bool is_virtual, uint16_t grp_addr,
448 bluetooth_mesh_network_group_info_t *info);
451 * Remove a group in a network
453 int bluetooth_mesh_network_remove_group(bluetooth_mesh_network_t *network,
454 bluetooth_mesh_network_group_info_t *req);
457 * Configure a Mesh group to a Mesh odel
459 int bluetooth_mesh_model_configure_group_sub(
460 bluetooth_mesh_model_configure_t *req);
463 * Confgure Virtual group to a Mesh Model
465 int bluetooth_mesh_model_configure_virtual_group_sub(
466 bluetooth_mesh_model_configure_t *req);
469 * Set Publication Information to a model of a node
471 int bluetooth_mesh_model_set_publication(bluetooth_mesh_model_configure_t *req);
474 * Get Publication Information from a model of a node
476 int bluetooth_mesh_model_get_publication(bluetooth_mesh_model_configure_t *req);
479 * Browse Vendor specific features from node
481 int bluetooth_mesh_node_browse_vendor_features(bluetooth_mesh_node_features_t *req);
486 #endif /* __BLUETOOTH_MESH_API_H */