[PATCH BlueZ] tools/mesh-cfgclient: add friend get/set commands

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

 



Add friend-get and friend-set commands as per Mesh Profile 4.3.2.55,
4.3.2.56 and 4.3.2.57.
---
 tools/mesh/cfgcli.c | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/tools/mesh/cfgcli.c b/tools/mesh/cfgcli.c
index ec9fabb3b..9020bb752 100644
--- a/tools/mesh/cfgcli.c
+++ b/tools/mesh/cfgcli.c
@@ -621,6 +621,15 @@ static bool msg_recvd(uint16_t src, uint16_t idx, uint8_t *data,
 				src, mesh_status_str(data[0]));
 
 		break;
+
+	/* Per Mesh Profile 4.3.2.57 */
+	case OP_CONFIG_FRIEND_STATUS:
+		if (len != 1)
+			return true;
+
+		bt_shell_printf("Node %4.4x Friend state 0x%02x\n",
+				src, data[0]);
+		break;
 	}
 
 	return true;
@@ -1310,6 +1319,33 @@ static void cmd_node_reset(int argc, char *argv[])
 	cmd_default(OP_NODE_RESET);
 }
 
+static void cmd_friend_set(int argc, char *argv[])
+{
+	uint16_t n;
+	uint8_t msg[2 + 1];
+	int parm_cnt;
+
+	n = mesh_opcode_set(OP_CONFIG_FRIEND_SET, msg);
+
+	parm_cnt = read_input_parameters(argc, argv);
+	if (parm_cnt != 1) {
+		bt_shell_printf("bad arguments");
+		return bt_shell_noninteractive_quit(EXIT_FAILURE);
+	}
+
+	msg[n++] = parms[0];
+
+	if (!config_send(msg, n, OP_CONFIG_FRIEND_SET))
+		return bt_shell_noninteractive_quit(EXIT_FAILURE);
+
+	return bt_shell_noninteractive_quit(EXIT_SUCCESS);
+}
+
+static void cmd_friend_get(int argc, char *argv[])
+{
+	cmd_default(OP_CONFIG_FRIEND_GET);
+}
+
 static bool tx_setup(model_send_msg_func_t send_func, void *user_data)
 {
 	if (!send_func)
@@ -1390,6 +1426,10 @@ static const struct bt_shell_menu cfg_menu = {
 				"Get subscription"},
 	{"node-reset", NULL, cmd_node_reset,
 				"Reset a node and remove it from network"},
+	{"friend-set", "<friend>", cmd_friend_set,
+				"Set friend state"},
+	{"friend-get", NULL, cmd_friend_get,
+				"Get friend state"},
 	{} },
 };
 
-- 
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