Skip to content

Commit b840af9

Browse files
committed
Periodically reset window if not configured to broadcast stats
1 parent f99b95c commit b840af9

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/modules/RoutingStatsModule.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
RoutingStatsModule *routingStats;
77

88
#define PRINT_STATS_INTERVAL_MS (60 * 1000) // Print our own stats every 60 seconds
9+
#define PRINT_STATS_WINDOW_SECS 900 // If not transmitting stats, reset the window every 15 minutes
910

1011
/**
1112
* Log a routing event
@@ -102,6 +103,11 @@ int32_t RoutingStatsModule::runOnce()
102103
printStats(&stats, nodeDB->getNodeNum());
103104
last_print_millis = now;
104105
next_print_millis = last_print_millis + PRINT_STATS_INTERVAL_MS;
106+
if (!config.device.routing_stats_broadcast_secs && (last_tx_millis + PRINT_STATS_WINDOW_SECS * 1000) < now) {
107+
// Reset stats window if we're not configured to broadcast stats
108+
stats = {};
109+
last_tx_millis = now;
110+
}
105111
}
106112

107113
if (next_tx_millis > now)

0 commit comments

Comments
 (0)