2019-06-28 08:28:16

by Michał Lowas-Rzechonek

[permalink] [raw]
Subject: [PATCH BlueZ 1/2] mesh: Fix D-Bus node path

According to doc/mesh-api.txt, node object should be located at
/org/bluez/mesh/node.
---
mesh/node.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mesh/node.c b/mesh/node.c
index c2feaee52..45383b7d5 100644
--- a/mesh/node.c
+++ b/mesh/node.c
@@ -47,7 +47,6 @@
#define MIN_COMP_SIZE 14

#define MESH_NODE_PATH_PREFIX "/node"
-#define MESH_ELEMENT_PATH_PREFIX "/ele"

/* Default values for a new locally created node */
#define DEFAULT_NEW_UNICAST 0x0001
@@ -1021,7 +1020,8 @@ static bool register_node_object(struct mesh_node *node)
if (!hex2str(node->uuid, sizeof(node->uuid), uuid, sizeof(uuid)))
return false;

- node->path = l_strdup_printf(MESH_NODE_PATH_PREFIX "%s", uuid);
+ node->path = l_strdup_printf(BLUEZ_MESH_PATH MESH_NODE_PATH_PREFIX
+ "%s", uuid);

if (!l_dbus_object_add_interface(dbus_get_bus(), node->path,
MESH_NODE_INTERFACE, node))
--
2.19.1


2019-06-28 08:30:17

by Michał Lowas-Rzechonek

[permalink] [raw]
Subject: [PATCH BlueZ 2/2] mesh: Register D-Bus management interface

When application Attach()es itself, start exposing both Node1 and
Management1 D-Bus interfaces.
---
mesh/node.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/mesh/node.c b/mesh/node.c
index 45383b7d5..a2ac747a1 100644
--- a/mesh/node.c
+++ b/mesh/node.c
@@ -259,9 +259,14 @@ static void free_node_resources(void *data)
if (node->disc_watch)
l_dbus_remove_watch(dbus_get_bus(), node->disc_watch);

- if (node->path)
+ if (node->path) {
l_dbus_object_remove_interface(dbus_get_bus(), node->path,
MESH_NODE_INTERFACE);
+
+ l_dbus_object_remove_interface(dbus_get_bus(), node->path,
+ MESH_MANAGEMENT_INTERFACE);
+ }
+
l_free(node->path);

l_free(node);
@@ -434,6 +439,7 @@ void node_cleanup_all(void)
{
l_queue_destroy(nodes, cleanup_node);
l_dbus_unregister_interface(dbus_get_bus(), MESH_NODE_INTERFACE);
+ l_dbus_unregister_interface(dbus_get_bus(), MESH_MANAGEMENT_INTERFACE);
}

bool node_is_provisioned(struct mesh_node *node)
@@ -1024,7 +1030,11 @@ static bool register_node_object(struct mesh_node *node)
"%s", uuid);

if (!l_dbus_object_add_interface(dbus_get_bus(), node->path,
- MESH_NODE_INTERFACE, node))
+ MESH_NODE_INTERFACE, node))
+ return false;
+
+ if (!l_dbus_object_add_interface(dbus_get_bus(), node->path,
+ MESH_MANAGEMENT_INTERFACE, node))
return false;

return true;
@@ -1046,6 +1056,9 @@ static void app_disc_cb(struct l_dbus *bus, void *user_data)
if (node->path) {
l_dbus_object_remove_interface(dbus_get_bus(), node->path,
MESH_NODE_INTERFACE);
+
+ l_dbus_object_remove_interface(dbus_get_bus(), node->path,
+ MESH_MANAGEMENT_INTERFACE);
l_free(node->app_path);
node->app_path = NULL;
}
--
2.19.1

2019-07-01 06:22:01

by Stotland, Inga

[permalink] [raw]
Subject: Re: [PATCH BlueZ 1/2] mesh: Fix D-Bus node path

Hi Michal,

On Fri, 2019-06-28 at 10:27 +0200, Michał Lowas-Rzechonek wrote:
> According to doc/mesh-api.txt, node object should be located at
> /org/bluez/mesh/node.
> ---
> mesh/node.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/mesh/node.c b/mesh/node.c
> index c2feaee52..45383b7d5 100644
> --- a/mesh/node.c
> +++ b/mesh/node.c
> @@ -47,7 +47,6 @@
> #define MIN_COMP_SIZE 14
>
> #define MESH_NODE_PATH_PREFIX "/node"
> -#define MESH_ELEMENT_PATH_PREFIX "/ele"
>
> /* Default values for a new locally created node */
> #define DEFAULT_NEW_UNICAST 0x0001
> @@ -1021,7 +1020,8 @@ static bool register_node_object(struct
> mesh_node *node)
> if (!hex2str(node->uuid, sizeof(node->uuid), uuid,
> sizeof(uuid)))
> return false;
>
> - node->path = l_strdup_printf(MESH_NODE_PATH_PREFIX "%s", uuid);
> + node->path = l_strdup_printf(BLUEZ_MESH_PATH
> MESH_NODE_PATH_PREFIX
> + "%s",
> uuid);
>
> if (!l_dbus_object_add_interface(dbus_get_bus(), node->path,
> MESH_NODE_INTERFACE, node))

