Mesh: Add support for Node Reset in OAL & HAL
[platform/core/connectivity/bluetooth-frwk.git] / bt-oal / oal-mesh.c
1 /*
2  * Open Adaptation Layer (OAL)
3  *
4  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
5  *
6  * @author: Anupam Roy <anupam.r@samsung.com>
7  *
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
11  *
12  *              http://www.apache.org/licenses/LICENSE-2.0
13  *
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.
19  *
20  */
21 #include <dlog.h>
22 #include <bluetooth.h>
23 #include "bt_mesh.h"
24
25 #include "oal-event.h"
26 #include "oal-internal.h"
27 #include "oal-manager.h"
28 #include "oal-adapter-mgr.h"
29 #include "oal-utils.h"
30 #include "oal-mesh.h"
31 #include "oal-common.h"
32
33
34 static const bt_interface_t *blued_api;
35 static const btmesh_interface_t *mesh_api;
36
37 #define CHECK_OAL_MESH_ENABLED() \
38         do { \
39                 if (mesh_api == NULL) { \
40                         BT_ERR("Mesh Not Enabled"); \
41                         return OAL_STATUS_NOT_READY; \
42                 } \
43         } while (0)
44
45 /* Forward declaration: Callbacks from HAL */
46 static void mesh_network_attached_callback(bt_status_t status,
47                 bt_mesh_token_t *token, bt_uuid_t *uuid);
48 static void mesh_network_destroyed_callback(bt_status_t status,
49                 bt_mesh_token_t *token, bt_uuid_t *uuid);
50 static void mesh_network_scan_status_callback(bt_mesh_scan_state_t scan_state,
51                 bt_status_t status, bt_uuid_t *net_uuid);
52 static void mesh_network_scan_result_callback(bt_status_t status,
53                 bt_uuid_t *net_uuid, bt_mesh_scan_result_t *result);
54 static void mesh_network_provisioning_status_callback(bt_status_t status,
55                 bt_uuid_t *net_uuid, bt_uuid_t *dev_uuid);
56 static void mesh_network_provisioning_finished_callback(bt_status_t status,
57                 int reason, bt_uuid_t *net_uuid,
58                         bt_uuid_t *dev_uuid, uint16_t unicast, uint8_t count);
59 static void mesh_network_provisioning_data_requested_callback(
60                 bt_uuid_t *net_uuid, uint8_t count);
61 static void mesh_network_authentication_requested_callback(bt_uuid_t *net_uuid,
62                 bt_hal_mesh_auth_variant_e auth_type, char auth_value[]);
63 static void mesh_network_netkey_execute_callback(bt_status_t status,
64                 bt_uuid_t *net_uuid, uint8_t key_event, uint16_t netkey_idx);
65 static void mesh_network_appkey_execute_callback(bt_status_t status,
66                 bt_uuid_t *net_uuid, uint8_t key_event, uint16_t netkey_idx, uint16_t appkey_idx);
67 static void mesh_network_appkey_execute_callback(bt_status_t status,
68                 bt_uuid_t *net_uuid, uint8_t key_event, uint16_t netkey_idx, uint16_t appkey_idx);
69 static void mesh_devkey_message_received_callback(bt_uuid_t *net_uuid,
70                 uint16_t source_addr, bool is_remote_devkey,
71                         uint16_t netkey_idx, uint16_t ata_len, uint8_t *data);
72 static void mesh_message_received_callback(bt_uuid_t *net_uuid,
73                 uint16_t source_addr, uint16_t dest_addr,
74                 uint16_t key_idx, uint16_t data_len, uint8_t *data);
75
76
77 static btmesh_callbacks_t sBluetoothMeshCallbacks = {
78         .size = sizeof(sBluetoothMeshCallbacks),
79         .network_attached_cb = mesh_network_attached_callback,
80         .network_destroyed_cb = mesh_network_destroyed_callback,
81         .scan_status_cb = mesh_network_scan_status_callback,
82         .scan_result_cb = mesh_network_scan_result_callback,
83         .provisioning_status_cb = mesh_network_provisioning_status_callback,
84         .provisioning_finished_cb = mesh_network_provisioning_finished_callback,
85         .provisioning_data_requested_cb = mesh_network_provisioning_data_requested_callback,
86         .authentication_requested_cb = mesh_network_authentication_requested_callback,
87         .netkey_execute_cb = mesh_network_netkey_execute_callback,
88         .appkey_execute_cb = mesh_network_appkey_execute_callback,
89         .devkey_msg_cb = mesh_devkey_message_received_callback,
90         .msg_cb = mesh_message_received_callback,
91 };
92
93 /* Mesh HAL event handlers */
94 static void mesh_network_attached_callback(bt_status_t status,
95                 bt_mesh_token_t *token, bt_uuid_t *uuid)
96 {
97         event_mesh_network_attached_t *event = g_new0(event_mesh_network_attached_t, 1);
98
99         event->status = convert_to_oal_status(status);
100         BT_INFO("Mesh Event: Network Attached, status: [%s]",
101                 status2string(status));
102
103         memcpy(event->token, token->token, sizeof(bt_mesh_token_t));
104         memcpy(event->uuid.uuid, uuid->uu, sizeof(bt_uuid_t));
105
106         send_event_bda_trace(OAL_EVENT_MESH_NETWORK_ATTACHED,
107                 event, sizeof(event_mesh_network_attached_t), NULL);
108 }
109
110 static void mesh_network_destroyed_callback(bt_status_t status,
111                 bt_mesh_token_t *token, bt_uuid_t *uuid)
112 {
113         event_mesh_network_attached_t *event = g_new0(event_mesh_network_attached_t, 1);
114
115         event->status = convert_to_oal_status(status);
116         BT_INFO("Mesh Event: Network Destroyed, status: [%s]",
117                         status2string(status));
118
119         memcpy(event->token, token->token, sizeof(bt_mesh_token_t));
120         memcpy(event->uuid.uuid, uuid->uu, sizeof(bt_uuid_t));
121
122         send_event_bda_trace(OAL_EVENT_MESH_NETWORK_DESTROYED,
123                         event, sizeof(event_mesh_network_destroyed_t), NULL);
124 }
125
126 static void mesh_network_scan_status_callback(bt_mesh_scan_state_t scan_state,
127                 bt_status_t status, bt_uuid_t *net_uuid)
128 {
129         event_mesh_scan_status_t *event_data = g_new0(event_mesh_scan_status_t, 1);
130         oal_event_t event;
131
132         event_data->status = convert_to_oal_status(status);
133         BT_INFO("Mesh Event: Scan status: [%s] state [%d]",
134                 status2string(status), scan_state);
135
136         memcpy(event_data->net_uuid.uuid, net_uuid->uu, sizeof(bt_uuid_t));
137
138         event = (BT_MESH_SCAN_STARTED == scan_state) ? \
139                 OAL_EVENT_MESH_SCAN_STARTED : OAL_EVENT_MESH_SCAN_FINISHED;
140         send_event_bda_trace(event, event_data,
141                 sizeof(event_mesh_scan_status_t), NULL);
142 }
143
144 static void mesh_network_provisioning_status_callback(bt_status_t status,
145                 bt_uuid_t *net_uuid, bt_uuid_t *dev_uuid)
146 {
147         event_mesh_provisioning_status_t *event = g_new0(event_mesh_provisioning_status_t, 1);
148
149         event->status = convert_to_oal_status(status);
150         BT_INFO("Mesh Event: Provisioning status: [%s]",
151                 status2string(status));
152
153         memcpy(event->net_uuid.uuid, net_uuid->uu, sizeof(bt_uuid_t));
154         memcpy(event->dev_uuid.uuid, dev_uuid->uu, sizeof(bt_uuid_t));
155
156         if (event->status == OAL_STATUS_SUCCESS)
157                 send_event_bda_trace(OAL_EVENT_MESH_PROVISIONING_STARTED,
158                         event, sizeof(event_mesh_provisioning_status_t), NULL);
159         else
160                 send_event_bda_trace(OAL_EVENT_MESH_PROVISIONING_FAILED,
161                         event, sizeof(event_mesh_provisioning_status_t), NULL);
162 }
163
164 static void mesh_network_provisioning_finished_callback(bt_status_t status,
165                 int reason, bt_uuid_t *net_uuid,
166                         bt_uuid_t *dev_uuid, uint16_t unicast, uint8_t count)
167 {
168         event_mesh_provisioning_finished_t *event = \
169                 g_new0(event_mesh_provisioning_finished_t, 1);
170
171         event->status = convert_to_oal_status(status);
172         event->reason = reason;
173         BT_INFO("Mesh Event: Provisioning Completed Result: [%s]",
174                 status2string(status));
175
176         memcpy(event->net_uuid.uuid, net_uuid->uu, sizeof(bt_uuid_t));
177         memcpy(event->dev_uuid.uuid, dev_uuid->uu, sizeof(bt_uuid_t));
178         event->unicast = unicast;
179         event->count = count;
180
181         send_event_bda_trace(OAL_EVENT_MESH_PROVISIONING_FINISHED,
182                 event, sizeof(event_mesh_provisioning_finished_t), NULL);
183 }
184
185 static void mesh_network_provisioning_data_requested_callback(
186                 bt_uuid_t *net_uuid, uint8_t count)
187 {
188         event_mesh_provisioning_data_requested_t *event = \
189                 g_new0(event_mesh_provisioning_data_requested_t, 1);
190
191         BT_INFO("Mesh Event: Provisioning Data requested");
192
193         memcpy(event->net_uuid.uuid, net_uuid->uu, sizeof(bt_uuid_t));
194         event->count = count;
195
196         send_event_bda_trace(OAL_EVENT_MESH_PROVISIONING_DATA_REQUESTED,
197                 event, sizeof(event_mesh_provisioning_data_requested_t), NULL);
198 }
199
200 static void mesh_network_authentication_requested_callback(bt_uuid_t *net_uuid,
201                 bt_hal_mesh_auth_variant_e auth_type,
202                         char auth_value[])
203 {
204         event_mesh_authentication_requested_t *event = \
205                 g_new0(event_mesh_authentication_requested_t, 1);
206
207         BT_INFO("Mesh Event: Authentication requested");
208
209         memcpy(event->net_uuid.uuid, net_uuid->uu, sizeof(bt_uuid_t));
210         event->auth_type = auth_type;
211         g_strlcpy(event->auth_value, auth_value, sizeof(event->auth_value));
212
213         send_event_bda_trace(OAL_EVENT_MESH_AUTHENTICATION_REQUESTED,
214                 event, sizeof(event_mesh_provisioning_data_requested_t), NULL);
215 }
216
217 static void mesh_network_netkey_execute_callback(bt_status_t status,
218                 bt_uuid_t *net_uuid, uint8_t key_event, uint16_t index)
219 {
220         event_mesh_netkey_operation_t *event = \
221                 g_new0(event_mesh_netkey_operation_t, 1);
222
223         event->status = convert_to_oal_status(status);
224         BT_INFO("Mesh Event: NetKey Execute Event");
225
226         memcpy(event->net_uuid.uuid, net_uuid->uu, sizeof(bt_uuid_t));
227         event->op = (oal_mesh_key_op_e)key_event;
228         event->key_idx = index;
229
230         send_event_bda_trace(OAL_EVENT_MESH_NETKEY_EXECUTE_EVENT,
231                 event, sizeof(event_mesh_netkey_operation_t), NULL);
232 }
233
234 static void mesh_network_appkey_execute_callback(bt_status_t status,
235                 bt_uuid_t *net_uuid, uint8_t key_event,
236                         uint16_t net_idx, uint16_t app_idx)
237 {
238         event_mesh_appkey_operation_t *event = \
239                 g_new0(event_mesh_appkey_operation_t, 1);
240
241         event->status = convert_to_oal_status(status);
242         BT_INFO("Mesh Event: AppKey Execute Event");
243
244         memcpy(event->net_uuid.uuid, net_uuid->uu, sizeof(bt_uuid_t));
245         event->op = (oal_mesh_key_op_e)key_event;
246         event->net_idx = net_idx;
247         event->app_idx = app_idx;
248
249         send_event_bda_trace(OAL_EVENT_MESH_APPKEY_EXECUTE_EVENT,
250                 event, sizeof(event_mesh_appkey_operation_t), NULL);
251 }
252
253 static void mesh_network_scan_result_callback(bt_status_t status,
254                 bt_uuid_t *net_uuid, bt_mesh_scan_result_t *result)
255 {
256         event_mesh_scan_result_t *event = g_new0(event_mesh_scan_result_t, 1);
257
258         event->status = convert_to_oal_status(status);
259         BT_INFO("Mesh Event: Scan Result status: [%s]",
260                 status2string(status));
261
262         memcpy(event->net_uuid.uuid, net_uuid->uu, sizeof(bt_uuid_t));
263         memcpy(&event->result, result, sizeof(bt_mesh_scan_result_t));
264
265         send_event_bda_trace(OAL_EVENT_MESH_SCAN_RESULT,
266                 event, sizeof(event_mesh_scan_result_t), NULL);
267 }
268
269 static void mesh_devkey_message_received_callback(bt_uuid_t *net_uuid,
270                 uint16_t source_addr,
271                         bool is_remote_devkey, uint16_t netkey_idx,
272                                 uint16_t data_len, uint8_t *data)
273 {
274         event_mesh_devkey_message_t *event = g_new0(event_mesh_devkey_message_t, 1);
275
276         BT_INFO("Mesh Event: Dev Key Message Received");
277         event->source = source_addr;
278         event->remote = is_remote_devkey;
279         event->subnet = netkey_idx;
280         event->data_len = data_len;
281         memcpy(event->net_uuid.uuid, net_uuid->uu, sizeof(bt_uuid_t));
282         memcpy(event->data, data, data_len);
283
284         send_event_bda_trace(OAL_EVENT_MESH_DEVKEY_MESSAGE_RECEIVED, event,
285                 sizeof(event_mesh_devkey_message_t), NULL);
286 }
287
288 static void mesh_message_received_callback(bt_uuid_t *net_uuid,
289                 uint16_t source_addr, uint16_t dest_addr, uint16_t key_idx,
290                                 uint16_t data_len, uint8_t *data)
291 {
292         event_mesh_message_t *event = g_new0(event_mesh_message_t, 1);
293
294         BT_INFO("Mesh Event: Model Message Received");
295         event->source = source_addr;
296         event->dest = dest_addr;
297         event->key_idx = key_idx;
298         event->data_len = data_len;
299         memcpy(event->net_uuid.uuid, net_uuid->uu, sizeof(bt_uuid_t));
300         memcpy(event->data, data, data_len);
301
302         send_event_bda_trace(OAL_EVENT_MESH_MODEL_MESSAGE_RECEIVED, event,
303                 sizeof(event_mesh_message_t), NULL);
304 }
305
306 oal_status_t mesh_enable(void)
307 {
308         int ret;
309         API_TRACE();
310
311         /* Get stack interface */
312         blued_api = (const bt_interface_t *) adapter_get_stack_interface();
313
314         if (blued_api == NULL) {
315                 BT_ERR("Stack is not initialized");
316                 return OAL_STATUS_NOT_READY;
317         }
318
319         if (mesh_api) {
320                 BT_WARN("MESH Interface is already initialized...");
321                 return OAL_STATUS_ALREADY_DONE;
322         }
323
324         mesh_api = (const btmesh_interface_t *)blued_api->get_profile_interface(BT_PROFILE_MESH_ID);
325         if (mesh_api == NULL) {
326                 BT_ERR("MESH interface failed");
327                 return OAL_STATUS_INTERNAL_ERROR;
328         }
329
330         if ((ret = mesh_api->init(&sBluetoothMeshCallbacks)) != BT_STATUS_SUCCESS) {
331                 BT_ERR("Error: Unable to initialise MESH :%s", status2string(ret));
332                 mesh_api->cleanup();
333                 mesh_api = NULL;
334                 return convert_to_oal_status(ret);
335         }
336
337         BT_INFO("MESH successfully initialized");
338         return OAL_STATUS_SUCCESS;
339 }
340
341 oal_status_t mesh_disable(void)
342 {
343         API_TRACE();
344         CHECK_OAL_MESH_ENABLED();
345
346         mesh_api->cleanup();
347
348         mesh_api = NULL;
349         return OAL_STATUS_SUCCESS;
350 }
351
352 oal_status_t mesh_register_node(oal_mesh_node_t *node,
353                 GSList *model_list, bool is_provisioner)
354 {
355         int ret = BT_STATUS_SUCCESS;
356         API_TRACE();
357         CHECK_OAL_MESH_ENABLED();
358
359         BT_INFO("Mesh: Send create network request to stack");
360         ret = mesh_api->create((bt_hal_mesh_node_t*)node, model_list, is_provisioner);
361         if (ret != BT_STATUS_SUCCESS) {
362                 BT_ERR("MESH: Create Network failed :failed: %s", status2string(ret));
363                 return convert_to_oal_status(ret);
364         }
365
366         BT_INFO("Mesh: Request sent to stack");
367         return OAL_STATUS_SUCCESS;
368 }
369
370 oal_status_t mesh_network_destroy(oal_uuid_t* network_uuid)
371 {
372         int ret = BT_STATUS_SUCCESS;
373         API_TRACE();
374         CHECK_OAL_MESH_ENABLED();
375
376         ret = mesh_api->destroy((bt_uuid_t*)network_uuid);
377         if (ret != BT_STATUS_SUCCESS) {
378                 BT_ERR("MESH: Network Leave failed: %s", status2string(ret));
379                 return convert_to_oal_status(ret);
380         }
381
382         return OAL_STATUS_SUCCESS;
383 }
384
385 oal_status_t mesh_delete_remote_node(oal_uuid_t* network_uuid,
386                 uint16_t unicast, uint16_t num_elements)
387 {
388         int ret = BT_STATUS_SUCCESS;
389         API_TRACE();
390         CHECK_OAL_MESH_ENABLED();
391
392         ret = mesh_api->delete_node((bt_uuid_t*)network_uuid, unicast, num_elements);
393         if (ret != BT_STATUS_SUCCESS) {
394                 BT_ERR("Mesh: Remote Node Deletion failed: %s", status2string(ret));
395                 return convert_to_oal_status(ret);
396         }
397
398         return OAL_STATUS_SUCCESS;
399 }
400
401 oal_status_t mesh_network_start_scan(oal_uuid_t* network_uuid,
402                 oal_mesh_scan_params_t *params)
403 {
404         int ret = BT_STATUS_SUCCESS;
405         API_TRACE();
406         CHECK_OAL_MESH_ENABLED();
407
408         ret = mesh_api->scan((bt_uuid_t*)network_uuid,
409                 (bt_hal_mesh_scan_param_t*)params);
410         if (ret != BT_STATUS_SUCCESS) {
411                 BT_ERR("MESH: Start Scan failed: %s", status2string(ret));
412                 return convert_to_oal_status(ret);
413         }
414
415         return OAL_STATUS_SUCCESS;
416 }
417
418 oal_status_t mesh_network_scan_cancel(oal_uuid_t* network_uuid)
419 {
420         int ret = BT_STATUS_SUCCESS;
421         API_TRACE();
422         CHECK_OAL_MESH_ENABLED();
423
424         ret = mesh_api->scan_cancel((bt_uuid_t*)network_uuid);
425         if (ret != BT_STATUS_SUCCESS) {
426                 BT_ERR("MESH: Scan Cancel failed: %s", status2string(ret));
427                 return convert_to_oal_status(ret);
428         }
429
430         return OAL_STATUS_SUCCESS;
431 }
432
433 oal_status_t mesh_network_set_provisioning_capabilities(
434                 oal_uuid_t *network_uuid,
435                          oal_mesh_capabilities_t *caps)
436 {
437         int ret = BT_STATUS_SUCCESS;
438         API_TRACE();
439         CHECK_OAL_MESH_ENABLED();
440
441         ret = mesh_api->capability((bt_uuid_t*)network_uuid,
442                 (bt_hal_mesh_prov_caps_t*)caps);
443         if (ret != BT_STATUS_SUCCESS) {
444                 BT_ERR("MESH: Set Provisioning capabilities :failed: %s",
445                         status2string(ret));
446                 return convert_to_oal_status(ret);
447         }
448
449         return OAL_STATUS_SUCCESS;
450 }
451
452 oal_status_t mesh_conf_send_message(oal_uuid_t *network_uuid,
453                 uint16_t dest, bool is_devkey_remote,
454                         uint16_t netkey_idx, uint8_t *buf, int len)
455 {
456         int ret = BT_STATUS_SUCCESS;
457         API_TRACE();
458         CHECK_OAL_MESH_ENABLED();
459
460         ret = mesh_api->config_send((bt_uuid_t*)network_uuid,
461                         dest, is_devkey_remote, netkey_idx, buf, len);
462         if (ret != BT_STATUS_SUCCESS) {
463                 BT_ERR("MESH: Configuration Message sending failed: %s",
464                         status2string(ret));
465                 return convert_to_oal_status(ret);
466         }
467
468         return OAL_STATUS_SUCCESS;
469 }
470
471 oal_status_t mesh_conf_send_key_message(oal_uuid_t *network_uuid,
472                 uint16_t dest, bool is_netkey,
473                         bool is_update, int key_idx, int netkey_idx)
474 {
475         int ret = BT_STATUS_SUCCESS;
476         API_TRACE();
477         CHECK_OAL_MESH_ENABLED();
478
479         ret = mesh_api->key_send((bt_uuid_t*)network_uuid, dest,
480                         is_netkey, is_update, key_idx, netkey_idx);
481         if (ret != BT_STATUS_SUCCESS) {
482                 BT_ERR("MESH: Key Configuration Message sending failed: %s",
483                         status2string(ret));
484                 return convert_to_oal_status(ret);
485         }
486
487         return OAL_STATUS_SUCCESS;
488 }
489
490 oal_status_t mesh_model_send_message(oal_uuid_t *network_uuid,
491                 uint16_t dest, uint16_t appkey_idx,
492                 uint8_t *buf, int len)
493 {
494         int ret = BT_STATUS_SUCCESS;
495         API_TRACE();
496         CHECK_OAL_MESH_ENABLED();
497
498         ret = mesh_api->msg_execute((bt_uuid_t*)network_uuid,
499                         dest, appkey_idx, buf, len);
500         if (ret != BT_STATUS_SUCCESS) {
501                 BT_ERR("MESH: Model Message sending failed: %s",
502                         status2string(ret));
503                 return convert_to_oal_status(ret);
504         }
505
506         return OAL_STATUS_SUCCESS;
507 }
508
509 oal_status_t mesh_network_provision_device(oal_uuid_t* network_uuid,
510                 oal_uuid_t *dev_uuid)
511 {
512         int ret = BT_STATUS_SUCCESS;
513         API_TRACE();
514         CHECK_OAL_MESH_ENABLED();
515
516         ret = mesh_api->provision((bt_uuid_t*)network_uuid, (bt_uuid_t *)dev_uuid);
517         if (ret != BT_STATUS_SUCCESS) {
518                 BT_ERR("MESH: Device Provisioning :failed: %s",
519                         status2string(ret));
520                 return convert_to_oal_status(ret);
521         }
522
523         return OAL_STATUS_SUCCESS;
524 }
525
526 oal_status_t mesh_network_send_provisioning_data(oal_uuid_t* network_uuid,
527                 uint16_t netkey_idx, uint16_t unicast)
528 {
529         int ret = BT_STATUS_SUCCESS;
530         API_TRACE();
531         CHECK_OAL_MESH_ENABLED();
532
533         ret = mesh_api->provision_data((bt_uuid_t*)network_uuid, netkey_idx, unicast);
534         if (ret != BT_STATUS_SUCCESS) {
535                 BT_ERR("MESH: Device Provisioning :failed: %s",
536                         status2string(ret));
537                 return convert_to_oal_status(ret);
538         }
539
540         return OAL_STATUS_SUCCESS;
541 }
542
543 oal_status_t mesh_network_subnet_execute(oal_uuid_t* network_uuid,
544                 oal_mesh_key_op_e operation, uint16_t net_index)
545 {
546         int ret = BT_STATUS_SUCCESS;
547         API_TRACE();
548         CHECK_OAL_MESH_ENABLED();
549
550         ret = mesh_api->subnet_execute((bt_uuid_t*)network_uuid,
551                 (bt_mesh_key_op_e)operation, net_index);
552         if (ret != BT_STATUS_SUCCESS) {
553                 BT_ERR("MESH: Create Subnet :failed: %s", status2string(ret));
554                 return convert_to_oal_status(ret);
555         }
556
557         return OAL_STATUS_SUCCESS;
558 }
559
560 oal_status_t mesh_network_appkey_execute(oal_uuid_t* network_uuid,
561                 oal_mesh_key_op_e operation,
562                         uint16_t net_index, uint16_t app_index)
563 {
564         int ret = BT_STATUS_SUCCESS;
565         API_TRACE();
566         CHECK_OAL_MESH_ENABLED();
567
568         ret = mesh_api->appkey_execute((bt_uuid_t*)network_uuid,
569                 (bt_mesh_key_op_e)operation,
570                         net_index, app_index);
571         if (ret != BT_STATUS_SUCCESS) {
572                 BT_ERR("MESH: Create Subnet :failed: %s",
573                         status2string(ret));
574                 return convert_to_oal_status(ret);
575         }
576
577         return OAL_STATUS_SUCCESS;
578 }
579
580 oal_status_t mesh_authentication_reply(
581                 oal_mesh_variant_authentication_e auth_type,
582                         const char* auth_value)
583 {
584         int ret = BT_STATUS_SUCCESS;
585         API_TRACE();
586         CHECK_OAL_MESH_ENABLED();
587
588         ret = mesh_api->auth_reply((bt_hal_mesh_auth_variant_e)auth_type,
589                         auth_value);
590         if (ret != BT_STATUS_SUCCESS) {
591                 BT_ERR("MESH: Device Provisioning :failed: %s",
592                         status2string(ret));
593                 return convert_to_oal_status(ret);
594         }
595
596         return OAL_STATUS_SUCCESS;
597 }