Skip to content

Commit 8d20805

Browse files
author
realtag
committed
Align hourly status to the top of the hour
Schedule repeater status broadcasts on :00 using RTC time while keeping the boot-time send.\nDocument the on-the-hour behavior in README.
1 parent 3fb97dd commit 8d20805

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ On Heltec boards, the repeater LCD shows WiFi status:
3131

3232
## ⏱ Status Broadcast
3333

34-
The repeater reports to the `#test` channel every hour. It only replies to `!ping` unless `ping.test` is enabled. Group commands:
34+
The repeater reports to the `#test` channel on the hour (:00) and once on boot. It only replies to `!ping` unless `ping.test` is enabled. Group commands:
3535

3636
- `!ping` — reply with path and RF stats.
3737
- `!5count` — reply 5 times with the same info as `!ping` (no "Pong").

examples/simple_repeater/MyMesh.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,14 @@ static size_t jsonEscape(const char* src, char* dst, size_t dst_len) {
109109
}
110110
#endif
111111

112+
static unsigned long calcNextHourDelayMs(mesh::RTCClock* rtc) {
113+
uint32_t now = rtc->getCurrentTime();
114+
uint32_t next_hour = (now / 3600UL + 1) * 3600UL;
115+
uint32_t delta_secs = next_hour - now;
116+
if (delta_secs == 0) delta_secs = 3600UL;
117+
return (unsigned long)delta_secs * 1000UL;
118+
}
119+
112120
uint8_t MyMesh::calcBusyPercent() {
113121
uint32_t now_ms = millis();
114122
uint32_t tx_ms = getTotalAirTime();
@@ -1800,7 +1808,7 @@ void MyMesh::loop() {
18001808
if (test_channel_ready) {
18011809
sendPublicBroadcast(test_channel);
18021810
}
1803-
next_public_broadcast_at = futureMillis(TEST_BROADCAST_INTERVAL_MS);
1811+
next_public_broadcast_at = futureMillis(calcNextHourDelayMs(getRTCClock()));
18041812
}
18051813

18061814
// update uptime

0 commit comments

Comments
 (0)