summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnupam Roy <anupam.r@samsung.com>2020-08-20 21:04:50 +0530
committerAnupam Roy <anupam.r@samsung.com>2020-08-20 16:18:49 +0000
commit0bdea44b72d68068ff2d21774cfe9afd0bcea8ce (patch)
tree8faccb6750b3254faaa1a1ca85b8588ba974b9cb
parentb6d47eb967457a3a64a3898f8d6d5179cd564e3b (diff)
downloadbluez-0bdea44b72d68068ff2d21774cfe9afd0bcea8ce.tar.gz
bluez-0bdea44b72d68068ff2d21774cfe9afd0bcea8ce.tar.bz2
bluez-0bdea44b72d68068ff2d21774cfe9afd0bcea8ce.zip
mesh: Add api to release node dbus resourcessubmit/tizen/20200821.002054accepted/tizen/unified/20200825.142910
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>
-rw-r--r--doc/mesh-api.txt12
-rw-r--r--mesh/mesh.c28
-rw-r--r--mesh/node.c16
-rw-r--r--mesh/node.h3
4 files changed, 59 insertions, 0 deletions
diff --git a/doc/mesh-api.txt b/doc/mesh-api.txt
index 24cface2..e71cf784 100644
--- a/doc/mesh-api.txt
+++ b/doc/mesh-api.txt
@@ -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
diff --git a/mesh/mesh.c b/mesh/mesh.c
index c1eeeaa8..c744ddf5 100644
--- a/mesh/mesh.c
+++ b/mesh/mesh.c
@@ -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");
diff --git a/mesh/node.c b/mesh/node.c
index 66b9c41b..cd3dd78b 100644
--- a/mesh/node.c
+++ b/mesh/node.c
@@ -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.
diff --git a/mesh/node.h b/mesh/node.h
index 290681e2..7a51205e 100644
--- a/mesh/node.h
+++ b/mesh/node.h
@@ -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);