From 2fd0d2baff7187cf0c2703066f8052e57d65bcb4 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sat, 15 Jan 2022 08:24:39 -0800 Subject: [PATCH] Fixed borked airtime report in /json/reports For: https://github.com/meshtastic/Meshtastic-device/issues/1086 --- src/airtime.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/airtime.cpp b/src/airtime.cpp index 3f744d4ac..eac58cfc9 100644 --- a/src/airtime.cpp +++ b/src/airtime.cpp @@ -46,8 +46,8 @@ void AirTime::airtimeRotatePeriod() this->airtimes.periodRX[i + 1] = this->airtimes.periodRX[i]; this->airtimes.periodRX_ALL[i + 1] = this->airtimes.periodRX_ALL[i]; - myNodeInfo.air_period_tx[i + 1] = myNodeInfo.air_period_tx[i]; - myNodeInfo.air_period_rx[i + 1] = myNodeInfo.air_period_rx[i]; + myNodeInfo.air_period_tx[i + 1] = this->airtimes.periodTX[i]; + myNodeInfo.air_period_rx[i + 1] = this->airtimes.periodRX[i]; } this->airtimes.periodTX[0] = 0; @@ -111,10 +111,21 @@ int32_t AirTime::runOnce() if (firstTime) { airtimeRotatePeriod(); + // Init channelUtilization window to all 0 for (uint32_t i = 0; i < CHANNEL_UTILIZATION_PERIODS; i++) { this->channelUtilization[i] = 0; } + // Init airtime windows to all 0 + for (int i = 0; i < PERIODS_TO_LOG; i++) { + this->airtimes.periodTX[i] = 0; + this->airtimes.periodRX[i] = 0; + this->airtimes.periodRX_ALL[i] = 0; + + //myNodeInfo.air_period_tx[i] = 0; + //myNodeInfo.air_period_rx[i] = 0; + } + firstTime = false; lastUtilPeriod = utilPeriod;