@@ -40,6 +40,7 @@
#include "mesh/mesh-defs.h"
#include "mesh/util.h"
#include "mesh/mesh-config.h"
+#include "mesh/net.h"
/* To prevent local node JSON cache thrashing, minimum update times */
#define MIN_SEQ_CACHE_TRIGGER 32
@@ -2019,6 +2020,9 @@ bool mesh_config_write_seq_number(struct mesh_config *cfg, uint32_t seq,
if (cached < seq + MIN_SEQ_CACHE_VALUE)
cached = seq + MIN_SEQ_CACHE_VALUE;
+ if (cached >= SEQ_MASK)
+ cached = SEQ_MASK;
+
l_debug("Seq Cache: %d -> %d", seq, cached);
cfg->write_seq = seq;
@@ -511,6 +511,9 @@ uint32_t mesh_net_next_seq_num(struct mesh_net *net)
{
uint32_t seq = net->seq_num++;
+ if (net->seq_num > SEQ_MASK)
+ net->seq_num = SEQ_MASK;
+
node_set_sequence_number(net->node, net->seq_num);
return seq;
}