mesh: Add api to release node dbus resources 97/241897/2 accepted/tizen/unified/20200825.142910 submit/tizen/20200821.002054
authorAnupam Roy <anupam.r@samsung.com>
Thu, 20 Aug 2020 15:34:50 +0000 (21:04 +0530)
committerAnupam Roy <anupam.r@samsung.com>
Thu, 20 Aug 2020 16:18:49 +0000 (16:18 +0000)
Currently, there is no way to release the node
and attach it back without disconnection of
dbus client. It is possible that dbus client
is owner of multiple mesh nodes and it intends
to stop using one or multiple nodes & re-attach
them back without disconnecting from dbus.

This patch introduces a Release API through which
dbus client can request to release the node's
dbus resources. dbus client can attach the node
after releasing it at any point of time.

Change-Id: I9ffb2588f1c1dc5d2ccbe45ab5c447ed916c593f
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
doc/mesh-api.txt
mesh/mesh.c
mesh/node.c
mesh/node.h

index 24cface..e71cf78 100644 (file)
@@ -127,6 +127,18 @@ Methods:
                PossibleErrors:
                        org.bluez.mesh.Error.InvalidArguments
 
+       void Release(uint64 token)
+
+               This removes the dbus resources of the mesh node
+               identified by the 64-bit token parameter. The token parameter
+               has been obtained as a result of successful Join() method call.
+               The mesh node whose dbus resources are removed can be attached back to
+               network by Attach() call.
+
+               PossibleErrors:
+                       org.bluez.mesh.Error.InvalidArguments,
+                       org.bluez.mesh.Error.NotFound
+
        void CreateNetwork(object app_root, array{byte}[16] uuid)
 
                This is the first method that an application calls to become
index c1eeeaa..c744ddf 100644 (file)
@@ -665,6 +665,29 @@ static struct l_dbus_message *leave_call(struct l_dbus *dbus,
        return l_dbus_message_new_method_return(msg);
 }
 
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+static struct l_dbus_message *release_call(struct l_dbus *dbus,
+                                               struct l_dbus_message *msg,
+                                               void *user_data)
+{
+       uint64_t token;
+       struct mesh_node *node;
+
+       l_debug("Release");
+
+       if (!l_dbus_message_get_arguments(msg, "t", &token))
+               return dbus_error(msg, MESH_ERROR_INVALID_ARGS, NULL);
+
+       node = node_find_by_token(token);
+
+       if (!node)
+               return dbus_error(msg, MESH_ERROR_NOT_FOUND, NULL);
+
+       node_release_resources(node);
+       return l_dbus_message_new_method_return(msg);
+}
+#endif
+
 static void create_join_complete_reply_cb(struct l_dbus_message *message,
                                                                void *user_data)
 {
@@ -848,6 +871,11 @@ static void setup_network_interface(struct l_dbus_interface *iface)
        l_dbus_interface_method(iface, "Leave", 0, leave_call, "", "t",
                                                                "token");
 
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+       l_dbus_interface_method(iface, "Release", 0, release_call, "", "t",
+                                                               "token");
+#endif
+
        l_dbus_interface_method(iface, "CreateNetwork", 0, create_network_call,
                                        "", "oay", "app", "uuid");
 
index 66b9c41..cd3dd78 100644 (file)
@@ -340,6 +340,22 @@ static void free_node_resources(void *data)
        l_free(node);
 }
 
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+/*
+ * This function is called to free resources
+ */
+void node_release_resources(struct mesh_node *node)
+{
+       if (!node)
+               return;
+
+       /* Free dynamic resources */
+       free_node_dbus_resources(node);
+
+       l_debug("Node DBUS Resources are removed");
+}
+#endif
+
 /*
  * This function is called to free resources and remove the
  * configuration files for the specified node.
index 290681e..7a51205 100644 (file)
@@ -31,6 +31,9 @@ typedef void (*node_join_ready_func_t) (struct mesh_node *node,
                                                struct mesh_agent *agent);
 
 void node_remove(struct mesh_node *node);
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+void node_release_resources(struct mesh_node *node);
+#endif
 void node_join(const char *app_root, const char *sender, const uint8_t *uuid,
                                                node_join_ready_func_t cb);
 uint8_t *node_uuid_get(struct mesh_node *node);