@@ -3582,16 +3582,21 @@ int mesh_net_set_heartbeat_sub(struct mesh_net *net, uint16_t src, uint16_t dst,
sub->max_hops = 0;
} else if (!period_log && src == sub->src && dst == sub->dst) {
+ if (IS_GROUP(sub->dst))
+ mesh_net_dst_unreg(net, sub->dst);
+
/* Preserve collected data, but disable */
sub->enabled = false;
sub->period = 0;
- } else if (sub->dst != dst) {
- if (IS_GROUP(sub->dst))
- mesh_net_dst_unreg(net, sub->dst);
+ } else {
+ if (sub->dst != dst) {
+ if (IS_GROUP(sub->dst))
+ mesh_net_dst_unreg(net, sub->dst);
- if (IS_GROUP(dst))
- mesh_net_dst_reg(net, dst);
+ if (IS_GROUP(dst))
+ mesh_net_dst_reg(net, dst);
+ }
sub->enabled = !!period_log;
sub->src = src;