Add min/max/avg history queries to repeaters

Move TimeSeriesData from simple_sensor into src/helpers and drive it with
monotonic uptime, so RTC changes cannot stall recording or break queries.
Keep the old RTCClock* overloads as deprecated for custom sensor sketches.

Record 24h of battery, noise floor, TX/RX airtime % and MCU temperature on
repeaters and answer the existing 0x04 min/max/avg request using the same
format as sensor nodes. No packets are sent by this feature.
REPEATER_HISTORY_SLOTS=0 removes it; default off on STM32/RP2040.

Add native tests for TimeSeriesData and document the request and channels.
This commit is contained in:
Maxwell committed 2026-11-08 16:34:54 +02:00
1 parent 4deb88dfe8
commit 25c1867bbd
14 files changed
+530 -85

No files matched your search

+9 -3
View File
@@ -789,7 +789,9 @@ SensorMesh::SensorMesh(mesh::MainBoard& board, mesh::Radio& radio, mesh::Millise
{
next_local_advert = next_flood_advert = 0;
dirty_contacts_expiry = 0;
last_read_time = 0;
last_read_time = uint32_t(0) - SENSOR_READ_INTERVAL_SECS; // read immediately on the first loop
last_millis = 0;
uptime_millis = 0;
num_alert_tasks = 0;
set_radio_at = revert_radio_at = 0;
recv_pkt_region = NULL;
@@ -999,6 +1001,9 @@ bool SensorMesh::getGPS(uint8_t channel, float& lat, float& lon, float& alt) {
}
void SensorMesh::loop() {
uint32_t now = millis();
uptime_millis += uint32_t(now - last_millis);
last_millis = now;
mesh::Mesh::loop();
if (next_flood_advert && millisHasNowPassed(next_flood_advert)) {
@@ -1028,7 +1033,8 @@ void SensorMesh::loop() {
}
uint32_t curr = getRTCClock()->getCurrentTime();
if (curr >= last_read_time + SENSOR_READ_INTERVAL_SECS) {
uint32_t uptime_secs = getUptimeSeconds();
if (uint32_t(uptime_secs - last_read_time) >= SENSOR_READ_INTERVAL_SECS) {
telemetry.reset();
telemetry.addVoltage(TELEM_CHANNEL_SELF, (float)board.getBattMilliVolts() / 1000.0f);
// query other sensors -- target specific
@@ -1069,7 +1075,7 @@ void SensorMesh::loop() {
onSensorDataRead();
last_read_time = curr;
last_read_time = uptime_secs;
}
// check the alert send queue