linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Stotland, Inga" <inga.stotland@intel.com>
To: "aurelien@aurel32.net" <aurelien@aurel32.net>,
	"linux-bluetooth@vger.kernel.org"
	<linux-bluetooth@vger.kernel.org>
Subject: Re: [PATCH Bluez] tools/mesh-cfgclient: add unbind command
Date: Mon, 11 Nov 2019 18:26:46 +0000	[thread overview]
Message-ID: <5ecf503ae4a6b1afb6f96ce9e09cd53cbf9a4c8f.camel@intel.com> (raw)
In-Reply-To: <20191111002407.32575-1-aurelien@aurel32.net>

Hi Aurelien,

On Mon, 2019-11-11 at 01:24 +0100, Aurelien Jarno wrote:
> This is basically a copy of cmd_bind with OP_MODEL_APP_BIND replaced by
> OP_MODEL_APP_UNBIND as cmds[] already has code to handle it.
> ---
>  tools/mesh/cfgcli.c | 36 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 36 insertions(+)
> 
> diff --git a/tools/mesh/cfgcli.c b/tools/mesh/cfgcli.c
> index 086998910..a4de42943 100644
> --- a/tools/mesh/cfgcli.c
> +++ b/tools/mesh/cfgcli.c
> @@ -897,6 +897,40 @@ static void cmd_bind(int argc, char *argv[])
>  	return bt_shell_noninteractive_quit(EXIT_SUCCESS);
>  }
>  
> +static void cmd_unbind(int argc, char *argv[])
> +{
> +	uint16_t n;
> +	uint8_t msg[32];
> +	int parm_cnt;
> +
> +	parm_cnt = read_input_parameters(argc, argv);
> +	if (parm_cnt != 3 && parm_cnt != 4) {
> +		bt_shell_printf("Bad arguments\n");
> +		return bt_shell_noninteractive_quit(EXIT_FAILURE);
> +	}
> +
> +	n = mesh_opcode_set(OP_MODEL_APP_UNBIND, msg);
> +
> +	put_le16(parms[0], msg + n);
> +	n += 2;
> +	put_le16(parms[1], msg + n);
> +	n += 2;
> +
> +	if (parm_cnt == 4) {
> +		put_le16(parms[3], msg + n);
> +		put_le16(parms[2], msg + n + 2);
> +		n += 4;
> +	} else {
> +		put_le16(parms[2], msg + n);
> +		n += 2;
> +	}
> +
> +	if (!config_send(msg, n, OP_MODEL_APP_UNBIND))
> +		return bt_shell_noninteractive_quit(EXIT_FAILURE);
> +
> +	return bt_shell_noninteractive_quit(EXIT_SUCCESS);
> +}

Since cmd_bind() & and cmd_unbind()
are virtually identical with the exception of the opcode, let's combine
them to call one routine, e.g.
cmd_add_binding() and cmd delete_binding() would call
cmd_bind(int argc, char*argv[], int opcode)

> +
>  static void cmd_beacon_set(int argc, char *argv[])
>  {
>  	uint16_t n;
> @@ -1335,6 +1369,8 @@ static const struct bt_shell_menu cfg_menu = {
>  				"Delete application key"},
>  	{"bind", "<ele_addr> <app_idx> <mod_id> [vendor_id]", cmd_bind,
>  				"Bind app key to a model"},
> +	{"unbind", "<ele_addr> <app_idx> <mod_id> [vendor_id]", cmd_unbind,
> +				"Remove app key from a model"},
>  	{"mod-appidx-get", "<ele_addr> <model id>", cmd_mod_appidx_get,
>  				"Get model app_idx"},
>  	{"ttl-set", "<ttl>", cmd_ttl_set,

Best regards,
Inga

  reply	other threads:[~2019-11-11 18:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-11  0:24 [PATCH Bluez] tools/mesh-cfgclient: add unbind command Aurelien Jarno
2019-11-11 18:26 ` Stotland, Inga [this message]
2019-11-12 17:55 ` Gix, Brian
2019-11-12 18:02   ` Gix, Brian

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=5ecf503ae4a6b1afb6f96ce9e09cd53cbf9a4c8f.camel@intel.com \
    --to=inga.stotland@intel.com \
    --cc=aurelien@aurel32.net \
    --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).