Skip to content

Commit 46ffe45

Browse files
Steve BrownAnas Nashif
authored andcommitted
Bluetooth: Mesh: heartbeat fixes for message count
Both count and period must be non-zero for message publication Stop publication when count becomes zero Add count to debug message in hb_publish Signed-off-by: Steve Brown <[email protected]>
1 parent 218dd04 commit 46ffe45

File tree

1 file changed

+7
-3
lines changed
  • subsys/bluetooth/host/mesh

1 file changed

+7
-3
lines changed

subsys/bluetooth/host/mesh/cfg.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ static void hb_send(struct bt_mesh_model *model)
9595

9696
hb.feat = sys_cpu_to_be16(feat);
9797

98-
BT_DBG("InitTTL %u feat 0x%02x", cfg->hb_pub.ttl, feat);
98+
BT_DBG("InitTTL %u feat 0x%04x", cfg->hb_pub.ttl, feat);
9999

100100
bt_mesh_ctl_send(&tx, TRANS_CTL_OP_HEARTBEAT, &hb, sizeof(hb), NULL);
101101
}
@@ -2726,7 +2726,7 @@ static void heartbeat_pub_set(struct bt_mesh_model *model,
27262726
* as possible after the Heartbeat Publication Period state
27272727
* has been configured for periodic publishing.
27282728
*/
2729-
if (param->period_log) {
2729+
if (param->period_log && param->count_log) {
27302730
k_work_submit(&cfg->hb_pub.timer.work);
27312731
} else {
27322732
k_delayed_work_cancel(&cfg->hb_pub.timer);
@@ -2904,7 +2904,7 @@ static void hb_publish(struct k_work *work)
29042904
struct bt_mesh_subnet *sub;
29052905
u16_t period_ms;
29062906

2907-
BT_DBG("");
2907+
BT_DBG("hb_pub.count: %u", cfg->hb_pub.count);
29082908

29092909
sub = bt_mesh_subnet_get(cfg->hb_pub.net_idx);
29102910
if (!sub) {
@@ -2916,6 +2916,10 @@ static void hb_publish(struct k_work *work)
29162916

29172917
hb_send(model);
29182918

2919+
if (cfg->hb_pub.count == 0) {
2920+
return;
2921+
}
2922+
29192923
if (cfg->hb_pub.count != 0xffff) {
29202924
cfg->hb_pub.count--;
29212925
}

0 commit comments

Comments
 (0)