2018-03-19 07:42:16

by Atul Kumar Rai

[permalink] [raw]
Subject: [PATCH v3] 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..a6cd87e 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)));
+ /* 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-27 14:08:41

by Luiz Augusto von Dentz

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

Hi Atul,

On Tue, Mar 27, 2018 at 4:19 PM, Atul Kumar Rai <[email protected]> wrote:
> Ping.
>
>> Hi Atul,
>>
>> On Mon, 2018-03-19 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..a6cd87e 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)));
>>> + /* 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"},
>>> {} },
>>> };
>>>
>> This looks fine.
>> Thanks,
>> Inga

Applied, thanks.

--
Luiz Augusto von Dentz

2018-03-27 13:19:32

by Atul Kumar Rai

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

Ping.

>=C2=A0Hi=C2=A0Atul,=0D=0A>=0D=0A>=C2=A0On=C2=A0Mon,=C2=A02018-03-19=C2=A0a=
t=C2=A013:12=C2=A0+0530,=C2=A0Atul=C2=A0Rai=C2=A0wrote:=0D=0A>>=C2=A0This=
=C2=A0patch=C2=A0adds=C2=A0'node-reset'=C2=A0command=C2=A0which=C2=A0can=C2=
=A0be=C2=A0used=C2=A0to=C2=A0reset=C2=A0a=0D=0A>>=C2=A0node=C2=A0(other=C2=
=A0than=C2=A0a=C2=A0Provisioner)=C2=A0and=C2=A0remove=C2=A0it=C2=A0from=C2=
=A0the=C2=A0network.=0D=0A>>=C2=A0---=0D=0A>>=C2=A0=C2=A0mesh/config-client=
.c=C2=A0=7C=C2=A018=C2=A0++++++++++++++++++=0D=0A>>=C2=A0=C2=A01=C2=A0file=
=C2=A0changed,=C2=A018=C2=A0insertions(+)=0D=0A>>=C2=A0=0D=0A>>=C2=A0diff=
=C2=A0--git=C2=A0a/mesh/config-client.c=C2=A0b/mesh/config-client.c=0D=0A>>=
=C2=A0index=C2=A019e617d..a6cd87e=C2=A0100644=0D=0A>>=C2=A0---=C2=A0a/mesh/=
config-client.c=0D=0A>>=C2=A0+++=C2=A0b/mesh/config-client.c=0D=0A>>=C2=A0=
=40=40=C2=A0-342,6=C2=A0+342,17=C2=A0=40=40=C2=A0static=C2=A0bool=C2=A0clie=
nt_msg_recvd(uint16_t=C2=A0src,=0D=0A>>=C2=A0uint8_t=C2=A0*data,=0D=0A>>=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0bt_shell_printf(=22Min=C2=A0Hops=5Ct%2.2x=5Cn=
=22,=C2=A0data=5B7=5D);=0D=0A>>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0bt_shell_=
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0void=C2=A0cmd_node_reset(int=C2=A0argc,=C2=
=A0char=C2=A0*argv=5B=5D)=0D=0A>>=C2=A0+=7B=0D=0A>>=C2=A0+=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0cmd_default(OP_NODE_RESET);=0D=0A>>=C2=A0+=
=7D=0D=0A>>=C2=A0+=0D=0A>>=C2=A0=C2=A0static=C2=A0const=C2=A0struct=C2=A0bt=
_shell_menu=C2=A0cfg_menu=C2=A0=3D=C2=A0=7B=0D=0A>>=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0.name=C2=A0=3D=C2=A0=22config=22,=0D=0A=
>>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0.desc=C2=A0=
=3D=C2=A0=22Configuration=C2=A0Model=C2=A0Submenu=22,=0D=0A>>=C2=A0=40=40=
=C2=A0-1179,6=C2=A0+1195,8=C2=A0=40=40=C2=A0static=C2=A0const=C2=A0struct=
=C2=A0bt_shell_menu=C2=A0cfg_menu=C2=A0=3D=C2=A0=7B=0D=0A>>=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0cmd_sub_add,=C2=A0=C2=A0=C2=A0=C2=A0=
=22Add=C2=A0subscription=22=7D,=0D=0A>>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=7B=22sub-get=22,=C2=A0=22<ele_addr>=C2=A0<model=C2=
=A0id>=22,=0D=0A>>=C2=A0=C2=A0=C2=A0=C2=A0=C2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0Thanks,=0D=0A>=C2=A0=
Inga

2018-03-20 15:11:48

by Stotland, Inga

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

Hi Atul,

On Mon, 2018-03-19 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..a6cd87e 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)));
> + /* 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"},
> {} },
> };
>
This looks fine.
Thanks,
Inga


Attachments:
smime.p7s (3.19 kB)