2018-03-16 07:42:19

by Atul Kumar Rai

[permalink] [raw]
Subject: [PATCH] Mesh: add 'node-reset' command

This patch adds 'node-reset' command which can be used to reset a
node (other than a Provisioner) and remove it from the network.
---
mesh/config-client.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)

diff --git a/mesh/config-client.c b/mesh/config-client.c
index 19e617d..7cb8a37 100644
--- a/mesh/config-client.c
+++ b/mesh/config-client.c
@@ -342,6 +342,17 @@ static bool client_msg_recvd(uint16_t src, uint8_t *data,
bt_shell_printf("Min Hops\t%2.2x\n", data[7]);
bt_shell_printf("Max Hops\t%2.2x\n", data[8]);
break;
+
+ /* Per Mesh Profile 4.3.2.54 */
+ case OP_NODE_RESET_STATUS:
+ bt_shell_printf("Node %4.4x reset status %s\n",
+ src, mesh_status_str(data[0]));
+
+ net_release_address(node_get_primary(node),
+ (node_get_num_elements(node) - 1));
+ /* TODO: Remove node info from database */
+ node_free(node);
+ break;
}

return true;
@@ -1124,6 +1135,11 @@ static void cmd_ttl_get(int argc, char *argv[])
cmd_default(OP_CONFIG_DEFAULT_TTL_GET);
}

+static void cmd_node_reset(int argc, char *argv[])
+{
+ cmd_default(OP_NODE_RESET);
+}
+
static const struct bt_shell_menu cfg_menu = {
.name = "config",
.desc = "Configuration Model Submenu",
@@ -1179,6 +1195,8 @@ static const struct bt_shell_menu cfg_menu = {
cmd_sub_add, "Add subscription"},
{"sub-get", "<ele_addr> <model id>",
cmd_sub_get, "Get subscription"},
+ {"node-reset", NULL, cmd_node_reset,
+ "reset a node and remove it from network"},
{} },
};

--
2.7.4



2018-03-16 19:26:47

by Stotland, Inga

[permalink] [raw]
Subject: Re: [PATCH] Mesh: add 'node-reset' command

Hi Atul,

On Fri, 2018-03-16 at 13:12 +0530, Atul Rai wrote:
> This patch adds 'node-reset' command which can be used to reset a
> node (other than a Provisioner) and remove it from the network.
> ---
> mesh/config-client.c | 18 ++++++++++++++++++
> 1 file changed, 18 insertions(+)
>
> diff --git a/mesh/config-client.c b/mesh/config-client.c
> index 19e617d..7cb8a37 100644
> --- a/mesh/config-client.c
> +++ b/mesh/config-client.c
> @@ -342,6 +342,17 @@ static bool client_msg_recvd(uint16_t src,
> uint8_t *data,
> bt_shell_printf("Min Hops\t%2.2x\n", data[7]);
> bt_shell_printf("Max Hops\t%2.2x\n", data[8]);
> break;
> +
> + /* Per Mesh Profile 4.3.2.54 */
> + case OP_NODE_RESET_STATUS:
> + bt_shell_printf("Node %4.4x reset status %s\n",
> + src, mesh_status_str(data[0]));
> +
> + net_release_address(node_get_primary(node),
> + (node_get_num_elements(node) - 1));
> + /* TODO: Remove node info from database */
> + node_free(node);
> + break;
> }
>
> return true;
> @@ -1124,6 +1135,11 @@ static void cmd_ttl_get(int argc, char
> *argv[])
> cmd_default(OP_CONFIG_DEFAULT_TTL_GET);
> }
>
> +static void cmd_node_reset(int argc, char *argv[])
> +{
> + cmd_default(OP_NODE_RESET);
> +}
> +
> static const struct bt_shell_menu cfg_menu = {
> .name = "config",
> .desc = "Configuration Model Submenu",
> @@ -1179,6 +1195,8 @@ static const struct bt_shell_menu cfg_menu = {
> cmd_sub_add, "Add subscription"},
> {"sub-get", "<ele_addr> <model id>",
> cmd_sub_get, "Get subscription"},
> + {"node-reset", NULL, cmd_no
> de_reset,

Please change leading white spaces to tabs in the line below and
capitalize "Reset" in the command description for consistency.
> + "reset a node and remove it
> from network"},
> {} },
> };
>

This looks good, just needs a little style fix.

Regards,
Inga


Attachments:
smime.p7s (3.19 kB)