summaryrefslogtreecommitdiff
path: root/mesh/node.c
diff options
context:
space:
mode:
authorMichaƂ Lowas-Rzechonek <michal.lowas-rzechonek@silvair.com>2019-08-28 09:52:30 +0200
committerBrian Gix <brian.gix@intel.com>2019-08-28 09:31:15 -0700
commit3d7d12ee99e2ee87f2eb81b291d2b6867a2194ba (patch)
treef4bde0e48149f09329f480305c358dbdc6326e1c /mesh/node.c
parentf370e7298178e19645854e36f04cbc356f6c7d7d (diff)
downloadbluez-3d7d12ee99e2ee87f2eb81b291d2b6867a2194ba.tar.gz
mesh: Add org.bluez.mesh.Node1.Addresses property
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.
Diffstat (limited to 'mesh/node.c')
-rw-r--r--mesh/node.c24
1 files changed, 24 insertions, 0 deletions
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)