Good catch.

Brian, coud you please apply?

Thanks,
Inga


Attachments:
smime.p7s (3.19 kB)

2019-07-01 16:55:50

by Gix, Brian

[permalink] [raw]
Subject: Re: [PATCH BlueZ 1/2] mesh: Fix D-Bus node path

Patch Applied

On Fri, 2019-06-28 at 10:27 +0200, Michał Lowas-Rzechonek wrote:
> According to doc/mesh-api.txt, node object should be located at
> /org/bluez/mesh/node.
> ---
> mesh/node.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/mesh/node.c b/mesh/node.c
> index c2feaee52..45383b7d5 100644
> --- a/mesh/node.c
> +++ b/mesh/node.c
> @@ -47,7 +47,6 @@
> #define MIN_COMP_SIZE 14
>
> #define MESH_NODE_PATH_PREFIX "/node"
> -#define MESH_ELEMENT_PATH_PREFIX "/ele"
>
> /* Default values for a new locally created node */
> #define DEFAULT_NEW_UNICAST 0x0001
> @@ -1021,7 +1020,8 @@ static bool register_node_object(struct mesh_node *node)
> if (!hex2str(node->uuid, sizeof(node->uuid), uuid, sizeof(uuid)))
> return false;
>
> - node->path = l_strdup_printf(MESH_NODE_PATH_PREFIX "%s", uuid);
> + node->path = l_strdup_printf(BLUEZ_MESH_PATH MESH_NODE_PATH_PREFIX
> + "%s", uuid);
>
> if (!l_dbus_object_add_interface(dbus_get_bus(), node->path,
> MESH_NODE_INTERFACE, node))

2019-07-01 19:40:34

by Michał Lowas-Rzechonek

[permalink] [raw]
Subject: Re: [PATCH BlueZ 2/2] mesh: Register D-Bus management interface

Hi Inga, Brian,

On 06/28, Michał Lowas-Rzechonek wrote:
> When application Attach()es itself, start exposing both Node1 and
> Management1 D-Bus interfaces.

How about this one? It's needed if the application wants to use remote
device keys imported via ImportRemoteNode API.

regards
--
Michał Lowas-Rzechonek <[email protected]>
Silvair http://silvair.com
Jasnogórska 44, 31-358 Krakow, POLAND

2019-07-01 19:44:51

by Gix, Brian

[permalink] [raw]
Subject: RE: [PATCH BlueZ 2/2] mesh: Register D-Bus management interface

Applied, Thanks.

> -----Original Message-----
> From: [email protected] [mailto:linux-bluetooth-
> [email protected]] On Behalf Of Michal Lowas-Rzechonek
> Sent: Friday, June 28, 2019 1:28 AM
> To: [email protected]
> Cc: Stotland, Inga <[email protected]>
> Subject: [PATCH BlueZ 2/2] mesh: Register D-Bus management interface
>
> When application Attach()es itself, start exposing both Node1 and
> Management1 D-Bus interfaces.
> ---
> mesh/node.c | 17 +++++++++++++++--
> 1 file changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/mesh/node.c b/mesh/node.c
> index 45383b7d5..a2ac747a1 100644
> --- a/mesh/node.c
> +++ b/mesh/node.c
> @@ -259,9 +259,14 @@ static void free_node_resources(void *data)
> if (node->disc_watch)
> l_dbus_remove_watch(dbus_get_bus(), node->disc_watch);
>
> - if (node->path)
> + if (node->path) {
> l_dbus_object_remove_interface(dbus_get_bus(), node->path,
>
> MESH_NODE_INTERFACE);
> +
> + l_dbus_object_remove_interface(dbus_get_bus(), node->path,
> +
> MESH_MANAGEMENT_INTERFACE);
> + }
> +
> l_free(node->path);
>
> l_free(node);
> @@ -434,6 +439,7 @@ void node_cleanup_all(void) {
> l_queue_destroy(nodes, cleanup_node);
> l_dbus_unregister_interface(dbus_get_bus(),
> MESH_NODE_INTERFACE);
> + l_dbus_unregister_interface(dbus_get_bus(),
> +MESH_MANAGEMENT_INTERFACE);
> }
>
> bool node_is_provisioned(struct mesh_node *node) @@ -1024,7 +1030,11
> @@ static bool register_node_object(struct mesh_node *node)
> "%s", uuid);
>
> if (!l_dbus_object_add_interface(dbus_get_bus(), node->path,
> - MESH_NODE_INTERFACE, node))
> + MESH_NODE_INTERFACE,
> node))
> + return false;
> +
> + if (!l_dbus_object_add_interface(dbus_get_bus(), node->path,
> + MESH_MANAGEMENT_INTERFACE,
> node))
> return false;
>
> return true;
> @@ -1046,6 +1056,9 @@ static void app_disc_cb(struct l_dbus *bus, void
> *user_data)
> if (node->path) {
> l_dbus_object_remove_interface(dbus_get_bus(), node->path,
>
> MESH_NODE_INTERFACE);
> +
> + l_dbus_object_remove_interface(dbus_get_bus(), node->path,
> +
> MESH_MANAGEMENT_INTERFACE);
> l_free(node->app_path);
> node->app_path = NULL;
> }
> --
> 2.19.1