Mesh: Add Node Reset API in FRWK
[platform/core/connectivity/bluetooth-frwk.git] / bt-service / services / mesh / bt-service-mesh-nodes.c
index 5bae17f..ca76db9 100644 (file)
@@ -258,6 +258,45 @@ bool _bt_mesh_node_get_element_count(uint8_t net_uuid[],
        return true;
 }
 
+uint8_t _bt_mesh_node_del_node(_bt_mesh_cdb_t *cfg,
+               uint16_t unicast)
+{
+       struct _bt_mesh_node_t *rmt;
+       uint8_t num_ele, i;
+       struct mesh_network_t *network;
+
+       if (!cfg)
+               return 0;
+
+       BT_INFO("Mesh: Uload Node Entry [0x%2.2x]", unicast);
+       network = l_queue_find(networks, __mesh_net_uuid_match, cfg->uuid);
+       if (!network)
+               return 0;
+
+       rmt = l_queue_find(network->nodes,
+                       __mesh_match_node_addr, L_UINT_TO_PTR(unicast));
+       if (!rmt)
+               return 0;
+
+       rmt = l_queue_remove_if(network->nodes, __mesh_match_node_addr,
+                       L_UINT_TO_PTR(unicast));
+       if (!rmt)
+               return 0;
+
+       num_ele = rmt->num_ele;
+
+       for (i = 0; i < num_ele; ++i)
+               l_queue_destroy(rmt->els[i], NULL);
+
+       l_free(rmt->els);
+
+       l_queue_destroy(rmt->net_keys, NULL);
+       l_queue_destroy(rmt->app_keys, NULL);
+       l_free(rmt);
+
+       return num_ele;
+}
+
 bool _bt_mesh_node_add_node(uint8_t net_uuid[],
        const uint8_t node_uuid[16], uint16_t unicast,
                uint8_t ele_cnt, uint16_t net_idx)