* [PATCH v2] Mesh: add 'node-reset' command
[not found] <CGME20180319042513epcas1p444801a5f15a2ff0a547962662433e1f6@epcas1p4.samsung.com>
@ 2018-03-19 4:24 ` Atul Rai
2018-03-19 7:22 ` Stotland, Inga
0 siblings, 1 reply; 2+ messages in thread
From: Atul Rai @ 2018-03-19 4:24 UTC (permalink / raw)
To: linux-bluetooth; +Cc: sachin.dev, anupam.r
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..29950dc 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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] Mesh: add 'node-reset' command
2018-03-19 4:24 ` [PATCH v2] Mesh: add 'node-reset' command Atul Rai
@ 2018-03-19 7:22 ` Stotland, Inga
0 siblings, 0 replies; 2+ messages in thread
From: Stotland, Inga @ 2018-03-19 7:22 UTC (permalink / raw)
To: a.rai@samsung.com, linux-bluetooth@vger.kernel.org
Cc: anupam.r@samsung.com, sachin.dev@samsung.com
[-- Attachment #1: Type: text/plain, Size: 1979 bytes --]
Hi Atul,
On Mon, 2018-03-19 at 09:54 +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..29950dc 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));
Sorry, I missed this one. You don't need to subtract 1 here, just pass
in the number of elements.
Actually, the calculations in net_release_address() itself are off by 1
and need to be fixed. Submitted a patch.
> + /* 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_n
> ode_reset,
> + "Reset a node and remove it from
> network"},
> {} },
> };
>
Regards,
Inga
[-- Attachment #2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 3266 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-03-19 7:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CGME20180319042513epcas1p444801a5f15a2ff0a547962662433e1f6@epcas1p4.samsung.com>
2018-03-19 4:24 ` [PATCH v2] Mesh: add 'node-reset' command Atul Rai
2018-03-19 7:22 ` Stotland, Inga
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.