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.
This commit is contained in:
Atul Rai 2018-03-19 13:12:16 +05:30 committed by Luiz Augusto von Dentz
parent f7c7a24bf9
commit 382ad0905d

View File

@ -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("Min Hops\t%2.2x\n", data[7]);
bt_shell_printf("Max Hops\t%2.2x\n", data[8]); bt_shell_printf("Max Hops\t%2.2x\n", data[8]);
break; 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; return true;
@ -1124,6 +1135,11 @@ static void cmd_ttl_get(int argc, char *argv[])
cmd_default(OP_CONFIG_DEFAULT_TTL_GET); 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 = { static const struct bt_shell_menu cfg_menu = {
.name = "config", .name = "config",
.desc = "Configuration Model Submenu", .desc = "Configuration Model Submenu",
@ -1179,6 +1195,8 @@ static const struct bt_shell_menu cfg_menu = {
cmd_sub_add, "Add subscription"}, cmd_sub_add, "Add subscription"},
{"sub-get", "<ele_addr> <model id>", {"sub-get", "<ele_addr> <model id>",
cmd_sub_get, "Get subscription"}, cmd_sub_get, "Get subscription"},
{"node-reset", NULL, cmd_node_reset,
"Reset a node and remove it from network"},
{} }, {} },
}; };