Mesh: Add Node Reset API in FRWK
[platform/core/connectivity/bluetooth-frwk.git] / bt-service / services / mesh / bt-service-mesh-network.c
index 9b32131..976e5a8 100644 (file)
@@ -188,6 +188,41 @@ int _bt_mesh_network_request_provisioning_data_request(uint8_t net_uuid[],
        return BLUETOOTH_ERROR_NONE;
 }
 
+int _bt_mesh_network_remove_node_configuration(
+               bluetooth_mesh_node_info_t *node)
+{
+       GSList *l;
+       _bt_mesh_cdb_t *cdb_cfg = NULL;
+       uint8_t net_uuid[16];
+       BT_INFO("Mesh: Remove Node Configuration: Unicast [0x%2.2x]",
+                       node->primary_unicast);
+
+       _bt_mesh_util_convert_string_to_hex(node->net_uuid,
+                       strlen(node->net_uuid), net_uuid, 16);
+
+       /* Find CDB */
+       l = g_slist_find_custom(cdb_list, net_uuid,
+                       __mesh_compare_app_network_uuid);
+       if (!l) {
+               BT_ERR("Mesh: Could not find Network Entry: unexpected!!");
+               return BLUETOOTH_ERROR_INVALID_PARAM;
+       }
+
+       cdb_cfg = (_bt_mesh_cdb_t*)l->data;
+
+       if (_bt_mesh_conf_delete_node(cdb_cfg, node->primary_unicast)) {
+               BT_INFO("Mesh: Node Entry deleted from Config DB");
+               if (!_bt_mesh_node_del_node(cdb_cfg,  node->primary_unicast)) {
+                       BT_ERR("Mesh: Node Entry could not be unloaded from memory");
+                       return BLUETOOTH_ERROR_INTERNAL;
+               }
+       } else {
+               BT_ERR("Mesh: Node Entry could not be deleted from Config DB");
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+       return BLUETOOTH_ERROR_NONE;
+}
+
 int _bt_mesh_network_remove_net_configuration(
                bluetooth_mesh_network_t *net)
 {