Mesh: Fix bug in Network load API 14/242414/1
authorAnupam <anupam.r@samsung.com>
Wed, 26 Aug 2020 17:48:14 +0000 (23:18 +0530)
committerAnupam <anupam.r@samsung.com>
Wed, 26 Aug 2020 17:52:00 +0000 (23:22 +0530)
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 <anupam.r@samsung.com>
src/bluetooth-mesh.c

index ba000bc..b360a12 100644 (file)
@@ -1299,7 +1299,20 @@ int bt_mesh_network_create(bt_mesh_node_h config_client,
        }
 
        memset(&param_node, 0x00, sizeof(bluetooth_mesh_node_t));
-       memcpy(&param_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;
 }