[PATCH V2 8/8] mesh: meshctl: Add get/set relay command

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

 



From: Steve Brown <sbrown@xxxxxxxxxxxx>

Sets the relay state in node 0100 to 1

[config: Target = 0100]# relay-set 1 0 0

Node 0100 Relay state: 0x01 count: 0 steps: 0

Fetches the relay state of node 0100

[config: Target = 0100]# relay-get

Node 0100 Relay state: 0x01 count: 0 steps: 0
---
 mesh/config-client.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/mesh/config-client.c b/mesh/config-client.c
index 20f1714a4..b6b09841c 100644
--- a/mesh/config-client.c
+++ b/mesh/config-client.c
@@ -167,6 +167,14 @@ static bool client_msg_recvd(uint16_t src, uint8_t *data,
 				get_le16(data + 1), data[3],
 				mesh_status_str(data[0]));
 
+	case OP_CONFIG_RELAY_STATUS:
+		if (len != 2)
+			return true;
+		bt_shell_printf("Node %4.4x Relay state: 0x%02x"
+				" count: %d steps: %d\n",
+				src, data[0], data[1]>>5, data[1] & 0x1f);
+		break;
+
 	case OP_CONFIG_PROXY_STATUS:
 		if (len != 1)
 			return true;
@@ -705,6 +713,35 @@ static void cmd_get_proxy(int argc, char *argv[])
 	cmd_default(OP_CONFIG_PROXY_GET);
 }
 
+static void cmd_set_relay(int argc, char *argv[])
+{
+	uint16_t n;
+	uint8_t msg[2 + 2 + 4];
+	int parm_cnt;
+
+	if (!verify_config_target(target))
+		return;
+
+	n = mesh_opcode_set(OP_CONFIG_RELAY_SET, msg);
+
+	parm_cnt = read_input_parameters(argc, argv);
+	if (parm_cnt != 3) {
+		bt_shell_printf("bad arguments\n");
+		return;
+	}
+
+	msg[n++] = parms[0];
+	msg[n++] = (parms[1] << 5) | parms[2];
+
+	if (!config_send(msg, n))
+		bt_shell_printf("Failed to send \"SET RELAY\"\n");
+}
+
+static void cmd_get_relay(int argc, char *argv[])
+{
+	cmd_default(OP_CONFIG_RELAY_GET);
+}
+
 static void cmd_set_ttl(int argc, char *argv[])
 {
 	uint16_t n;
@@ -985,6 +1022,11 @@ static const struct bt_shell_menu cfg_menu = {
 						"Set node identity state"},
 	{"ident-get",		"<net_idx>",		cmd_get_ident,
 						"Get node identity state"},
+	{"relay-set",		"<relay> <rexmt count> <rexmt steps>",
+							cmd_set_relay,
+						"Set relay"},
+	{"relay-get",		NULL,			cmd_get_relay,
+						"Get relay"},
 	{"pub-get", "<ele_addr> <model>",		cmd_get_pub,
 						"Get publication"},
 	{"hb-set", "<pub_addr> <count> <period> <features> <net_idx>",
-- 
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[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