2 * Open Adaptation Layer (OAL)
4 * Copyright (c) 2019 -2020 Samsung Electronics Co., Ltd All Rights Reserved.
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.
25 #include <oal-manager.h>
27 /* Start of BLE Mesh structures and enum declarations */
29 #define OAL_MESH_DEVKEY_MSG_BUF_MAX 2048
30 #define OAL_MESH_MSG_BUF_MAX 2048
32 /* Mesh Key Operation Enums (For Appkey & NetKey) */
39 /* Mesh Authentication types */
41 /*< Output authentication request types */
42 OAL_MESH_AUTH_ALPHANUMERIC_DISPLAY = 0,
43 OAL_MESH_AUTH_NUMERIC_DISPLAY,
44 OAL_MESH_AUTH_PUSH_COUNT_DISPLAY,
45 OAL_MESH_AUTH_TWIST_COUNT_DISPLAY,
47 /*< Input authentication request types */
48 OAL_MESH_AUTH_REQ_ALPHANUMERIC_INPUT,
49 OAL_MESH_AUTH_REQ_NUMERIC_INPUT,
50 OAL_MESH_AUTH_REQ_BLINK_COUNT_INPUT,
51 OAL_MESH_AUTH_REQ_BEEP_COUNT_INPUT,
52 OAL_MESH_AUTH_REQ_VIBRATE_COUNT_INPUT,
54 /**< OOB Key Inputs */
55 OAL_MESH_AUTH_REQ_OOB_PUBLIC_KEY_INPUT,
56 OAL_MESH_AUTH_REQ_OOB_STATIC_KEY_INPUT
57 } oal_mesh_variant_authentication_e;
59 /* Mesh Enumerations of 2 octet OUT OOB Actions */
61 OAL_MESH_OUT_OOB_METHOD_BLINK = 0x01,
62 OAL_MESH_OUT_OOB_METHOD_BEEP = 0x02,
63 OAL_MESH_OUT_OOB_METHOD_VIBRATE = 0x04,
64 OAL_MESH_OUT_OOB_METHOD_NUMERIC = 0x08,
65 OAL_MESH_OUT_OOB_METHOD_ALPHANUMERIC = 0x10,
66 /* bit 5 ~ 15 : RFU */
67 } oal_mesh_output_oob_action_e;
69 /* Mesh Enumerations of 2 octet IN OOB Actions */
71 OAL_MESH_IN_OOB_METHOD_PUSH = 0x01,
72 OAL_MESH_IN_OOB_METHOD_TWIST = 0x02,
73 OAL_MESH_IN_OOB_METHOD_NUMERIC = 0x04,
74 OAL_MESH_IN_OOB_METHOD_ALPHANUMERIC = 0x08,
75 /* bit 4 ~ 15 : RFU */
76 } oal_mesh_input_oob_action_e;
78 /* Mesh strcuture of Mesh Provisioning Capabilities */
80 /**< Indicates Public Key for ECC Key exchange, can be fetched OOB */
82 /**< Indicates Static Key for authentication, can be fetched OOB */
84 /**< Indicates support for bitmap combination of OUT-OOB actions */
85 oal_mesh_output_oob_action_e out_oob;
86 /**< Indicates support for bitmap combination of IN-OOB actions */
87 oal_mesh_input_oob_action_e in_oob;
88 } oal_mesh_capabilities_t;
90 /* Mesh Unprovisioned Device Scan result */
94 /* 2-octet OOB info */
96 /* 4-octet URI Hash info */
98 } oal_mesh_scan_result_t;
100 /* Mesh Scan Parameters */
103 /* Structure may be expanded in future to support more scan parameters*/
104 } oal_mesh_scan_params_t;
106 /* Mesh Node Properties */
116 } oal_mesh_vendor_info_t;
118 /* Mesh Model: 2 bytes for BT SIG Model & 4 bytes for Vendor Model */
124 /* Mesh Element structure */
128 } oal_mesh_element_t;
130 /* Mesh Node structure */
132 oal_mesh_vendor_info_t vendor_info;
133 uint16_t num_elements;
134 uint16_t primary_unicast;
144 } event_mesh_network_proxy_added_t;
151 } event_mesh_network_attached_t;
157 } event_mesh_network_destroyed_t;
162 oal_mesh_scan_result_t result;
163 } event_mesh_scan_result_t;
168 } event_mesh_scan_status_t;
174 } event_mesh_provisioning_status_t;
179 } event_mesh_provisioning_data_requested_t;
183 oal_mesh_variant_authentication_e auth_type;
184 /* MAX length of Auth value is 50 */
185 char auth_value[50 + 1];
186 } event_mesh_authentication_requested_t;
195 } event_mesh_provisioning_finished_t;
200 oal_mesh_key_op_e op;
202 } event_mesh_netkey_operation_t;
207 oal_mesh_key_op_e op;
210 } event_mesh_appkey_operation_t;
214 /* Source means the node which sent the DevKey Message*/
219 uint8_t data[OAL_MESH_DEVKEY_MSG_BUF_MAX];
220 } event_mesh_devkey_message_t;
225 uint16_t source; /* address of remote element which sent msg */
226 uint16_t dest; /* address of local element which received msg*/
229 uint8_t data[OAL_MESH_MSG_BUF_MAX];
230 } event_mesh_message_t;
234 * @brief Enables Bluetooth Mesh Stack
236 * @remarks Application will be able to BLE Mesh features.
237 * @remarks Initializes Bluetooth Mesh HAL interface.
240 oal_status_t mesh_enable(void);
243 * @brief Disables Bluetooth Mesh Stack
245 * @remarks De-Initializes Bluetooth Mesh HAL interface.
246 * @remarks Application will not be able to BLE Mesh features.
248 * @pre OAL API should be enabled with mesh_enable().
252 oal_status_t mesh_disable(void);
255 * @brief Register the BLE Mesh Node
257 * @remarks Application will register the Mesh Provisioner node
260 * @pre OAl API should be enabled with mesh_enable().
264 oal_status_t mesh_register_node(oal_mesh_node_t *node,
265 GSList *model_list, bool is_provisioner);
269 * @brief Destroy or leave Network
271 * @remarks Stack will remove the local node entry
273 * @pre OAl API should be enabled with mesh_enable().
276 * @see mesh_register_node()
278 oal_status_t mesh_network_destroy(oal_uuid_t* network_uuid);
281 * @brief Cancel ongoing Join Request
283 * @remark Stack will remove the local node entry
285 * @pre OAL API should be enabled with mesh_enable().
289 oal_status_t mesh_cancel_join(oal_uuid_t* node_uuid);
292 * @brief Request Stack to release Network resources
294 * @remarks Stack will remove only yhe DBUS resources of local node
296 * @pre OAl API should be enabled with mesh_enable().
299 * @see mesh_register_node()
301 oal_status_t mesh_network_release(oal_uuid_t* network_uuid);
304 * @brief Delete Remote Node configuration
306 * @remarks Stack will remove the Remote node entry
308 * @pre OAl API should be enabled with mesh_enable().
312 oal_status_t mesh_delete_remote_node(oal_uuid_t* network_uuid,
313 uint16_t unicast, uint16_t num_elements);
316 * @brief UnRegister the BLE Mesh Node
318 * @remarks Application will unregister the Mesh Provisioner
319 * node or Device node
321 * @pre OAl API should be enabled with mesh_enable().
324 * @see mesh_register_node()
326 oal_status_t mesh_deregister_node(oal_mesh_node_t *node);
329 * @brief Local Network Subnet Operations by Mesh Provisioner Node
331 * @remarks Application can Create/Delete/Update subnets in
334 * @pre OAl API should be enabled with mesh_enable().
337 * @see mesh_network_subnet_execute()
339 oal_status_t mesh_network_subnet_execute(oal_uuid_t* network_uuid,
340 oal_mesh_key_op_e operation, uint16_t net_index);
343 * @brief Local Network Appkey Operations by Mesh Provisioner Node
345 * @remarks Application can Create/Delete/Update Appkeys, bound to
346 * netkeys in local key database
348 * @pre OAl API should be enabled with mesh_enable().
351 * @see mesh_network_subnet_execute()
352 * @see mesh_network_subnet_execute()
354 oal_status_t mesh_network_appkey_execute(oal_uuid_t* network_uuid,
355 oal_mesh_key_op_e operation,
356 uint16_t net_index, uint16_t app_index);
359 * @brief Discover unprovisioned device
361 * @remarks Provisioner application can discover Unprovisioned Device
362 * beaons which want to Join Mesh network
363 * @remarks scan params structure is defined for forward compatibility.
364 * Currently only single parameter (seconds) is supported
366 * @pre OAl API should be enabled with mesh_enable().
369 * @see mesh_network_start_scan()
371 oal_status_t mesh_network_start_scan(oal_uuid_t* network_uuid,
372 oal_mesh_scan_params_t *params);
375 * @brief Cancel unprovisionined Device scanning
378 * @see mesh_network_start_scan()
380 oal_status_t mesh_network_scan_cancel(oal_uuid_t* network_uuid);
383 * @brief Set Provisioning capabilities
385 * @remarks Provisioner application should set the capabilities
386 * before initiating device provision. Provisioning parameters are
387 * chosen based on combination of provisioner & device's capabilities
389 * @pre OAl API should be enabled with mesh_enable().
393 oal_status_t mesh_network_set_provisioning_capabilities(
394 oal_uuid_t *network_uuid, oal_mesh_capabilities_t *caps);
397 * @brief Security provision a device to Mesh Network
399 * @remarks Provisioner application can provision device after
400 * scanning for device beacons.
401 * @remarks Provisioner application should set the Provisioning
402 * capabilities before starting provision.
404 * @pre OAl API should be enabled with mesh_enable().
407 * @see mesh_network_set_provisioning_capabilities()
408 * @see mesh_network_provision_device()
410 oal_status_t mesh_network_provision_device(oal_uuid_t* network_uuid,
411 oal_uuid_t *dev_uuid);
415 * @brief Send data for provisioning like NetKey, Primary unicast
419 oal_status_t mesh_network_send_provisioning_data(oal_uuid_t* network_uuid,
420 uint16_t netkey_idx, uint16_t unicast);
423 * @brief Send Reply to Ongoing Security Provisioning
425 * @remarks Tizen supports only one Provisioning or Join
426 * Call simulatneously.
428 * @pre OAl API should be enabled with mesh_enable().
431 * @see mesh_network_provision_device()
432 * @see cb_mesh_authentication_request()
434 oal_status_t mesh_authentication_reply(oal_mesh_variant_authentication_e type,
435 const char* auth_value);
438 * @brief Cancels an ongoing security provisioning
440 * @remarks Mesh stack does not support Cancelling Ongoing
441 * provisiong currently.
443 * @pre OAl API should be enabled with mesh_enable().
446 * @see mesh_network_provision_device()
448 oal_status_t mesh_provisioning_cancel(oal_uuid_t *local_device_uuid);
451 * @brief Sends Configuration Client message originated from Local Node
453 * @remarks Local Configuration client can send message to both local
454 * & remote Configuration Server.
456 * @pre OAl API should be enabled with mesh_enable().
459 * @see cb_mesh_conf_message()
461 oal_status_t mesh_conf_send_message(oal_uuid_t *network_uuid,
462 uint16_t dest, bool is_devkey_remote,
463 uint16_t netkey_idx, uint8_t *buf, int len);
466 * @brief Sends Configuration Client Key (NetKey & AppKey Add/Update)
467 * messages originated from Local Node
469 * @remarks Local Configuration client can send message to both
470 * local & remote Configuration Server.
472 * @pre OAl API should be enabled with mesh_enable().
475 * @see cb_mesh_conf_message()
477 oal_status_t mesh_conf_send_key_message(oal_uuid_t *network_uuid,
478 uint16_t dest, bool is_netkey,
479 bool is_update, int key_idx, int netkey_idx);
483 * @brief Sends Application message to be encrypted with appplication key
485 * @remarks These messages are generated by Models, which are
486 * implemented by Tizen Application.
487 * @remarks Tizen Mesh Framework will not handle these mesages directly
488 * and only transport these to and from application.
490 * @pre OAl API should be enabled with mesh_enable().
493 * @see cb_mesh_model_message()
495 oal_status_t mesh_model_send_message(oal_uuid_t *network_uuid,
496 uint16_t dest, uint16_t appkey_idx, uint8_t *buf, int len);
498 #endif /* OAL_MESH_H_ */