[PATCH BlueZ v2 2/2] mesh: Add org.bluez.mesh.Node1.Addresses property

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



To enable applications to talk to the local node's internal models, it's
useful to know its unicast addresses. They are known after CreateNetwork
and Import, but after Join, the allocated address is only known to the
provisioner.

This patch enables read only access to list of allocated unicast
addresses.
---
 doc/mesh-api.txt |  4 ++++
 mesh/node.c      | 24 ++++++++++++++++++++++++
 2 files changed, 28 insertions(+)

diff --git a/doc/mesh-api.txt b/doc/mesh-api.txt
index 255104ab6..470751f7a 100644
--- a/doc/mesh-api.txt
+++ b/doc/mesh-api.txt
@@ -423,6 +423,10 @@ Properties:
 		seconds since mesh network layer traffic was last detected on
 		this node's network.
 
+	array{uint16} Addresses [read-only]
+
+		This property contains unicast addresses of node's elements.
+
 Mesh Provisioning Hierarchy
 ============================
 Service		org.bluez.mesh
diff --git a/mesh/node.c b/mesh/node.c
index 3d9ded3b1..b6824f505 100644
--- a/mesh/node.c
+++ b/mesh/node.c
@@ -2198,6 +2198,28 @@ static bool lastheard_getter(struct l_dbus *dbus, struct l_dbus_message *msg,
 
 }
 
+static bool addresses_getter(struct l_dbus *dbus, struct l_dbus_message *msg,
+					struct l_dbus_message_builder *builder,
+					void *user_data)
+{
+	struct mesh_node *node = user_data;
+	const struct l_queue_entry *entry;
+
+	l_dbus_message_builder_enter_array(builder, "q");
+
+	entry = l_queue_get_entries(node->elements);
+	for (; entry; entry = entry->next) {
+		const struct node_element *ele = entry->data;
+		uint16_t address = node->primary + ele->idx;
+
+		l_dbus_message_builder_append_basic(builder, 'q', &address);
+	}
+
+	l_dbus_message_builder_leave_array(builder);
+
+	return true;
+}
+
 static void setup_node_interface(struct l_dbus_interface *iface)
 {
 	l_dbus_interface_method(iface, "Send", 0, send_call, "", "oqqay",
@@ -2222,6 +2244,8 @@ static void setup_node_interface(struct l_dbus_interface *iface)
 									NULL);
 	l_dbus_interface_property(iface, "SecondsSinceLastHeard", 0, "u",
 					lastheard_getter, NULL);
+	l_dbus_interface_property(iface, "Addresses", 0, "aq", addresses_getter,
+									NULL);
 }
 
 bool node_dbus_init(struct l_dbus *bus)
-- 
2.19.1




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux