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
31 /* Mesh Key Operation Enums (For Appkey & NetKey) */
38 /* Mesh Authentication types */
40 /*< Output authentication request types */
41 OAL_MESH_AUTH_ALPHANUMERIC_DISPLAY = 0,
42 OAL_MESH_AUTH_NUMERIC_DISPLAY,
43 OAL_MESH_AUTH_PUSH_COUNT_DISPLAY,
44 OAL_MESH_AUTH_TWIST_COUNT_DISPLAY,
46 /*< Input authentication request types */
47 OAL_MESH_AUTH_REQ_ALPHANUMERIC_INPUT,
48 OAL_MESH_AUTH_REQ_NUMERIC_INPUT,
49 OAL_MESH_AUTH_REQ_BLINK_COUNT_INPUT,
50 OAL_MESH_AUTH_REQ_BEEP_COUNT_INPUT,
51 OAL_MESH_AUTH_REQ_VIBRATE_COUNT_INPUT,
53 /**< OOB Key Inputs */
54 OAL_MESH_AUTH_REQ_OOB_PUBLIC_KEY_INPUT,
55 OAL_MESH_AUTH_REQ_OOB_STATIC_KEY_INPUT
56 } oal_mesh_variant_authentication_e;
58 /* Mesh Enumerations of 2 octet OUT OOB Actions */
60 OAL_MESH_OUT_OOB_METHOD_BLINK = 0x01,
61 OAL_MESH_OUT_OOB_METHOD_BEEP = 0x02,
62 OAL_MESH_OUT_OOB_METHOD_VIBRATE = 0x04,
63 OAL_MESH_OUT_OOB_METHOD_NUMERIC = 0x08,
64 OAL_MESH_OUT_OOB_METHOD_ALPHANUMERIC = 0x10,
65 /* bit 5 ~ 15 : RFU */
66 } oal_mesh_output_oob_action_e;
68 /* Mesh Enumerations of 2 octet IN OOB Actions */
70 OAL_MESH_IN_OOB_METHOD_PUSH = 0x01,
71 OAL_MESH_IN_OOB_METHOD_TWIST = 0x02,
72 OAL_MESH_IN_OOB_METHOD_NUMERIC = 0x04,
73 OAL_MESH_IN_OOB_METHOD_ALPHANUMERIC = 0x08,
74 /* bit 4 ~ 15 : RFU */
75 } oal_mesh_input_oob_action_e;
77 /* Mesh strcuture of Mesh Provisioning Capabilities */
79 /**< Indicates Public Key for ECC Key exchange, can be fetched OOB */
81 /**< Indicates Static Key for authentication, can be fetched OOB */
83 /**< Indicates support for bitmap combination of OUT-OOB actions */
84 oal_mesh_output_oob_action_e out_oob;
85 /**< Indicates support for bitmap combination of IN-OOB actions */
86 oal_mesh_input_oob_action_e in_oob;
87 } oal_mesh_capabilities_t;
89 /* Mesh Unprovisioned Device Scan result */
93 /* 2-octet OOB info */
95 /* 4-octet URI Hash info */
97 } oal_mesh_scan_result_t;
99 /* Mesh Scan Parameters */
102 /* Structure may be expanded in future to support more scan parameters*/
103 } oal_mesh_scan_params_t;
105 /* Mesh Node Properties */
115 } oal_mesh_vendor_info_t;
117 /* Mesh Model: 2 bytes for BT SIG Model & 4 bytes for Vendor Model */
123 /* Mesh Element structure */
127 } oal_mesh_element_t;
129 /* Mesh Node structure */
131 oal_mesh_vendor_info_t vendor_info;
132 uint16_t num_elements;
133 uint16_t primary_unicast;
145 } event_mesh_network_attached_t;
150 oal_mesh_scan_result_t result;
151 } event_mesh_scan_result_t;
156 } event_mesh_scan_status_t;
162 } event_mesh_provisioning_status_t;
167 } event_mesh_provisioning_data_requested_t;
171 oal_mesh_variant_authentication_e auth_type;
172 /* MAX length of Auth value is 50 */
173 char auth_value[50 + 1];
174 } event_mesh_authentication_requested_t;
183 } event_mesh_provisioning_finished_t;
188 oal_mesh_key_op_e op;
190 } event_mesh_netkey_operation_t;
195 oal_mesh_key_op_e op;
198 } event_mesh_appkey_operation_t;
202 /* Source means the node which sent the DevKey Message*/
207 uint8_t data[OAL_MESH_DEVKEY_MSG_BUF_MAX];
208 } event_mesh_devkey_message_t;
211 * @brief Enables Bluetooth Mesh Stack
213 * @remarks Application will be able to BLE Mesh features.
214 * @remarks Initializes Bluetooth Mesh HAL interface.
217 oal_status_t mesh_enable(void);
220 * @brief Disables Bluetooth Mesh Stack
222 * @remarks De-Initializes Bluetooth Mesh HAL interface.
223 * @remarks Application will not be able to BLE Mesh features.
225 * @pre OAL API should be enabled with mesh_enable().
229 oal_status_t mesh_disable(void);
232 * @brief Register the BLE Mesh Node
234 * @remarks Application will register the Mesh Provisioner node
237 * @pre OAl API should be enabled with mesh_enable().
241 oal_status_t mesh_register_node(oal_mesh_node_t *node,
242 GSList *model_list, bool is_provisioner);
245 * @brief UnRegister the BLE Mesh Node
247 * @remarks Application will unregister the Mesh Provisioner
248 * node or Device node
250 * @pre OAl API should be enabled with mesh_enable().
253 * @see mesh_register_node()
255 oal_status_t mesh_deregister_node(oal_mesh_node_t *node);
258 * @brief Local Network Subnet Operations by Mesh Provisioner Node
260 * @remarks Application can Create/Delete/Update subnets in
263 * @pre OAl API should be enabled with mesh_enable().
266 * @see mesh_network_subnet_execute()
268 oal_status_t mesh_network_subnet_execute(oal_uuid_t* network_uuid,
269 oal_mesh_key_op_e operation, uint16_t net_index);
272 * @brief Local Network Appkey Operations by Mesh Provisioner Node
274 * @remarks Application can Create/Delete/Update Appkeys, bound to
275 * netkeys in local key database
277 * @pre OAl API should be enabled with mesh_enable().
280 * @see mesh_network_subnet_execute()
281 * @see mesh_network_subnet_execute()
283 oal_status_t mesh_network_appkey_execute(oal_uuid_t* network_uuid,
284 oal_mesh_key_op_e operation,
285 uint16_t net_index, uint16_t app_index);
288 * @brief Discover unprovisioned device
290 * @remarks Provisioner application can discover Unprovisioned Device
291 * beaons which want to Join Mesh network
292 * @remarks scan params structure is defined for forward compatibility.
293 * Currently only single parameter (seconds) is supported
295 * @pre OAl API should be enabled with mesh_enable().
298 * @see mesh_network_start_scan()
300 oal_status_t mesh_network_start_scan(oal_uuid_t* network_uuid,
301 oal_mesh_scan_params_t *params);
304 * @brief Cancel unprovisionined Device scanning
307 * @see mesh_network_start_scan()
309 oal_status_t mesh_network_scan_cancel(oal_uuid_t* network_uuid);
312 * @brief Set Provisioning capabilities
314 * @remarks Provisioner application should set the capabilities
315 * before initiating device provision. Provisioning parameters are
316 * chosen based on combination of provisioner & device's capabilities
318 * @pre OAl API should be enabled with mesh_enable().
322 oal_status_t mesh_network_set_provisioning_capabilities(
323 oal_uuid_t *network_uuid, oal_mesh_capabilities_t *caps);
326 * @brief Security provision a device to Mesh Network
328 * @remarks Provisioner application can provision device after
329 * scanning for device beacons.
330 * @remarks Provisioner application should set the Provisioning
331 * capabilities before starting provision.
333 * @pre OAl API should be enabled with mesh_enable().
336 * @see mesh_network_set_provisioning_capabilities()
337 * @see mesh_network_provision_device()
339 oal_status_t mesh_network_provision_device(oal_uuid_t* network_uuid,
340 oal_uuid_t *dev_uuid);
344 * @brief Send data for provisioning like NetKey, Primary unicast
348 oal_status_t mesh_network_send_provisioning_data(oal_uuid_t* network_uuid,
349 uint16_t netkey_idx, uint16_t unicast);
352 * @brief Send Reply to Ongoing Security Provisioning
354 * @remarks Tizen supports only one Provisioning or Join
355 * Call simulatneously.
357 * @pre OAl API should be enabled with mesh_enable().
360 * @see mesh_network_provision_device()
361 * @see cb_mesh_authentication_request()
363 oal_status_t mesh_authentication_reply(oal_mesh_variant_authentication_e type,
364 const char* auth_value);
367 * @brief Cancels an ongoing security provisioning
369 * @remarks Mesh stack does not support Cancelling Ongoing
370 * provisiong currently.
372 * @pre OAl API should be enabled with mesh_enable().
375 * @see mesh_network_provision_device()
377 oal_status_t mesh_provisioning_cancel(oal_uuid_t *local_device_uuid);
380 * @brief Sends Configuration Client message originated from Local Node
382 * @remarks Local Configuration client can send message to both local
383 * & remote Configuration Server.
385 * @pre OAl API should be enabled with mesh_enable().
388 * @see cb_mesh_conf_message()
390 oal_status_t mesh_conf_send_message(oal_uuid_t *network_uuid,
391 uint16_t dest, bool is_devkey_remote,
392 uint16_t netkey_idx, uint8_t *buf, int len);
395 * @brief Sends Configuration Client Key (NetKey & AppKey Add/Update)
396 * messages originated from Local Node
398 * @remarks Local Configuration client can send message to both
399 * local & remote Configuration Server.
401 * @pre OAl API should be enabled with mesh_enable().
404 * @see cb_mesh_conf_message()
406 oal_status_t mesh_conf_send_key_message(oal_uuid_t *network_uuid,
407 uint16_t dest, bool is_netkey,
408 bool is_update, int key_idx, int netkey_idx);
412 * @brief Sends Application message to be encrypted with appplication key
414 * @remarks These messages are generated by Models, which are
415 * implemenetd by Tizen Application.
416 * @remarks Tizen Mesh Framework will not handle these mesages directly
417 * and only transport these to and from application.
419 * @pre OAl API should be enabled with mesh_enable().
422 * @see cb_mesh_model_message()
424 oal_status_t mesh_model_send_message(oal_uuid_t *network_uuid,
425 uint16_t dest, int appkey_idx,
426 int netkey_idx, uint8_t *buf, int len);
428 #endif /* OAL_MESH_H_ */