2020-06-15 12:44:46

by Michał Lowas-Rzechonek

[permalink] [raw]
Subject: [PATCH BlueZ] mesh: Change BeaconFlags property type to a dict

Instead of a binary value, return a dictionary consistent with
"flags" argument used in Import().
---
doc/mesh-api.txt | 18 ++++++++++++++----
mesh/node.c | 13 +++++++++++--
2 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/doc/mesh-api.txt b/doc/mesh-api.txt
index 7fbab32b6..26bc92807 100644
--- a/doc/mesh-api.txt
+++ b/doc/mesh-api.txt
@@ -431,11 +431,21 @@ Properties:
This property indicates whether the periodic beaconing is
enabled (true) or disabled (false).

- uint8 BeaconFlags [read-only]
+ dict BeaconFlags [read-only]

- This property may be read at any time to determine the flag
- field setting on sent and received beacons of the primary
- network key.
+ This property may be read at any time to determine the flags
+ used in network beacons of the primary network key. Supported
+ values are:
+
+ boolean IvUpdate
+
+ When true, indicates that the network is in the
+ middle of IV Index Update procedure.
+
+ boolean KeyRefresh
+
+ When true, indicates that the network is in the
+ middle of a key refresh procedure.

uint32 IvIndex [read-only]

diff --git a/mesh/node.c b/mesh/node.c
index 6140fdf9f..87a85a44d 100644
--- a/mesh/node.c
+++ b/mesh/node.c
@@ -32,6 +32,7 @@
#include "mesh/mesh-defs.h"
#include "mesh/mesh.h"
#include "mesh/net.h"
+#include "mesh/net-keys.h"
#include "mesh/appkey.h"
#include "mesh/mesh-config.h"
#include "mesh/provision.h"
@@ -2191,10 +2192,18 @@ static bool beaconflags_getter(struct l_dbus *dbus, struct l_dbus_message *msg,
struct mesh_net *net = node_get_net(node);
uint8_t flags;
uint32_t iv_index;
+ bool ivu;
+ bool kr;

mesh_net_get_snb_state(net, &flags, &iv_index);

- l_dbus_message_builder_append_basic(builder, 'y', &flags);
+ ivu = flags & IV_INDEX_UPDATE;
+ kr = flags & KEY_REFRESH;
+
+ l_dbus_message_builder_enter_array(builder, "{sv}");
+ dbus_append_dict_entry_basic(builder, "IvUpdate", "b", &ivu);
+ dbus_append_dict_entry_basic(builder, "KeyRefresh", "b", &kr);
+ l_dbus_message_builder_leave_array(builder);

return true;
}
@@ -2295,7 +2304,7 @@ static void setup_node_interface(struct l_dbus_interface *iface)
l_dbus_interface_property(iface, "Features", 0, "a{sv}", features_getter,
NULL);
l_dbus_interface_property(iface, "Beacon", 0, "b", beacon_getter, NULL);
- l_dbus_interface_property(iface, "BeaconFlags", 0, "y",
+ l_dbus_interface_property(iface, "BeaconFlags", 0, "a{sv}",
beaconflags_getter, NULL);
l_dbus_interface_property(iface, "IvIndex", 0, "u", ivindex_getter,
NULL);
--
2.20.1