You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by na...@apache.org on 2021/05/27 08:19:40 UTC

[mynewt-nimble] 02/31: mesh: Fix heartbeat subscription tests

This is an automated email from the ASF dual-hosted git repository.

naraj pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 8becf2a64f0659d431685e5f39f8fbfa2aa2404b
Author: Krzysztof Kopyściński <kr...@codecoup.pl>
AuthorDate: Mon Mar 29 10:44:43 2021 +0200

    mesh: Fix heartbeat subscription tests
    
    MESH/NODE/CFG/HBS/BV-01-C expects the MinHops to be 0x7f after
    disabling subscription, but 0x00 for subsequent Get requests.
    
    MESH/NODE/CFG/HBS/BV-02-C expects us to return previous
    count value and then reset it to 0.
    
    this is port of 419d2aa85b3e2656ac8bdd99875313e9f4b4720c
---
 nimble/host/mesh/src/cfg_srv.c   | 10 +++++++++-
 nimble/host/mesh/src/heartbeat.c |  5 +++++
 nimble/host/mesh/src/heartbeat.h |  1 +
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/nimble/host/mesh/src/cfg_srv.c b/nimble/host/mesh/src/cfg_srv.c
index 8a085bd..404f731 100644
--- a/nimble/host/mesh/src/cfg_srv.c
+++ b/nimble/host/mesh/src/cfg_srv.c
@@ -2387,11 +2387,19 @@ static void heartbeat_sub_set(struct bt_mesh_model *model,
 	/* MESH/NODE/CFG/HBS/BV-01-C expects the MinHops to be 0x7f after
 	 * disabling subscription, but 0x00 for subsequent Get requests.
 	 */
-	if (!period_log) {
+	if (sub.src == BT_MESH_ADDR_UNASSIGNED || !period_log) {
 		sub.min_hops = BT_MESH_TTL_MAX;
 	}
 
 	hb_sub_send_status(model, ctx, &sub);
+
+	/* MESH/NODE/CFG/HBS/BV-02-C expects us to return previous
+	 * count value and then reset it to 0.
+	 */
+	if (sub.src != BT_MESH_ADDR_UNASSIGNED &&
+	    sub.dst != BT_MESH_ADDR_UNASSIGNED && !period) {
+		bt_mesh_hb_sub_reset_count();
+	}
 }
 
 const struct bt_mesh_model_op bt_mesh_cfg_srv_op[] = {
diff --git a/nimble/host/mesh/src/heartbeat.c b/nimble/host/mesh/src/heartbeat.c
index 538a1cb..f990dc0 100644
--- a/nimble/host/mesh/src/heartbeat.c
+++ b/nimble/host/mesh/src/heartbeat.c
@@ -303,6 +303,11 @@ uint8_t bt_mesh_hb_sub_set(uint16_t src, uint16_t dst, uint32_t period)
 	return STATUS_SUCCESS;
 }
 
+void bt_mesh_hb_sub_reset_count(void)
+{
+	sub.count = 0;
+}
+
 void bt_mesh_hb_sub_get(struct bt_mesh_hb_sub *get)
 {
 	*get = sub;
diff --git a/nimble/host/mesh/src/heartbeat.h b/nimble/host/mesh/src/heartbeat.h
index c43683f..92b0cae 100644
--- a/nimble/host/mesh/src/heartbeat.h
+++ b/nimble/host/mesh/src/heartbeat.h
@@ -38,3 +38,4 @@ void bt_mesh_hb_feature_changed(uint16_t features);
 
 uint8_t bt_mesh_hb_pub_set(struct bt_mesh_hb_pub *hb_pub);
 uint8_t bt_mesh_hb_sub_set(uint16_t src, uint16_t dst, uint32_t period);
+void bt_mesh_hb_sub_reset_count(void);