From 91117ca7c655a5a3cf6bcc804130a58c1013e814 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sat, 15 Jan 2022 15:27:25 -0800 Subject: [PATCH] AirTime - fix bug in array shifter --- src/airtime.cpp | 8 ++++---- src/airtime.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/airtime.cpp b/src/airtime.cpp index df32ca1ba..d8f0229c9 100644 --- a/src/airtime.cpp +++ b/src/airtime.cpp @@ -45,8 +45,8 @@ uint8_t AirTime::getPeriodUtilHour() { void AirTime::airtimeRotatePeriod() { - if (this->airtimes.lastPeriodIndex != currentPeriodIndex()) { - // DEBUG_MSG("Rotating airtimes to a new period = %u\n", currentPeriodIndex()); + if (this->airtimes.lastPeriodIndex != this->currentPeriodIndex()) { + DEBUG_MSG("Rotating airtimes to a new period = %u\n", this->currentPeriodIndex()); for (int i = PERIODS_TO_LOG - 2; i >= 0; --i) { this->airtimes.periodTX[i + 1] = this->airtimes.periodTX[i]; @@ -64,7 +64,7 @@ void AirTime::airtimeRotatePeriod() myNodeInfo.air_period_tx[0] = 0; myNodeInfo.air_period_rx[0] = 0; - this->airtimes.lastPeriodIndex = currentPeriodIndex(); + this->airtimes.lastPeriodIndex = this->currentPeriodIndex(); } } @@ -127,7 +127,6 @@ int32_t AirTime::runOnce() uint8_t utilPeriodTX = this->getPeriodUtilHour(); if (firstTime) { - airtimeRotatePeriod(); // Init utilizationTX window to all 0 for (uint32_t i = 0; i < MINUTES_IN_HOUR; i++) { @@ -153,6 +152,7 @@ int32_t AirTime::runOnce() lastUtilPeriod = utilPeriod; } else { + this->airtimeRotatePeriod(); // Reset the channelUtilization window when we roll over if (lastUtilPeriod != utilPeriod) { diff --git a/src/airtime.h b/src/airtime.h index ecaa1203e..8845ec34d 100644 --- a/src/airtime.h +++ b/src/airtime.h @@ -52,7 +52,6 @@ class AirTime : private concurrency::OSThread uint32_t channelUtilization[CHANNEL_UTILIZATION_PERIODS]; uint32_t utilizationTX[MINUTES_IN_HOUR]; - uint8_t currentPeriodIndex(); void airtimeRotatePeriod(); uint8_t getPeriodsToLog(); uint32_t getSecondsPerPeriod(); @@ -74,6 +73,7 @@ class AirTime : private concurrency::OSThread uint8_t getPeriodUtilMinute(); uint8_t getPeriodUtilHour(); + uint8_t currentPeriodIndex(); protected: virtual int32_t runOnce() override;