From: Aurelien Jarno <aurelien@aurel32.net>
To: linux-bluetooth@vger.kernel.org
Cc: Aurelien Jarno <aurelien@aurel32.net>
Subject: [PATCH BlueZ v2] tools/mesh-cfgclient: add unbind command
Date: Mon, 11 Nov 2019 21:20:09 +0100 [thread overview]
Message-ID: <20191111202009.4281-1-aurelien@aurel32.net> (raw)
This reuses the existing cmd_bind for both opcodes. cmds[] already has
code to handle it.
---
tools/mesh/cfgcli.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
Changes v1 -> v2:
- Reuse the existing code by passing an opcode instead of duplicating
the code. Thanks to Inga Stotland for the hint.
diff --git a/tools/mesh/cfgcli.c b/tools/mesh/cfgcli.c
index 6dffbeefc..39e8a0b2c 100644
--- a/tools/mesh/cfgcli.c
+++ b/tools/mesh/cfgcli.c
@@ -872,7 +872,7 @@ static void cmd_appkey_update(int argc, char *argv[])
cmd_key_add(OP_APPKEY_UPDATE, argc, argv);
}
-static void cmd_bind(int argc, char *argv[])
+static void cmd_bind(uint32_t opcode, int argc, char *argv[])
{
uint16_t n;
uint8_t msg[32];
@@ -884,7 +884,7 @@ static void cmd_bind(int argc, char *argv[])
return bt_shell_noninteractive_quit(EXIT_FAILURE);
}
- n = mesh_opcode_set(OP_MODEL_APP_BIND, msg);
+ n = mesh_opcode_set(opcode, msg);
put_le16(parms[0], msg + n);
n += 2;
@@ -900,12 +900,22 @@ static void cmd_bind(int argc, char *argv[])
n += 2;
}
- if (!config_send(msg, n, OP_MODEL_APP_BIND))
+ if (!config_send(msg, n, opcode))
return bt_shell_noninteractive_quit(EXIT_FAILURE);
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
}
+static void cmd_add_binding(int argc, char *argv[])
+{
+ cmd_bind(OP_MODEL_APP_BIND, argc, argv);
+}
+
+static void cmd_del_binding(int argc, char *argv[])
+{
+ cmd_bind(OP_MODEL_APP_UNBIND, argc, argv);
+}
+
static void cmd_beacon_set(int argc, char *argv[])
{
uint16_t n;
@@ -1369,8 +1379,10 @@ static const struct bt_shell_menu cfg_menu = {
"Add application key"},
{"appkey-del", "<app_idx>", cmd_appkey_del,
"Delete application key"},
- {"bind", "<ele_addr> <app_idx> <mod_id> [vendor_id]", cmd_bind,
+ {"bind", "<ele_addr> <app_idx> <mod_id> [vendor_id]", cmd_add_binding,
"Bind app key to a model"},
+ {"unbind", "<ele_addr> <app_idx> <mod_id> [vendor_id]", cmd_del_binding,
+ "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,
--
2.24.0
reply other threads:[~2019-11-11 20:20 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20191111202009.4281-1-aurelien@aurel32.net \
--to=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).