linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Gix, Brian" <brian.gix@intel.com>
To: "linux-bluetooth@vger.kernel.org"
	<linux-bluetooth@vger.kernel.org>,
	"Stotland, Inga" <inga.stotland@intel.com>
Subject: Re: [PATCH BlueZ] tools/mesh: add commands for AppKey Get and NetKey Get
Date: Tue, 14 Jan 2020 14:41:48 +0000	[thread overview]
Message-ID: <d13c97c94c1c98e2c56b3e9eb8e4c67032211b4e.camel@intel.com> (raw)
In-Reply-To: <20200110030440.5725-1-inga.stotland@intel.com>

Applied
On Thu, 2020-01-09 at 19:04 -0800, Inga Stotland wrote:
> This implements commands to send AppKey Get and NetKey Get messages and
> to process AppKey List and NetKey List reponses
> ---
>  tools/mesh/cfgcli.c | 100 ++++++++++++++++++++++++++++++++++++++++----
>  1 file changed, 91 insertions(+), 9 deletions(-)
> 
> diff --git a/tools/mesh/cfgcli.c b/tools/mesh/cfgcli.c
> index 2403c9293..50d2ce706 100644
> --- a/tools/mesh/cfgcli.c
> +++ b/tools/mesh/cfgcli.c
> @@ -2,7 +2,7 @@
>   *
>   *  BlueZ - Bluetooth protocol stack for Linux
>   *
> - *  Copyright (C) 2019  Intel Corporation. All rights reserved.
> + *  Copyright (C) 2019-2020  Intel Corporation. All rights reserved.
>   *
>   *
>   *  This library is free software; you can redistribute it and/or
> @@ -406,6 +406,33 @@ static bool msg_recvd(uint16_t src, uint16_t idx, uint8_t *data,
>  
>  		break;
>  
> +	case OP_APPKEY_LIST:
> +		if (len < 3)
> +			break;
> +
> +		bt_shell_printf("AppKey List (node %4.4x) Status %s\n",
> +						src, mesh_status_str(data[0]));
> +		bt_shell_printf("NetKey %3.3x\n", l_get_le16(&data[1]));
> +		len -= 3;
> +
> +		if (data[0] != MESH_STATUS_SUCCESS)
> +			break;
> +
> +		bt_shell_printf("AppKeys:\n");
> +		data += 3;
> +
> +		while (len >= 3) {
> +			bt_shell_printf("\t%3.3x\n", l_get_le16(data) & 0xfff);
> +			bt_shell_printf("\t%3.3x\n", l_get_le16(data + 1) >> 4);
> +			len -= 3;
> +			data += 3;
> +		}
> +
> +		if (len == 2)
> +			bt_shell_printf("\t%3.3x\n", l_get_le16(data));
> +
> +		break;
> +
>  	case OP_NETKEY_STATUS:
>  		if (len != 3)
>  			break;
> @@ -432,6 +459,26 @@ static bool msg_recvd(uint16_t src, uint16_t idx, uint8_t *data,
>  
>  		break;
>  
> +	case OP_NETKEY_LIST:
> +		if (len < 2)
> +			break;
> +
> +		bt_shell_printf("NetKey List (node %4.4x):\n", src);
> +
> +		while (len >= 3) {
> +			net_idx = l_get_le16(data) & 0xfff;
> +			bt_shell_printf("\t%3.3x\n", net_idx);
> +			net_idx = l_get_le16(data + 1) >> 4;
> +			bt_shell_printf("\t%3.3x\n", net_idx);
> +			data += 3;
> +			len -= 3;
> +		}
> +
> +		if (len == 2)
> +			bt_shell_printf("\t%3.3x\n", l_get_le16(data) & 0xfff);
> +
> +		break;
> +
>  	case OP_MODEL_APP_STATUS:
>  		if (len != 7 && len != 9)
>  			break;
> @@ -818,6 +865,32 @@ static void cmd_appkey_del(int argc, char *argv[])
>  	return bt_shell_noninteractive_quit(EXIT_SUCCESS);
>  }
>  
> +static void cmd_appkey_get(int argc, char *argv[])
> +{
> +	uint16_t n;
> +	uint8_t msg[32];
> +
> +	if (IS_UNASSIGNED(target)) {
> +		bt_shell_printf("Destination not set\n");
> +		return bt_shell_noninteractive_quit(EXIT_FAILURE);
> +	}
> +
> +	n = mesh_opcode_set(OP_APPKEY_GET, msg);
> +
> +	if (read_input_parameters(argc, argv) != 1) {
> +		bt_shell_printf("Bad arguments %s\n", argv[1]);
> +		return bt_shell_noninteractive_quit(EXIT_FAILURE);
> +	}
> +
> +	put_le16(parms[0], msg + n);
> +	n += 2;
> +
> +	if (!config_send(msg, n, OP_APPKEY_GET))
> +		return bt_shell_noninteractive_quit(EXIT_FAILURE);
> +
> +	return bt_shell_noninteractive_quit(EXIT_SUCCESS);
> +}
> +
>  static void cmd_key_add(uint32_t opcode, int argc, char *argv[])
>  {
>  	uint16_t key_idx;
> @@ -1382,6 +1455,11 @@ static void cmd_node_reset(int argc, char *argv[])
>  	cmd_default(OP_NODE_RESET);
>  }
>  
> +static void cmd_netkey_get(int argc, char *argv[])
> +{
> +	cmd_default(OP_NETKEY_GET);
> +}
> +
>  static bool tx_setup(model_send_msg_func_t send_func, void *user_data)
>  {
>  	if (!send_func)
> @@ -1404,21 +1482,25 @@ static const struct bt_shell_menu cfg_menu = {
>  	{"composition-get", "[page_num]", cmd_composition_get,
>  				"Get composition data"},
>  	{"netkey-add", "<net_idx>", cmd_netkey_add,
> -				"Add network key"},
> +				"Add NetKey"},
>  	{"netkey-update", "<net_idx>", cmd_netkey_update,
> -				"Update network key"},
> +				"Update NetKey"},
>  	{"netkey-del", "<net_idx>", cmd_netkey_del,
> -				"Delete network key"},
> +				"Delete NetKey"},
> +	{"netkey-get", NULL, cmd_netkey_get,
> +				"List NetKeys known to the node"},
>  	{"appkey-add", "<app_idx>", cmd_appkey_add,
> -				"Add application key"},
> +				"Add AppKey"},
>  	{"appkey-update", "<app_idx>", cmd_appkey_update,
> -				"Add application key"},
> +				"Add AppKey"},
>  	{"appkey-del", "<app_idx>", cmd_appkey_del,
> -				"Delete application key"},
> +				"Delete AppKey"},
> +	{"appkey-get", "<net_idx>", cmd_appkey_get,
> +				"List AppKeys bound to the NetKey"},
>  	{"bind", "<ele_addr> <app_idx> <mod_id> [vendor_id]", cmd_add_binding,
> -				"Bind app key to a model"},
> +				"Bind AppKey to a model"},
>  	{"unbind", "<ele_addr> <app_idx> <mod_id> [vendor_id]", cmd_del_binding,
> -				"Remove app key from a model"},
> +				"Remove AppKey from a model"},
>  	{"mod-appidx-get", "<ele_addr> <model id>", cmd_mod_appidx_get,
>  				"Get model app_idx"},
>  	{"ttl-set", "<ttl>", cmd_ttl_set,

      reply	other threads:[~2020-01-14 14:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-10  3:04 [PATCH BlueZ] tools/mesh: add commands for AppKey Get and NetKey Get Inga Stotland
2020-01-14 14:41 ` Gix, Brian [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d13c97c94c1c98e2c56b3e9eb8e4c67032211b4e.camel@intel.com \
    --to=brian.gix@intel.com \
    --cc=inga.stotland@intel.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).