All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2] mesh: meshctl: Add set heartbeat subscription command
@ 2018-01-17 12:44 Steve Brown
  2018-01-18  2:08 ` Stotland, Inga
  2018-01-27 19:14 ` Johan Hedberg
  0 siblings, 2 replies; 4+ messages in thread
From: Steve Brown @ 2018-01-17 12:44 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: inga.stotland, Steve Brown

[config: Target = 0100]# hb-sub-set 0077 0100 2

Heartbeat subscription status for node 0100 status: Success
Source:		0077
Destination:	0100
Period:		01
Count:		00
Min Hops:	7f
Max Hops:	00
---
 mesh/config-client.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 59 insertions(+), 4 deletions(-)

diff --git a/mesh/config-client.c b/mesh/config-client.c
index f280441cc..6c8c7ee87 100644
--- a/mesh/config-client.c
+++ b/mesh/config-client.c
@@ -303,7 +303,8 @@ static bool client_msg_recvd(uint16_t src, uint8_t *data,
 
 	/* Per Mesh Profile 4.3.2.63 */
 	case OP_CONFIG_HEARTBEAT_PUB_STATUS:
-		bt_shell_printf("\nSet heartbeat for node %4.4x status: %s\n",
+		bt_shell_printf("\nHeartbeat publication status for "
+				"node %4.4x status: %s\n",
 				src,
 				data[0] == MESH_STATUS_SUCCESS ? "Success" :
 						mesh_status_str(data[0]));
@@ -318,6 +319,25 @@ static bool client_msg_recvd(uint16_t src, uint8_t *data,
 		bt_shell_printf("Features:\t%4.4x\n", get_le16(data + 6));
 		bt_shell_printf("Net_Idx:\t%4.4x\n", get_le16(data + 8));
 		break;
+
+	/* Per Mesh Profile 4.3.2.66 */
+	case OP_CONFIG_HEARTBEAT_SUB_STATUS:
+		bt_shell_printf("\nHeartbeat subscription status for "
+				"node %4.4x status: %s\n",
+				src,
+				data[0] == MESH_STATUS_SUCCESS ? "Success" :
+						mesh_status_str(data[0]));
+
+		if (data[0] != MESH_STATUS_SUCCESS)
+			return true;
+
+		bt_shell_printf("Source:\t\t%4.4x\n", get_le16(data + 1));
+		bt_shell_printf("Destination:\t%4.4x\n", get_le16(data + 3));
+		bt_shell_printf("Period:\t\t%2.2x\n", data[5]);
+		bt_shell_printf("Count:\t\t%2.2x\n", data[6]);
+		bt_shell_printf("Min Hops:\t%2.2x\n", data[7]);
+		bt_shell_printf("Max Hops:\t%2.2x\n", data[8]);
+		break;
 	}
 
 	return true;
@@ -946,7 +966,7 @@ static void cmd_get_app(int argc, char *argv[])
 		bt_shell_printf("Failed to send \"GET APP GET\"\n");
 }
 
-static void cmd_set_hb(int argc, char *argv[])
+static void cmd_hb_pub_set(int argc, char *argv[])
 {
 	uint16_t n;
 	uint8_t msg[32];
@@ -983,7 +1003,40 @@ static void cmd_set_hb(int argc, char *argv[])
 	n += 2;
 
 	if (!config_send(msg, n))
-		bt_shell_printf("Failed to send \"SET HEARTBEAT PUBLICATION\"\n");
+		bt_shell_printf("Failed to send \"SET HEARTBEAT PUBLISH\"\n");
+}
+
+static void cmd_hb_sub_set(int argc, char *argv[])
+{
+	uint16_t n;
+	uint8_t msg[32];
+	int parm_cnt;
+
+	if (IS_UNASSIGNED(target)) {
+		bt_shell_printf("Destination not set\n");
+		return;
+	}
+
+	n = mesh_opcode_set(OP_CONFIG_HEARTBEAT_SUB_SET, msg);
+
+	parm_cnt = read_input_parameters(argc, argv);
+	if (parm_cnt != 3) {
+		bt_shell_printf("Bad arguments: %s\n", argv[1]);
+		return;
+	}
+
+	/* Per Mesh Profile 4.3.2.65 */
+	/* Source address */
+	put_le16(parms[0], msg + n);
+	n += 2;
+	/* Destination address */
+	put_le16(parms[1], msg + n);
+	n += 2;
+	/* Period log */
+	msg[n++] = parms[2];
+
+	if (!config_send(msg, n))
+		bt_shell_printf("Failed to send \"SET HEARTBEAT SUBSCRIBE\"\n");
 }
 
 static void cmd_get_ttl(int argc, char *argv[])
@@ -1033,7 +1086,9 @@ static const struct bt_shell_menu cfg_menu = {
 	{"relay-get",           NULL,                   cmd_get_relay,
 						"Get relay"},
 	{"hb-pub-set", "<pub_addr> <count> <period> <features> <net_idx>",
-				cmd_set_hb,     "Set heartbeati publish"},
+				cmd_hb_pub_set,     "Set heartbeat publish"},
+	{"hb-sub-set", "<src_addr> <dst_addr> <period>",
+				cmd_hb_sub_set,     "Set heartbeat subscribe"},
 	{"sub-add", "<ele_addr> <sub_addr> <model id>",
 				cmd_sub_add,    "Subscription add"},
 	{"sub-get", "<ele_addr> <model id>",
-- 
2.14.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH V2] mesh: meshctl: Add set heartbeat subscription command
  2018-01-17 12:44 [PATCH V2] mesh: meshctl: Add set heartbeat subscription command Steve Brown
@ 2018-01-18  2:08 ` Stotland, Inga
  2018-01-27 19:07   ` Steve Brown
  2018-01-27 19:14 ` Johan Hedberg
  1 sibling, 1 reply; 4+ messages in thread
From: Stotland, Inga @ 2018-01-18  2:08 UTC (permalink / raw)
  To: sbrown, linux-bluetooth

[-- Attachment #1: Type: text/plain, Size: 4113 bytes --]

Hi Steve,

On Wed, 2018-01-17 at 07:44 -0500, Steve Brown wrote:
> [config: Target = 0100]# hb-sub-set 0077 0100 2
> 
> Heartbeat subscription status for node 0100 status: Success
> Source:		0077
> Destination:	0100
> Period:		01
> Count:		00
> Min Hops:	7f
> Max Hops:	00
> ---
>  mesh/config-client.c | 63
> ++++++++++++++++++++++++++++++++++++++++++++++++----
>  1 file changed, 59 insertions(+), 4 deletions(-)
> 
> diff --git a/mesh/config-client.c b/mesh/config-client.c
> index f280441cc..6c8c7ee87 100644
> --- a/mesh/config-client.c
> +++ b/mesh/config-client.c
> @@ -303,7 +303,8 @@ static bool client_msg_recvd(uint16_t src,
> uint8_t *data,
>  
>  	/* Per Mesh Profile 4.3.2.63 */
>  	case OP_CONFIG_HEARTBEAT_PUB_STATUS:
> -		bt_shell_printf("\nSet heartbeat for node %4.4x
> status: %s\n",
> +		bt_shell_printf("\nHeartbeat publication status for
> "
> +				"node %4.4x status: %s\n",
>  				src,
>  				data[0] == MESH_STATUS_SUCCESS ?
> "Success" :
>  						mesh_status_str(data
> [0]));
> @@ -318,6 +319,25 @@ static bool client_msg_recvd(uint16_t src,
> uint8_t *data,
>  		bt_shell_printf("Features:\t%4.4x\n", get_le16(data
> + 6));
>  		bt_shell_printf("Net_Idx:\t%4.4x\n", get_le16(data +
> 8));
>  		break;
> +
> +	/* Per Mesh Profile 4.3.2.66 */
> +	case OP_CONFIG_HEARTBEAT_SUB_STATUS:
> +		bt_shell_printf("\nHeartbeat subscription status for
> "
> +				"node %4.4x status: %s\n",
> +				src,
> +				data[0] == MESH_STATUS_SUCCESS ?
> "Success" :
> +						mesh_status_str(data
> [0]));
> +
> +		if (data[0] != MESH_STATUS_SUCCESS)
> +			return true;
> +
> +		bt_shell_printf("Source:\t\t%4.4x\n", get_le16(data
> + 1));
> +		bt_shell_printf("Destination:\t%4.4x\n",
> get_le16(data + 3));
> +		bt_shell_printf("Period:\t\t%2.2x\n", data[5]);
> +		bt_shell_printf("Count:\t\t%2.2x\n", data[6]);
> +		bt_shell_printf("Min Hops:\t%2.2x\n", data[7]);
> +		bt_shell_printf("Max Hops:\t%2.2x\n", data[8]);
> +		break;
>  	}
>  
>  	return true;
> @@ -946,7 +966,7 @@ static void cmd_get_app(int argc, char *argv[])
>  		bt_shell_printf("Failed to send \"GET APP GET\"\n");
>  }
>  
> -static void cmd_set_hb(int argc, char *argv[])
> +static void cmd_hb_pub_set(int argc, char *argv[])
>  {
>  	uint16_t n;
>  	uint8_t msg[32];
> @@ -983,7 +1003,40 @@ static void cmd_set_hb(int argc, char *argv[])
>  	n += 2;
>  
>  	if (!config_send(msg, n))
> -		bt_shell_printf("Failed to send \"SET HEARTBEAT
> PUBLICATION\"\n");
> +		bt_shell_printf("Failed to send \"SET HEARTBEAT
> PUBLISH\"\n");
> +}
> +
> +static void cmd_hb_sub_set(int argc, char *argv[])
> +{
> +	uint16_t n;
> +	uint8_t msg[32];
> +	int parm_cnt;
> +
> +	if (IS_UNASSIGNED(target)) {
> +		bt_shell_printf("Destination not set\n");
> +		return;
> +	}
> +
> +	n = mesh_opcode_set(OP_CONFIG_HEARTBEAT_SUB_SET, msg);
> +
> +	parm_cnt = read_input_parameters(argc, argv);
> +	if (parm_cnt != 3) {
> +		bt_shell_printf("Bad arguments: %s\n", argv[1]);
> +		return;
> +	}
> +
> +	/* Per Mesh Profile 4.3.2.65 */
> +	/* Source address */
> +	put_le16(parms[0], msg + n);
> +	n += 2;
> +	/* Destination address */
> +	put_le16(parms[1], msg + n);
> +	n += 2;
> +	/* Period log */
> +	msg[n++] = parms[2];
> +
> +	if (!config_send(msg, n))
> +		bt_shell_printf("Failed to send \"SET HEARTBEAT
> SUBSCRIBE\"\n");
>  }
>  
>  static void cmd_get_ttl(int argc, char *argv[])
> @@ -1033,7 +1086,9 @@ static const struct bt_shell_menu cfg_menu = {
>  	{"relay-
> get",           NULL,                   cmd_get_relay,
>  						"Get relay"},
>  	{"hb-pub-set", "<pub_addr> <count> <period> <features>
> <net_idx>",
> -				cmd_set_hb,     "Set heartbeati
> publish"},
> +				cmd_hb_pub_set,     "Set heartbeat
> publish"},
> +	{"hb-sub-set", "<src_addr> <dst_addr> <period>",
> +				cmd_hb_sub_set,     "Set heartbeat
> subscribe"},
>  	{"sub-add", "<ele_addr> <sub_addr> <model id>",
>  				cmd_sub_add,    "Subscription add"},
>  	{"sub-get", "<ele_addr> <model id>",

This looks fine.

Thanks,
Inga

[-- Attachment #2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 3266 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH V2] mesh: meshctl: Add set heartbeat subscription command
  2018-01-18  2:08 ` Stotland, Inga
@ 2018-01-27 19:07   ` Steve Brown
  0 siblings, 0 replies; 4+ messages in thread
From: Steve Brown @ 2018-01-27 19:07 UTC (permalink / raw)
  To: Stotland, Inga, linux-bluetooth; +Cc: Johan Hedberg

Ping

On Thu, 2018-01-18 at 02:08 +0000, Stotland, Inga wrote:
> Hi Steve,
> 
> On Wed, 2018-01-17 at 07:44 -0500, Steve Brown wrote:
> > [config: Target = 0100]# hb-sub-set 0077 0100 2
> > 
> > Heartbeat subscription status for node 0100 status: Success
> > Source:		0077
> > Destination:	0100
> > Period:		01
> > Count:		00
> > Min Hops:	7f
> > Max Hops:	00
> > ---
> >  mesh/config-client.c | 63
> > ++++++++++++++++++++++++++++++++++++++++++++++++----
> >  1 file changed, 59 insertions(+), 4 deletions(-)
> > 
> > diff --git a/mesh/config-client.c b/mesh/config-client.c
> > index f280441cc..6c8c7ee87 100644
> > --- a/mesh/config-client.c
> > +++ b/mesh/config-client.c
> > @@ -303,7 +303,8 @@ static bool client_msg_recvd(uint16_t src,
> > uint8_t *data,
> >  
> >  	/* Per Mesh Profile 4.3.2.63 */
> >  	case OP_CONFIG_HEARTBEAT_PUB_STATUS:
> > -		bt_shell_printf("\nSet heartbeat for node %4.4x
> > status: %s\n",
> > +		bt_shell_printf("\nHeartbeat publication status
> > for
> > "
> > +				"node %4.4x status: %s\n",
> >  				src,
> >  				data[0] == MESH_STATUS_SUCCESS ?
> > "Success" :
> >  						mesh_status_str(da
> > ta
> > [0]));
> > @@ -318,6 +319,25 @@ static bool client_msg_recvd(uint16_t src,
> > uint8_t *data,
> >  		bt_shell_printf("Features:\t%4.4x\n",
> > get_le16(data
> > + 6));
> >  		bt_shell_printf("Net_Idx:\t%4.4x\n", get_le16(data
> > +
> > 8));
> >  		break;
> > +
> > +	/* Per Mesh Profile 4.3.2.66 */
> > +	case OP_CONFIG_HEARTBEAT_SUB_STATUS:
> > +		bt_shell_printf("\nHeartbeat subscription status
> > for
> > "
> > +				"node %4.4x status: %s\n",
> > +				src,
> > +				data[0] == MESH_STATUS_SUCCESS ?
> > "Success" :
> > +						mesh_status_str(da
> > ta
> > [0]));
> > +
> > +		if (data[0] != MESH_STATUS_SUCCESS)
> > +			return true;
> > +
> > +		bt_shell_printf("Source:\t\t%4.4x\n",
> > get_le16(data
> > + 1));
> > +		bt_shell_printf("Destination:\t%4.4x\n",
> > get_le16(data + 3));
> > +		bt_shell_printf("Period:\t\t%2.2x\n", data[5]);
> > +		bt_shell_printf("Count:\t\t%2.2x\n", data[6]);
> > +		bt_shell_printf("Min Hops:\t%2.2x\n", data[7]);
> > +		bt_shell_printf("Max Hops:\t%2.2x\n", data[8]);
> > +		break;
> >  	}
> >  
> >  	return true;
> > @@ -946,7 +966,7 @@ static void cmd_get_app(int argc, char *argv[])
> >  		bt_shell_printf("Failed to send \"GET APP
> > GET\"\n");
> >  }
> >  
> > -static void cmd_set_hb(int argc, char *argv[])
> > +static void cmd_hb_pub_set(int argc, char *argv[])
> >  {
> >  	uint16_t n;
> >  	uint8_t msg[32];
> > @@ -983,7 +1003,40 @@ static void cmd_set_hb(int argc, char
> > *argv[])
> >  	n += 2;
> >  
> >  	if (!config_send(msg, n))
> > -		bt_shell_printf("Failed to send \"SET HEARTBEAT
> > PUBLICATION\"\n");
> > +		bt_shell_printf("Failed to send \"SET HEARTBEAT
> > PUBLISH\"\n");
> > +}
> > +
> > +static void cmd_hb_sub_set(int argc, char *argv[])
> > +{
> > +	uint16_t n;
> > +	uint8_t msg[32];
> > +	int parm_cnt;
> > +
> > +	if (IS_UNASSIGNED(target)) {
> > +		bt_shell_printf("Destination not set\n");
> > +		return;
> > +	}
> > +
> > +	n = mesh_opcode_set(OP_CONFIG_HEARTBEAT_SUB_SET, msg);
> > +
> > +	parm_cnt = read_input_parameters(argc, argv);
> > +	if (parm_cnt != 3) {
> > +		bt_shell_printf("Bad arguments: %s\n", argv[1]);
> > +		return;
> > +	}
> > +
> > +	/* Per Mesh Profile 4.3.2.65 */
> > +	/* Source address */
> > +	put_le16(parms[0], msg + n);
> > +	n += 2;
> > +	/* Destination address */
> > +	put_le16(parms[1], msg + n);
> > +	n += 2;
> > +	/* Period log */
> > +	msg[n++] = parms[2];
> > +
> > +	if (!config_send(msg, n))
> > +		bt_shell_printf("Failed to send \"SET HEARTBEAT
> > SUBSCRIBE\"\n");
> >  }
> >  
> >  static void cmd_get_ttl(int argc, char *argv[])
> > @@ -1033,7 +1086,9 @@ static const struct bt_shell_menu cfg_menu =
> > {
> >  	{"relay-
> > get",           NULL,                   cmd_get_relay,
> >  						"Get relay"},
> >  	{"hb-pub-set", "<pub_addr> <count> <period> <features>
> > <net_idx>",
> > -				cmd_set_hb,     "Set heartbeati
> > publish"},
> > +				cmd_hb_pub_set,     "Set heartbeat
> > publish"},
> > +	{"hb-sub-set", "<src_addr> <dst_addr> <period>",
> > +				cmd_hb_sub_set,     "Set heartbeat
> > subscribe"},
> >  	{"sub-add", "<ele_addr> <sub_addr> <model id>",
> >  				cmd_sub_add,    "Subscription
> > add"},
> >  	{"sub-get", "<ele_addr> <model id>",
> 
> This looks fine.
> 
> Thanks,
> Inga

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH V2] mesh: meshctl: Add set heartbeat subscription command
  2018-01-17 12:44 [PATCH V2] mesh: meshctl: Add set heartbeat subscription command Steve Brown
  2018-01-18  2:08 ` Stotland, Inga
@ 2018-01-27 19:14 ` Johan Hedberg
  1 sibling, 0 replies; 4+ messages in thread
From: Johan Hedberg @ 2018-01-27 19:14 UTC (permalink / raw)
  To: Steve Brown; +Cc: linux-bluetooth, inga.stotland

Hi Steve,

On Wed, Jan 17, 2018, Steve Brown wrote:
> [config: Target = 0100]# hb-sub-set 0077 0100 2
> 
> Heartbeat subscription status for node 0100 status: Success
> Source:		0077
> Destination:	0100
> Period:		01
> Count:		00
> Min Hops:	7f
> Max Hops:	00
> ---
>  mesh/config-client.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++----
>  1 file changed, 59 insertions(+), 4 deletions(-)

Sorry, forgot about this one. Thanks for the ping. The patch has now
been applied upstream.

Johan

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-01-27 19:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-17 12:44 [PATCH V2] mesh: meshctl: Add set heartbeat subscription command Steve Brown
2018-01-18  2:08 ` Stotland, Inga
2018-01-27 19:07   ` Steve Brown
2018-01-27 19:14 ` Johan Hedberg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.