From 37e6455004ab9a27a2eae3c2e087f6ecf48d9775 Mon Sep 17 00:00:00 2001 From: Anupam Date: Wed, 26 Aug 2020 23:18:14 +0530 Subject: [PATCH] Mesh: Fix bug in Network load API This patch handles following:- - Network handle was not returned after Networking loading is successful. - Vendor & Feature informations were not initialized. Change-Id: I929e95f30f78d5b59bee592be6d0620e28a74153 Signed-off-by: Anupam --- src/bluetooth-mesh.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/bluetooth-mesh.c b/src/bluetooth-mesh.c index ba000bc..b360a12 100644 --- a/src/bluetooth-mesh.c +++ b/src/bluetooth-mesh.c @@ -1299,7 +1299,20 @@ int bt_mesh_network_create(bt_mesh_node_h config_client, } memset(¶m_node, 0x00, sizeof(bluetooth_mesh_node_t)); - memcpy(¶m_node.vendor_info, &(node->features), sizeof(node->features)); + param_node.vendor_info.companyid = node->features.cid; + param_node.vendor_info.vendorid = node->features.pid; + param_node.vendor_info.versionid = node->features.vid; + param_node.vendor_info.crpl = node->features.crpl; + + if (node->features.features & BT_MESH_FEATURE_RELAY) + param_node.vendor_info.relay = 1; + if (node->features.features & BT_MESH_FEATURE_PROXY) + param_node.vendor_info.proxy = 1; + if (node->features.features & BT_MESH_FEATURE_FRIEND) + param_node.vendor_info.frnd = 1; + if (node->features.features & BT_MESH_FEATURE_LOWPOWER) + param_node.vendor_info.lpn = 1; + param_node.num_elements = g_slist_length(node->elements); param_node.primary_unicast = 0x0001; _bt_get_random_bytes(param_node.uuid, 16); @@ -1414,6 +1427,7 @@ int bt_mesh_network_load(const char *token, bt_mesh_network_h *network) g_strlcpy(network_s->name, net.name.name, BT_MESH_NETWORK_NAME_STRING_MAX_LEN + 1); networks = g_slist_append(networks, network_s); + *network = (bt_mesh_network_h)network_s; FUNC_EXIT; return error_code; } -- 2.7.4