Fix the coverity issues
[platform/core/connectivity/bluetooth-frwk.git] / bt-service / services / mesh / bt-service-mesh-config-client.c
index a9bfac4..9b57173 100644 (file)
@@ -233,19 +233,43 @@ static void __bt_mesh_wait_response_timeout(
        /* TODO Reset the remote node, as no response is expected on reset command */
 
 
-       switch(req->cmd->opcode) {
+       switch (req->cmd->opcode) {
        case MESH_OPCODE_DEV_COMP_GET: {
-               /* Send event with timeout */
+               /* Send event with timeout for Vendor Features */
+               bluetooth_mesh_node_features_t *vendor_event = \
+                       g_malloc0(sizeof(bluetooth_mesh_node_features_t));
+
+               _bt_mesh_util_convert_hex_to_string((uint8_t *) req->net_uuid, 16,
+                       vendor_event->net_uuid,
+                               BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1);
+               vendor_event->unicast = req->addr;
+                __bt_mesh_handle_pending_dev_config_request_info(
+                       BLUETOOTH_ERROR_TIMEOUT, BT_MESH_NODE_GET_VENDOR_FEATURES,
+                               vendor_event, sizeof(bluetooth_mesh_node_features_t));
+               g_free(vendor_event);
+
+               /* Send event with timeout for Node Browse */
                event_mesh_devkey_message_t *event = \
                        g_malloc0(sizeof(event_mesh_devkey_message_t));
                memcpy(event->net_uuid.uuid, req->net_uuid, 16);
                event->source = req->addr;
+
                 __bt_mesh_handle_pending_dev_config_request_info(
                        BLUETOOTH_ERROR_TIMEOUT, BT_MESH_NODE_BROWSE,
                                event, sizeof(event_mesh_devkey_message_t));
+
                g_free(event);
                break;
        }
+       case MESH_OPCODE_CONFIG_MODEL_SUB_GET:
+       case MESH_OPCODE_CONFIG_VEND_MODEL_SUB_GET:
+               BT_INFO("Mesh: Command TimedOut: Model Subscription list get");
+               /* Send event with timeout */
+                __bt_mesh_handle_pending_dev_config_request_info(
+                       BLUETOOTH_ERROR_TIMEOUT,
+                               BT_MESH_MODEL_GET_SUBSCRIPTION_LIST, req->data,
+                                       sizeof(bluetooth_mesh_model_configure_t));
+       break;
        case MESH_OPCODE_NETKEY_ADD:
        case MESH_OPCODE_NETKEY_UPDATE:
        case MESH_OPCODE_NETKEY_DELETE:
@@ -266,6 +290,58 @@ static void __bt_mesh_wait_response_timeout(
                                BT_MESH_NODE_TTL_EXECUTE, req->data,
                                        sizeof(bluetooth_mesh_node_ttl_info_t));
                break;
+       case MESH_OPCODE_CONFIG_MODEL_SUB_ADD:
+       case MESH_OPCODE_CONFIG_MODEL_SUB_DELETE:
+       case MESH_OPCODE_CONFIG_MODEL_SUB_OVERWRITE:
+               /* Send event with timeout */
+                __bt_mesh_handle_pending_dev_config_request_info(
+                       BLUETOOTH_ERROR_TIMEOUT,
+                               BT_MESH_MODEL_CONFIG_GROUP_SUB, req->data,
+                                       sizeof(bluetooth_mesh_model_configure_t));
+               break;
+       case MESH_OPCODE_CONFIG_MODEL_SUB_VIRT_ADD:
+       case MESH_OPCODE_CONFIG_MODEL_SUB_VIRT_DELETE:
+       case MESH_OPCODE_CONFIG_MODEL_SUB_VIRT_OVERWRITE:
+               /* Send event with timeout */
+                __bt_mesh_handle_pending_dev_config_request_info(
+                       BLUETOOTH_ERROR_TIMEOUT,
+                               BT_MESH_MODEL_CONFIG_VIRTUAL_GROUP_SUB, req->data,
+                                       sizeof(bluetooth_mesh_model_configure_t));
+               break;
+       case MESH_OPCODE_CONFIG_MODEL_SUB_DELETE_ALL:
+               /* Send event with timeout */
+                __bt_mesh_handle_pending_dev_config_request_info(
+                       BLUETOOTH_ERROR_TIMEOUT,
+                               BT_MESH_MODEL_CONFIG_VIRTUAL_GROUP_SUB, req->data,
+                                       sizeof(bluetooth_mesh_model_configure_t));
+               /* Send event with timeout */
+                __bt_mesh_handle_pending_dev_config_request_info(
+                       BLUETOOTH_ERROR_TIMEOUT,
+                               BT_MESH_MODEL_CONFIG_GROUP_SUB, req->data,
+                                       sizeof(bluetooth_mesh_model_configure_t));
+               break;
+       case MESH_OPCODE_CONFIG_MODEL_PUB_GET:
+               /* Send event with timeout */
+               __bt_mesh_handle_pending_dev_config_request_info(
+                       BLUETOOTH_ERROR_TIMEOUT,
+                               BT_MESH_MODEL_GET_PUBLICATION, req->data,
+                               sizeof(bluetooth_mesh_model_configure_t));
+               break;
+       case MESH_OPCODE_CONFIG_MODEL_PUB_SET:
+               /* Send event with timeout */
+               __bt_mesh_handle_pending_dev_config_request_info(
+                       BLUETOOTH_ERROR_TIMEOUT,
+                               BT_MESH_MODEL_SET_PUBLICATION, req->data,
+                               sizeof(bluetooth_mesh_model_configure_t));
+               break;
+       case MESH_OPCODE_MODEL_APP_BIND:
+       case MESH_OPCODE_MODEL_APP_UNBIND:
+               /* Send event with timeout */
+               __bt_mesh_handle_pending_dev_config_request_info(
+                       BLUETOOTH_ERROR_TIMEOUT,
+                               BT_MESH_MODEL_CONFIGURE_APPKEY, req->data,
+                               sizeof(bluetooth_mesh_model_configure_t));
+               break;
        default:
                break;
        }
@@ -287,7 +363,7 @@ static void __bt_mesh_add_request(uint32_t opcode, uint16_t dest,
                return;
        _bt_mesh_util_convert_hex_to_string((uint8_t *) net_uuid, 16, uuid_str,
                BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1);
-       BT_INFO("Mesh: Net UUID[%s]",uuid_str);
+       BT_INFO("Mesh: Net UUID[%s]", uuid_str);
 
        BT_INFO("Mesh: Adding command opcode [0x%2.2x] response [0x%2.2x]",
                        cmd->opcode, cmd->response);
@@ -324,11 +400,11 @@ static struct mesh_pending_request *__bt_mesh_get_request_by_response(
                BT_INFO("Mesh: Current req addr [0x%2.2x] res [0x%2.2x]", addr, response);
                _bt_mesh_util_convert_hex_to_string((uint8_t *) net_uuid, 16, uuid_str,
                                BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1);
-               BT_INFO("Mesh: Net UUID[%s]",uuid_str);
+               BT_INFO("Mesh: Net UUID[%s]", uuid_str);
 
                _bt_mesh_util_convert_hex_to_string((uint8_t *) req->net_uuid, 16, uuid_str1,
                                BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1);
-               BT_INFO("Mesh: Net UUID1[%s]",uuid_str1);
+               BT_INFO("Mesh: Net UUID1[%s]", uuid_str1);
                if (!memcmp(net_uuid, req->net_uuid, 16) &&
                                req->addr == addr &&
                                req->cmd->response == response)
@@ -446,6 +522,8 @@ static void __bt_mesh_send_model_publication_status_event(
        GArray *info = NULL;
 
        if (BLUETOOTH_ERROR_NONE == result) {
+               BT_INFO("Mesh: Model ID [0x%4.4x]", evt->model);
+               BT_INFO("Mesh: Model Publication Address [0x%2.2x]", evt->pub_addr);
                /* Send event */
                info = g_array_new(FALSE, FALSE, sizeof(gchar));
                g_array_append_vals(info, evt,
@@ -490,19 +568,26 @@ static void __bt_mesh_send_model_get_subscription_list_event(
        GVariant  *param = NULL;
        GVariantBuilder *builder = NULL;
        int i;
+       char *net_uuid;
 
        if (BLUETOOTH_ERROR_NONE == result) {
-               if (evt->sublist_count) {
-                       builder = g_variant_builder_new(G_VARIANT_TYPE("aq"));
-                       for (i = 0; i < evt->sublist_count; i++)
-                               g_variant_builder_add(builder, "q", *evt->sub_list[i]);
+               BT_INFO("Mesh: Total Subscriptions bound to model [%d]",
+                               evt->sublist_count);
+               BT_INFO("Mesh: Network [%s]", evt->net_uuid);
+               builder = g_variant_builder_new(G_VARIANT_TYPE("aq"));
+               for (i = 0; i < evt->sublist_count; i++) {
+                       BT_INFO("Mesh: Subscription Address [0x%2.2x]",
+                               *evt->sub_list[i]);
+                       g_variant_builder_add(builder, "q", *evt->sub_list[i]);
+               }
 
-                       param = g_variant_new("(isqiui(aq))", result, evt->net_uuid,
-                                       evt->primary_unicast, evt->elem_index, evt->model,
-                                       evt->sublist_count, builder);
+               net_uuid = g_strdup(evt->net_uuid);
+               param = g_variant_new("(isqiui(aq))", result, net_uuid,
+                               evt->primary_unicast, evt->elem_index, evt->model,
+                               evt->sublist_count, builder);
+
+               g_variant_builder_unref(builder);
 
-                       g_variant_builder_unref(builder);
-               }
                /* Send event */
                _bt_send_event(BT_MESH_EVENT,
                                BLUETOOTH_EVENT_MESH_MODEL_SUBSCRIPTION_LIST,
@@ -514,6 +599,8 @@ static void __bt_mesh_send_model_get_subscription_list_event(
                                g_free(evt->sub_list[i]);
                        g_free(evt->sub_list);
                }
+               g_free(net_uuid);
+               BT_INFO("freed net uuid");
        }
 }
 
@@ -522,21 +609,22 @@ static void __bt_mesh_send_model_get_appkey_list_event(int result,
 {
        GVariant  *param = NULL;
        GVariantBuilder *builder = NULL;
+       char *net_uuid;
        int i;
 
        if (BLUETOOTH_ERROR_NONE == result) {
-
-               if (evt->appkeylist_count) {
-                       builder = g_variant_builder_new(G_VARIANT_TYPE("aq"));
-                       for (i = 0; i < evt->appkeylist_count; i++)
-                               g_variant_builder_add(builder, "q", *evt->appkey_list[i]);
-
-                       param = g_variant_new("(isqiui(aq))", result, evt->net_uuid,
-                                       evt->primary_unicast, evt->elem_index, evt->model,
-                                       evt->appkeylist_count, builder);
-
-                       g_variant_builder_unref(builder);
-               }
+               builder = g_variant_builder_new(G_VARIANT_TYPE("aq"));
+               BT_INFO("Mesh: Total AppKeys bound to model [%d]",
+                               evt->appkeylist_count);
+               BT_INFO("Mesh: Network [%s]", evt->net_uuid);
+               for (i = 0; i < evt->appkeylist_count; i++)
+                       g_variant_builder_add(builder, "q", *evt->appkey_list[i]);
+               net_uuid = g_strdup(evt->net_uuid);
+               param = g_variant_new("(isqiui(aq))", result, net_uuid,
+                               evt->primary_unicast, evt->elem_index, evt->model,
+                               evt->appkeylist_count, builder);
+
+               g_variant_builder_unref(builder);
 
                /* Send event */
                _bt_send_event(BT_MESH_EVENT,
@@ -544,11 +632,13 @@ static void __bt_mesh_send_model_get_appkey_list_event(int result,
                                param);
 
                if (evt->appkeylist_count) {
-                       /* Free List data */
                        for (int i = 0; i < evt->appkeylist_count; i++)
                                g_free(evt->appkey_list[i]);
+
                        g_free(evt->appkey_list);
                }
+               /* Free List data */
+               g_free(net_uuid);
        }
 }
 
@@ -569,7 +659,7 @@ static void __bt_mesh_send_model_configure_appkey_event(int result,
 
                param = g_variant_new("(iv)", result, out_var);
                _bt_send_event(BT_MESH_EVENT,
-                               BLUETOOTH_EVENT_MESH_NODE_MODEL_APPKEY_BIND,
+                               BLUETOOTH_EVENT_MESH_MODEL_APPKEY_BIND,
                                param);
        }
 }
@@ -734,6 +824,8 @@ static void __bt_mesh_handle_pending_dev_config_request_info(int result,
                                        _bt_mesh_node_get_element_count(event->net_uuid.uuid, remote_addr, &elem_count);
                                        node->unicast = event->source;
                                        node->count = elem_count;
+                                       BT_INFO("Mesh: Browse event for Node: Unicast [0x%2.2x] Element Count [%d]",
+                                               node->unicast, elem_count);
                                        /* Send Event */
                                        __bt_mesh_send_node_browsed_event(result, node);
 
@@ -844,6 +936,7 @@ static void __bt_mesh_handle_pending_dev_config_request_info(int result,
                        bluetooth_mesh_model_configure_t *event;
                        bluetooth_mesh_model_configure_t *req;
 
+                       BT_INFO("Mesh: Handle event for BT_MESH_MODEL_GET_SUBSCRIPTION_LIST");
                        event = (bluetooth_mesh_model_configure_t*) param;
                        req = (bluetooth_mesh_model_configure_t*)req_info->user_data;
 
@@ -868,11 +961,17 @@ static void __bt_mesh_handle_pending_dev_config_request_info(int result,
 
                        event = (bluetooth_mesh_model_configure_t*) param;
                        req = (bluetooth_mesh_model_configure_t*)req_info->user_data;
+                       BT_INFO("Mesh: Event Network [%s] Req Network [%s]",
+                               event->net_uuid, req->net_uuid);
+
+                       BT_INFO("Mesh: Event Unicast [0x%4.4x] Req Unicast [0x%4.4x]",
+                               event->primary_unicast, req->primary_unicast);
 
                        if (!g_strcmp0(req->net_uuid, event->net_uuid) &&
                                req->primary_unicast == event->primary_unicast) {
 
                                req->sub_addr = event->sub_addr;
+                               BT_INFO("Mesh: Send event for Model Subscription");
                                /* Send Event */
                                __bt_mesh_send_model_subscription_configure_event(
                                        BLUETOOTH_EVENT_MESH_MODEL_SUBSCRIPTION_CONFGURED,
@@ -894,7 +993,11 @@ static void __bt_mesh_handle_pending_dev_config_request_info(int result,
 
                        event = (bluetooth_mesh_model_configure_t*) param;
                        req = (bluetooth_mesh_model_configure_t*)req_info->user_data;
+                       BT_INFO("Mesh: Event Network [%s] Req Network [%s]",
+                               event->net_uuid, req->net_uuid);
 
+                       BT_INFO("Mesh: Event Unicast [0x%4.4x] Req Unicast [0x%4.4x]",
+                               event->primary_unicast, req->primary_unicast);
                        if (!g_strcmp0(req->net_uuid, event->net_uuid) &&
                                req->primary_unicast == event->primary_unicast) {
                                /* Send Event */
@@ -914,6 +1017,7 @@ static void __bt_mesh_handle_pending_dev_config_request_info(int result,
                        break;
                }
                case BT_MESH_MODEL_GET_PUBLICATION: {
+                       BT_INFO("Mesh: Event for Model Get Publication Request");
                        bluetooth_mesh_model_configure_t *event;
                        bluetooth_mesh_model_configure_t *req;
 
@@ -923,6 +1027,7 @@ static void __bt_mesh_handle_pending_dev_config_request_info(int result,
                        if (!g_strcmp0(req->net_uuid, event->net_uuid) &&
                                        req->primary_unicast == event->primary_unicast) {
                                /* Send Event */
+                               BT_INFO("Mesh: Send Model Publication status for Get Request");
                                __bt_mesh_send_model_publication_status_event( \
                                                BLUETOOTH_EVENT_MESH_MODEL_PUBLICATION_STATUS, \
                                                result, event);
@@ -938,6 +1043,7 @@ static void __bt_mesh_handle_pending_dev_config_request_info(int result,
                        break;
                }
                case BT_MESH_MODEL_SET_PUBLICATION: {
+                       BT_INFO("Mesh: Event for Model Set Publication Request");
                        bluetooth_mesh_model_configure_t *event;
                        bluetooth_mesh_model_configure_t *req;
 
@@ -947,6 +1053,7 @@ static void __bt_mesh_handle_pending_dev_config_request_info(int result,
                        if (!g_strcmp0(req->net_uuid, event->net_uuid) &&
                                req->primary_unicast == event->primary_unicast) {
                                /* Send Event */
+                               BT_INFO("Mesh: Send Model Publication status for Set Request");
                                __bt_mesh_send_model_publication_status_event( \
                                        BLUETOOTH_EVENT_MESH_MODEL_PUBLICATION_STATUS, \
                                                result, req);
@@ -998,22 +1105,33 @@ static void __mesh_handle_model_subscription_event(int result,
                bluetooth_mesh_model_configure_t *param,
                        const struct mesh_config_cmd *cmd)
 {
+       BT_INFO("Mesh: Model Subscription Event: Request [%d]", cmd->opcode);
        switch (cmd->opcode) {
        /* Fall through */
        case MESH_OPCODE_CONFIG_MODEL_SUB_ADD:
        case MESH_OPCODE_CONFIG_MODEL_SUB_DELETE:
        case MESH_OPCODE_CONFIG_MODEL_SUB_OVERWRITE:
-       case MESH_OPCODE_CONFIG_MODEL_SUB_DELETE_ALL:
                /* Model Bind/UnBind Event */
+       BT_INFO("Mesh: Handle Event for Request: BT_MESH_MODEL_CONFIG_GROUP_SUB");
        __bt_mesh_handle_pending_dev_config_request_info(result,
-                       BT_MESH_MODEL_CONFIG_GROUP_SUB, &param,
+                       BT_MESH_MODEL_CONFIG_GROUP_SUB, param,
                                sizeof(bluetooth_mesh_model_configure_t));
                break;
        case MESH_OPCODE_CONFIG_MODEL_SUB_VIRT_ADD:
        case MESH_OPCODE_CONFIG_MODEL_SUB_VIRT_DELETE:
        case MESH_OPCODE_CONFIG_MODEL_SUB_VIRT_OVERWRITE:
+       BT_INFO("Mesh: Handle Event for Request: BT_MESH_MODEL_CONFIG_VIRTUAL_GROUP_SUB");
        __bt_mesh_handle_pending_dev_config_request_info(result,
-                       BT_MESH_MODEL_CONFIG_VIRTUAL_GROUP_SUB, &param,
+                       BT_MESH_MODEL_CONFIG_VIRTUAL_GROUP_SUB, param,
+                               sizeof(bluetooth_mesh_model_configure_t));
+               break;
+       case MESH_OPCODE_CONFIG_MODEL_SUB_DELETE_ALL:
+       BT_INFO("Mesh: Handle Event for Request: MESH_OPCODE_CONFIG_MODEL_SUB_DELETE_ALL");
+       __bt_mesh_handle_pending_dev_config_request_info(result,
+                       BT_MESH_MODEL_CONFIG_GROUP_SUB, param,
+                               sizeof(bluetooth_mesh_model_configure_t));
+       __bt_mesh_handle_pending_dev_config_request_info(result,
+                       BT_MESH_MODEL_CONFIG_VIRTUAL_GROUP_SUB, param,
                                sizeof(bluetooth_mesh_model_configure_t));
                break;
        default:
@@ -1038,13 +1156,13 @@ void _bt_mesh_config_client_devkey_msg_handler(
        int n;
        struct mesh_pending_request *req;
 
-       if (_bt_mesh_util_opcode_get(data, data_len, &opcode, &n)) {
-               BT_INFO("Mesh: Opcode of response data [0x%2.2x], actual data len [%d]", opcode, n);
-               data_len -= n;
-               data += n;
-       } else
+       if (_bt_mesh_util_opcode_get(data, data_len, &opcode, &n) == false)
                return;
 
+       BT_INFO("Mesh: Opcode of response data [0x%2.2x], actual data len [%d]", opcode, n);
+       data_len -= n;
+       data += n;
+
        BT_INFO("Mesh: Received %s (len %u) opcode [0x%2.2x]",
                __mesh_get_opcode_string(opcode), data_len, opcode);
 
@@ -1053,15 +1171,16 @@ void _bt_mesh_config_client_devkey_msg_handler(
        if (req) {
                BT_INFO("Mesh: Got Config Request");
                cmd = req->cmd;
-               __mesh_request_remove(req);
                l_queue_remove(pending_requests, req);
-       } else
+               __mesh_request_remove(req);
+       } else {
                cmd = NULL;
+       }
 
 
        switch (opcode & ~MESH_OPCODE_UNRELIABLE) {
-               default:
-                       return;
+       default:
+               return;
        case MESH_OPCODE_CONFIG_MODEL_PUB_STATUS: {
                if (data_len != 12 && data_len != 14)
                        break;
@@ -1075,7 +1194,7 @@ void _bt_mesh_config_client_devkey_msg_handler(
                                event->source, __mesh_status_to_string(data[0]));
 
                if (data[0] != MESH_STATUS_SUCCESS)
-                       break;
+                       result = BLUETOOTH_ERROR_INTERNAL;
 
                /* Extract Element Address */
                ele_addr = l_get_le16(data + 1);
@@ -1091,16 +1210,22 @@ void _bt_mesh_config_client_devkey_msg_handler(
                        mod_id = MESH_VENDOR_ID_MASK | mod_id;
                }
 
+               param.model = mod_id;
+               BT_INFO("Model ID\t%4.4x\n", mod_id);
+
                param.primary_unicast = event->source;
                param.elem_index = ele_addr - event->source;
                /* Extract Publish Address */
                param.pub_addr = l_get_le16(data + 3);
+               BT_INFO("Mesh: Pub Address [0x%2.2x]", param.pub_addr);
 
                /* Extract Appkey Index */
                param.appkey_idx =  l_get_le16(data + 5);
+               BT_INFO("Mesh: AppKey Idx [0x%2.2x]", param.appkey_idx);
 
                /* Extract TTL */
                param.ttl = data[6];
+               BT_INFO("Mesh: TTL [0x%x]", param.ttl);
 
                /* Extract Period */
                param.period = data[7];
@@ -1130,9 +1255,18 @@ void _bt_mesh_config_client_devkey_msg_handler(
                BT_INFO("\nNode %4.4x Subscription status %s\n",
                                event->source, __mesh_status_to_string(data[0]));
 
+               if (data[0] != MESH_STATUS_SUCCESS)
+                       result = BLUETOOTH_ERROR_INTERNAL;
+
+               if (!cmd) {
+                       BT_INFO("Mesh: Command not found!!");
+                       break;
+               }
+
                ele_addr = l_get_le16(data + 1);
                addr = l_get_le16(data + 3);
                BT_INFO("Element Addr\t%4.4x\n", ele_addr);
+               BT_INFO("Message Source Addr\t%4.4x\n", event->source);
 
                if (data_len == 9) {
                        /* vendor Model */
@@ -1150,7 +1284,48 @@ void _bt_mesh_config_client_devkey_msg_handler(
                param.sub_addr = addr;
                param.model = mod_id;
                BT_INFO("Subscr Addr\t%4.4x\n", addr);
-               __mesh_handle_model_subscription_event(result, &param, cmd);
+               BT_INFO("Model ID\t%4.4x\n", mod_id);
+
+               if (data[0] == MESH_STATUS_SUCCESS) {
+                       /* Update cdb */
+                       switch (cmd->opcode) {
+                       case MESH_OPCODE_CONFIG_MODEL_SUB_ADD:
+                       case MESH_OPCODE_CONFIG_MODEL_SUB_VIRT_ADD:
+                               if (!_bt_mesh_network_add_model_subscription(
+                                       event->net_uuid.uuid, event->source,
+                                       ele_addr - event->source, mod_id, addr)) {
+                                       BT_INFO("Failed to add model subscription!");
+                               }
+                       break;
+                       case MESH_OPCODE_CONFIG_MODEL_SUB_DELETE:
+                       case MESH_OPCODE_CONFIG_MODEL_SUB_VIRT_DELETE:
+                               if (!_bt_mesh_network_delete_model_subscription(
+                                       event->net_uuid.uuid, event->source,
+                                       ele_addr - event->source, mod_id, addr)) {
+                                       BT_INFO("Failed to delete model subscription!");
+                               }
+                       break;
+                       case MESH_OPCODE_CONFIG_MODEL_SUB_DELETE_ALL:
+                               if (!_bt_mesh_network_delete_all_model_subscription(
+                                       event->net_uuid.uuid, event->source,
+                                       ele_addr - event->source, mod_id)) {
+                                       BT_INFO("Failed to delete all model subscription!");
+                               }
+                       break;
+                       case MESH_OPCODE_CONFIG_MODEL_SUB_OVERWRITE:
+                       case MESH_OPCODE_CONFIG_MODEL_SUB_VIRT_OVERWRITE:
+                               if (!_bt_mesh_network_overwrite_model_subscription(
+                                       event->net_uuid.uuid, event->source,
+                                       ele_addr - event->source, mod_id, addr)) {
+                                       BT_INFO("Failed to overwrite model subscription!");
+                               }
+                       break;
+                       }
+               }
+
+               if (cmd)
+                       __mesh_handle_model_subscription_event(result, &param, cmd);
+
                break;
        }
        case MESH_OPCODE_CONFIG_DEFAULT_TTL_STATUS: {
@@ -1189,6 +1364,10 @@ void _bt_mesh_config_client_devkey_msg_handler(
                                BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1);
                BT_INFO("Node %4.4x: Model App status %s\n", event->source,
                        __mesh_status_to_string(data[0]));
+
+               if (data[0] != MESH_STATUS_SUCCESS)
+                       result = BLUETOOTH_ERROR_INTERNAL;
+
                elem_addr = l_get_le16(data + 1);
                app_idx = l_get_le16(data + 3);
 
@@ -1303,19 +1482,23 @@ void _bt_mesh_config_client_devkey_msg_handler(
                param.primary_unicast = event->source;
                param.elem_index = elem_addr - event->source;
                param.model = mod_id;
-
-               total = data_len -  5;
+               BT_INFO("Mesh: Data length of All Models Together [%d]", data_len - 5);
+               total = (data_len -  5)/2;
                param.sublist_count = total;
+               BT_INFO("Mesh: Total Number of subscriptions [%d]", total);
                if (total) {
                        param.sub_list = (uint16_t **)g_malloc0(sizeof(uint16_t*) * total);
 
                        i = 5;
-                       for (; i < data_len; i += 2) {
-                               BT_INFO("Subscription Addr \t\t%4.4x\n ", l_get_le16(data + i));
-                               param.sub_list[i] = g_malloc(sizeof(uint16_t));
-                               *param.sub_list[i] = l_get_le16(data + i);
+                       for (int k = 0; i < data_len; k++, i += 2) {
+                               BT_INFO("Mesh: Subscription Addr \t\t%4.4x\n ", l_get_le16(data + i));
+                               param.sub_list[k] = g_malloc(sizeof(uint16_t));
+                               *param.sub_list[k] = l_get_le16(data + i);
                        }
                }
+
+               /* <TO-DO> Update model sub in cdb */
+
                __bt_mesh_handle_pending_dev_config_request_info(result,
                        BT_MESH_MODEL_GET_SUBSCRIPTION_LIST, &param,
                                sizeof(bluetooth_mesh_model_configure_t));
@@ -1333,7 +1516,7 @@ void _bt_mesh_config_client_devkey_msg_handler(
                        (uint8_t *) event->net_uuid.uuid, 16, param.net_uuid,
                                BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1);
 
-               BT_INFO("\nNode %4.4x BT SIG Model Subscription List status %s\n",
+               BT_INFO("\nNode %4.4x Vendor Model Subscription List status %s\n",
                                event->source, __mesh_status_to_string(data[0]));
 
                BT_INFO("Element Addr\t%4.4x\n", l_get_le16(data + 1));
@@ -1349,16 +1532,19 @@ void _bt_mesh_config_client_devkey_msg_handler(
                param.elem_index = elem_addr - event->source;
                param.model = mod_id;
 
-               total = data_len -  7;
+               BT_INFO("Mesh: Data length of All Models Together [%d]", data_len - 7);
+               total = (data_len -  7)/2;
                param.sublist_count = total;
+
+               BT_INFO("Mesh: Total Number of subscriptions [%d]", total);
                if (total) {
                        param.sub_list = (uint16_t **)g_malloc0(sizeof(uint16_t*) * total);
 
                        i = 7;
-                       for (; i < data_len; i += 2) {
-                               BT_INFO("Subscription Addr \t\t%4.4x\n ", l_get_le16(data + i));
-                               param.sub_list[i] = g_malloc(sizeof(uint16_t));
-                               *param.sub_list[i] = l_get_le16(data + i);
+                       for (int k = 0; i < data_len; k++, i += 2) {
+                               BT_INFO("Mesh: Subscription Addr \t\t%4.4x\n ", l_get_le16(data + i));
+                               param.sub_list[k] = g_malloc(sizeof(uint16_t));
+                               *param.sub_list[k] = l_get_le16(data + i);
                        }
                }
                __bt_mesh_handle_pending_dev_config_request_info(result,
@@ -1388,9 +1574,19 @@ void _bt_mesh_config_client_devkey_msg_handler(
                        (uint8_t *) event->net_uuid.uuid, 16, features.net_uuid,
                                BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1);
                features.unicast = event->source;
-               _bt_mesh_node_get_vendor_features(event->net_uuid.uuid,
-                       event->source, &features);
-
+               BT_INFO("Mesh: Net UUID [%s]", features.net_uuid);
+
+               BT_INFO("Mesh: Composition status for node unicast [0x%2.2x]",
+                       event->source);
+               if (!_bt_mesh_node_get_vendor_features(event->net_uuid.uuid,
+                       event->source, &features)) {
+                       BT_ERR("Mesh: Failed to get Vendor Specific Infor for [0x%2.2x]",
+                               event->source);
+                       result = BLUETOOTH_ERROR_INTERNAL;
+               } else {
+                       BT_INFO("Mesh: Got Feature informations for [0x%2.2x]",
+                               event->source);
+               }
                __bt_mesh_handle_pending_dev_config_request_info(result,
                        BT_MESH_NODE_GET_VENDOR_FEATURES, &features,
                                sizeof(bluetooth_mesh_node_features_t));
@@ -1410,7 +1606,7 @@ void _bt_mesh_config_client_devkey_msg_handler(
                BT_INFO("\tNetKey %u (0x%3.3x)", net_idx, net_idx);
 
                if (data[0] != 0)
-                       break;
+                       result = BLUETOOTH_ERROR_INTERNAL;
 
                if (!cmd)
                        break;
@@ -1422,19 +1618,25 @@ void _bt_mesh_config_client_devkey_msg_handler(
                param.netkey_idx = net_idx;
                param.is_netkey = true;
 
+               BT_INFO("Mesh: Resp recvd from node unicast [0x%4.4x]", event->source);
                if (cmd->opcode == MESH_OPCODE_NETKEY_ADD) {
                        BT_INFO("Mesh: Resp recvd: MESH_OPCODE_NETKEY_ADD");
-                       if (!_bt_mesh_network_save_remote_node_netkey(
-                                       event->net_uuid.uuid, event->source, net_idx)) {
-                               result = BLUETOOTH_ERROR_INTERNAL;
-                               BT_INFO("Failed to save node Netkey!");
+                       if (result == BLUETOOTH_ERROR_NONE) {
+                               if (!_bt_mesh_network_save_remote_node_netkey(
+                                                       event->net_uuid.uuid, event->source, net_idx)) {
+                                       result = BLUETOOTH_ERROR_INTERNAL;
+                                       BT_INFO("Failed to save node Netkey!");
+                               }
                        }
                        param.op = BLUETOOTH_MESH_NODE_KEY_ADD;
                } else if (cmd->opcode == MESH_OPCODE_NETKEY_DELETE) {
-                       if (!_bt_mesh_network_delete_remote_node_netkey(
-                                       event->net_uuid.uuid, event->source, net_idx)) {
-                               result = BLUETOOTH_ERROR_INTERNAL;
-                               BT_INFO("Failed to delete node Netkey!");
+                       BT_INFO("Mesh: Resp recvd: MESH_OPCODE_NETKEY_DELETE");
+                       if (result == BLUETOOTH_ERROR_NONE) {
+                               if (!_bt_mesh_network_delete_remote_node_netkey(
+                                                       event->net_uuid.uuid, event->source, net_idx)) {
+                                       result = BLUETOOTH_ERROR_INTERNAL;
+                                       BT_INFO("Failed to delete node Netkey!");
+                               }
                        }
                        param.op = BLUETOOTH_MESH_NODE_KEY_DELETE;
                } else if (cmd->opcode == MESH_OPCODE_NETKEY_UPDATE) {
@@ -1463,7 +1665,7 @@ void _bt_mesh_config_client_devkey_msg_handler(
                BT_INFO("AppKey\t%u (0x%3.3x)\n", app_idx, app_idx);
 
                if (data[0] != MESH_STATUS_SUCCESS)
-                       break;
+                       result = BLUETOOTH_ERROR_INTERNAL;
 
                if (!cmd)
                        break;
@@ -1479,20 +1681,24 @@ void _bt_mesh_config_client_devkey_msg_handler(
 
                if (cmd->opcode == MESH_OPCODE_APPKEY_ADD) {
                        BT_INFO("Mesh: Resp recvd: MESH_OPCODE_APPKEY_ADD");
-                       if (!_bt_mesh_network_save_remote_node_appkey(
-                               event->net_uuid.uuid, event->source,
-                                       net_idx, app_idx)) {
-                               result = BLUETOOTH_ERROR_INTERNAL;
-                               BT_INFO("Failed to save node Appkey!");
+                       if (result == BLUETOOTH_ERROR_NONE) {
+                               if (!_bt_mesh_network_save_remote_node_appkey(
+                                               event->net_uuid.uuid, event->source,
+                                               net_idx, app_idx)) {
+                                       result = BLUETOOTH_ERROR_INTERNAL;
+                                       BT_INFO("Failed to save node Appkey!");
+                               }
                        }
                        param.op = BLUETOOTH_MESH_NODE_KEY_ADD;
                } else if (cmd->opcode == MESH_OPCODE_APPKEY_DELETE) {
                        BT_INFO("Mesh: Resp recvd: MESH_OPCODE_APPKEY_DELETE");
-                       if (!_bt_mesh_network_delete_remote_node_appkey(
-                               event->net_uuid.uuid, event->source,
-                                       net_idx, app_idx)) {
-                               result = BLUETOOTH_ERROR_INTERNAL;
-                               BT_INFO("Failed to delete node Appkey!");
+                       if (result == BLUETOOTH_ERROR_NONE) {
+                               if (!_bt_mesh_network_delete_remote_node_appkey(
+                                               event->net_uuid.uuid, event->source,
+                                               net_idx, app_idx)) {
+                                       result = BLUETOOTH_ERROR_INTERNAL;
+                                       BT_INFO("Failed to delete node Appkey!");
+                               }
                        }
                        param.op = BLUETOOTH_MESH_NODE_KEY_DELETE;
                } else if (cmd->opcode == MESH_OPCODE_APPKEY_UPDATE) {
@@ -1530,10 +1736,13 @@ int _bt_mesh_node_discover_vendor_features(const char *app_cred, const char *sen
        oal_uuid_t net_uuid;
        uint8_t buffer[MESH_CONFIG_BUFFER_MAX_LEN];
 
+       BT_INFO("Mesh: Vendor features for Network UUID [%s]", req->net_uuid);
        _bt_mesh_util_convert_string_to_hex(req->net_uuid,
                        strlen(req->net_uuid), net_uuid.uuid, 16);
        /* Check if Node's vendor features are already svaed or not */
        if (_bt_mesh_node_get_vendor_features(net_uuid.uuid, req->unicast, req)) {
+               BT_INFO("Mesh: Vendor Features already available for Node: Unicast [0x%.2x]",
+                               req->unicast);
                /* Schedule event ot Application */
                bluetooth_mesh_node_features_t *event = \
                        g_memdup(req, sizeof(bluetooth_mesh_node_features_t));
@@ -1552,6 +1761,7 @@ int _bt_mesh_node_discover_vendor_features(const char *app_cred, const char *sen
                        strlen(req->net_uuid), net_uuid.uuid, 16);
 
        dest = req->unicast;
+       BT_INFO("Mesh: Get Vendor Features for Remote Node Unicast [0x%2.2x]", dest);
 
        /* Check pending request */
        if (_bt_mesh_check_pending_request(MESH_OPCODE_DEV_COMP_GET,
@@ -1560,6 +1770,7 @@ int _bt_mesh_node_discover_vendor_features(const char *app_cred, const char *sen
                return BLUETOOTH_ERROR_DEVICE_BUSY;
        }
 
+       BT_INFO("Mesh: Browse Remote Node: Unicast [0x%2.2x]", dest);
        /* Get Subnet index of the rmeote node for TX encryption */
        netkey_idx = _bt_mesh_node_get_subnet_idx(net_uuid.uuid, dest);
        if (netkey_idx == MESH_NET_IDX_INVALID)
@@ -1615,6 +1826,7 @@ int _bt_mesh_browse_remote_node(const char *app_cred,
                        dev_uuid.uuid, &dest))
                return BLUETOOTH_ERROR_INTERNAL;
 
+       BT_INFO("Mesh: Browse Remote Node: Unicast [0x%2.2x]", dest);
        /* Check pending request */
        if (_bt_mesh_check_pending_request(MESH_OPCODE_DEV_COMP_GET,
                        dest, net_uuid.uuid)) {
@@ -1662,25 +1874,28 @@ int _bt_mesh_model_configure_group_subscription(const char *app_cred,
                return BLUETOOTH_ERROR_DEVICE_BUSY;
        }
 
+       BT_INFO("Mesh: group Subscription Req: [%d]", req->op);
        if (req->op != BLUETOOTH_MESH_MODEL_SUB_DELETE_ALL) {
+               BT_INFO("Mesh: group Subscription Addr [0x%2.2x]", req->sub_addr);
+
                /* Subscriptio address sanity check */
-               if ((!MESH_IS_GROUP(req->sub_addr) ||
-                       MESH_IS_ALL_NODES(req->sub_addr)) ||
+               if (!MESH_IS_GROUP(req->sub_addr) ||
                                MESH_IS_VIRTUAL(req->sub_addr)) {
-                       BT_ERR("Mesh: Bad subscription address %x\n",
+                       BT_ERR("Mesh: Bad subscription address [0x%2.2x\n]",
                                req->sub_addr);
                        return BLUETOOTH_ERROR_INVALID_PARAM;
                }
-       }
+       } else
+               BT_INFO("Mesh: group Subscription Req: Delete All");
 
+       _bt_mesh_util_convert_string_to_hex(req->net_uuid,
+               strlen(req->net_uuid), net_uuid.uuid, 16);
        /* Get Subnet index of the remote node for TX encryption */
        netkey_idx = _bt_mesh_node_get_subnet_idx(net_uuid.uuid,
                                req->primary_unicast);
        if (netkey_idx == MESH_NET_IDX_INVALID)
                return BLUETOOTH_ERROR_INTERNAL;
 
-       _bt_mesh_util_convert_string_to_hex(req->net_uuid,
-               strlen(req->net_uuid), net_uuid.uuid, 16);
 
        if (req->op == BLUETOOTH_MESH_MODEL_SUB_ADD)
                opcode = MESH_OPCODE_CONFIG_MODEL_SUB_ADD;
@@ -1700,6 +1915,8 @@ int _bt_mesh_model_configure_group_subscription(const char *app_cred,
 
        data_len = _bt_mesh_util_opcode_set(opcode, buffer);
 
+       BT_INFO("Mesh: Group Subscription Primary unicast [0x%2.2x]",
+                       req->primary_unicast);
        /* Element Address */
        l_put_le16((req->primary_unicast + req->elem_index),
                        buffer + data_len);
@@ -1711,6 +1928,7 @@ int _bt_mesh_model_configure_group_subscription(const char *app_cred,
                data_len += 2;
        }
 
+       BT_INFO("Mesh: Group Subscription Model ID [0x%4.4x]", req->model);
        /* Insert Model ID */
         if (req->model >= 0xFFFF0000) {
                /* 1st 2 octet Company ID is 0xFFFF means, it is BT SIG Model*/
@@ -1732,6 +1950,7 @@ int _bt_mesh_model_configure_group_subscription(const char *app_cred,
                return BLUETOOTH_ERROR_INTERNAL;
        }
 
+       BT_INFO("Mesh: Group Subscription Command sent successfully");
        /* Queue the request with timeout */
        __bt_mesh_add_request(opcode, req->primary_unicast,
                net_uuid.uuid,
@@ -1761,16 +1980,19 @@ int _bt_mesh_model_configure_virtual_group_subscription(
        _bt_mesh_util_convert_string_to_hex(req->net_uuid,
                strlen(req->net_uuid), net_uuid.uuid, 16);
 
+       BT_INFO("Mesh: Virtual Group Subscription Req: [%d] Group Addr [0x%2.2x]",
+                       req->op, req->sub_addr);
+
        if (req->op != BLUETOOTH_MESH_MODEL_SUB_DELETE_ALL) {
                /* Subscription address sanity check */
-               if ((MESH_IS_GROUP(req->sub_addr) ||
-                       MESH_IS_ALL_NODES(req->sub_addr)) ||
+               if (MESH_IS_GROUP(req->sub_addr) ||
                                !(MESH_IS_VIRTUAL(req->sub_addr))) {
-                       BT_ERR("Mesh: Bad Virtual subscription address %x\n",
+                       BT_ERR("Mesh: Bad Virtual Group subscription address [0x%2.2x\n]",
                                req->sub_addr);
                        return BLUETOOTH_ERROR_INVALID_PARAM;
                }
-       }
+       } else
+               BT_INFO("Mesh: Virtual Group Subscription Req: Delete All");
 
        /* Get Subnet index of the remote node for TX encryption */
        netkey_idx = _bt_mesh_node_get_subnet_idx(net_uuid.uuid,
@@ -1779,13 +2001,13 @@ int _bt_mesh_model_configure_virtual_group_subscription(
                return BLUETOOTH_ERROR_INTERNAL;
 
        if (req->op == BLUETOOTH_MESH_MODEL_SUB_ADD)
-               opcode = MESH_OPCODE_CONFIG_MODEL_SUB_ADD;
+               opcode = MESH_OPCODE_CONFIG_MODEL_SUB_VIRT_ADD;
        else if (req->op == BLUETOOTH_MESH_MODEL_SUB_DELETE)
-               opcode = MESH_OPCODE_CONFIG_MODEL_SUB_DELETE;
+               opcode = MESH_OPCODE_CONFIG_MODEL_SUB_VIRT_DELETE;
+       else if (req->op == BLUETOOTH_MESH_MODEL_SUB_OVERWRITE)
+               opcode = MESH_OPCODE_CONFIG_MODEL_SUB_VIRT_OVERWRITE;
        else if (req->op == BLUETOOTH_MESH_MODEL_SUB_DELETE_ALL)
                opcode = MESH_OPCODE_CONFIG_MODEL_SUB_DELETE_ALL;
-       else if (req->op == BLUETOOTH_MESH_MODEL_SUB_OVERWRITE)
-               opcode = MESH_OPCODE_CONFIG_MODEL_SUB_OVERWRITE;
 
        /* Check pending request */
        if (_bt_mesh_check_pending_request(opcode,
@@ -1812,6 +2034,7 @@ int _bt_mesh_model_configure_virtual_group_subscription(
                data_len += 16;
        }
 
+       BT_INFO("Mesh: Virtual Group Subscription Model ID [0x%4.4x]", req->model);
        /* Insert Model ID */
         if (req->model >= 0xFFFF0000) {
                /* 1st 2 octet Company ID is 0xFFFF means, it is BT SIG Model*/
@@ -1834,6 +2057,7 @@ int _bt_mesh_model_configure_virtual_group_subscription(
                return BLUETOOTH_ERROR_INTERNAL;
        }
 
+       BT_INFO("Mesh: Virtual Group Subscription Command sent successfully");
        /* Queue the request with timeout */
        __bt_mesh_add_request(opcode, req->primary_unicast,
                net_uuid.uuid,
@@ -1938,7 +2162,7 @@ int _bt_mesh_model_set_publication(const char *app_cred, const char *sender,
 
        if (req->pub_addr != MESH_UNASSIGNED_ADDRESS) {
                if (MESH_IS_VIRTUAL(req->pub_addr)) {
-                       if(!_bt_mesh_network_get_label_uuid_from_sub_addr(
+                       if (!_bt_mesh_network_get_label_uuid_from_sub_addr(
                                        net_uuid.uuid, req->pub_addr, label_uuid))
                                return BLUETOOTH_ERROR_INVALID_PARAM;
                        opcode = MESH_OPCODE_CONFIG_MODEL_PUB_VIRT_SET;
@@ -2059,13 +2283,14 @@ int _bt_mesh_node_model_get_subscription_list(const char *app_cred, const char *
        l_put_le16((req->primary_unicast + req->elem_index), buffer + data_len);
        data_len += 2;
 
-
        /* Insert Model ID */
        if (opcode == MESH_OPCODE_CONFIG_MODEL_SUB_GET) {
+               BT_INFO("Mesh: Get Subscription List for BT SIG Model");
                /* 1st 2 octet Company ID is 0xFFFF means, it is BT SIG Model*/
                l_put_le16(req->model & 0x0000FFFF, buffer + data_len);
                data_len += 2;
        } else {
+               BT_INFO("Mesh: Get Subscription List for Vendor Model");
                /* Vendor Model, 1st 2 octetes: Company ID, next 2 octets: Vendor Model ID */
                l_put_le16(req->model & 0xFFFF0000, buffer + data_len);
                data_len += 2;
@@ -2160,6 +2385,63 @@ int _bt_mesh_node_model_get_appkey_list(const char *app_cred, const char *sender
        return BLUETOOTH_ERROR_NONE;
 }
 
+int _bt_mesh_network_reset_node(const char *app_cred, const char *sender,
+               bluetooth_mesh_node_info_t *node)
+{
+       int ret = OAL_STATUS_SUCCESS;
+       uint16_t netkey_idx;
+       oal_uuid_t net_uuid;
+       uint16_t data_len;
+       uint8_t buffer[MESH_CONFIG_BUFFER_MAX_LEN];
+
+       /* If Scanning is going on */
+       if (_bt_mesh_is_provisioning() ||
+                       _bt_mesh_is_scanning()) {
+               BT_ERR("Device is buzy..");
+               return BLUETOOTH_ERROR_DEVICE_BUSY;
+       }
+
+       _bt_mesh_util_convert_string_to_hex(node->net_uuid,
+                       strlen(node->net_uuid), net_uuid.uuid, 16);
+
+       /* Check pending request */
+       if (_bt_mesh_check_pending_request(MESH_OPCODE_NODE_RESET,
+                               node->primary_unicast, net_uuid.uuid)) {
+               BT_ERR("Device is buzy..");
+               return BLUETOOTH_ERROR_DEVICE_BUSY;
+       }
+       BT_INFO("Mesh: Reset a remote Node [0x%2.2x] Elem Cnt [0x%2.2x]",
+                       node->primary_unicast, node->num_elements);
+       /* Get Subnet index of the remote node for TX encryption */
+       netkey_idx = _bt_mesh_node_get_subnet_idx(net_uuid.uuid, node->primary_unicast);
+       if (netkey_idx == MESH_NET_IDX_INVALID)
+               return BLUETOOTH_ERROR_INTERNAL;
+
+       data_len = _bt_mesh_util_opcode_set(MESH_OPCODE_NODE_RESET, buffer);
+
+       /* Send Node Reset command 5 times to ensure reliability */
+       for (int i = 0; i < 5; i++)
+               ret = mesh_conf_send_message(&net_uuid, node->primary_unicast,
+                               true, netkey_idx, buffer, data_len);
+
+       if (ret != OAL_STATUS_SUCCESS) {
+               BT_ERR("Mesh: Node Reset Failed!: %d", ret);
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       BT_INFO("Mesh: Node reset Done, Send Delete req: Unicast[0x%2.2x]",
+                       node->primary_unicast);
+
+       ret = mesh_delete_remote_node(&net_uuid, node->primary_unicast,
+                       node->num_elements);
+       if (ret != OAL_STATUS_SUCCESS) {
+               BT_ERR("Mesh: Remote Node Deletion Failed!: %d", ret);
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       return _bt_mesh_network_remove_node_configuration(node);
+}
+
 int _bt_mesh_node_model_appkey_execute(const char *app_cred, const char *sender,
                bluetooth_mesh_model_configure_t *req)
 {
@@ -2290,7 +2572,7 @@ static bool __bt_mesh_check_pending_key_cmd(uint16_t dest, bool is_netkey,
        const struct mesh_config_cmd *cmd;
 
        if (is_netkey) {
-               switch(op) {
+               switch (op) {
                case BLUETOOTH_MESH_NODE_KEY_ADD:
                        cmd = __mesh_get_command(MESH_OPCODE_NETKEY_ADD);
                        if (!cmd)
@@ -2323,7 +2605,7 @@ static bool __bt_mesh_check_pending_key_cmd(uint16_t dest, bool is_netkey,
                        return false;
                }
        } else {
-               switch(op) {
+               switch (op) {
                case BLUETOOTH_MESH_NODE_KEY_ADD:
                        cmd = __mesh_get_command(MESH_OPCODE_APPKEY_ADD);
                        if (!cmd)
@@ -2424,7 +2706,7 @@ int _bt_mesh_node_configure_key(const char *app_cred, const char *sender,
                /* Handle Key (App/Net) Update & Add Commands: Key Config message  */
                update = (opcode == MESH_OPCODE_NETKEY_UPDATE || opcode == MESH_OPCODE_APPKEY_UPDATE);
                ret = mesh_conf_send_key_message(&net_uuid, req->primary_unicast, req->is_netkey,
-                               update, req->is_netkey? req->netkey_idx: req->appkey_idx, netkey_idx);
+                               update, req->is_netkey ? req->netkey_idx : req->appkey_idx, netkey_idx);
        }
        if (ret != OAL_STATUS_SUCCESS) {
                BT_ERR("ret: %d", ret);