[PATCH Bluez] tools/mesh-cfgclient: add unbind command

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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);
+}
+
 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,
-- 
2.24.0




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux