Merge pull request #1099 from mc-hamster/master

AirTime - fix bug in array shifter
This commit is contained in:
Jm Casler 2022-01-15 15:28:39 -08:00 committed by GitHub
commit b53f4214bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -45,8 +45,8 @@ uint8_t AirTime::getPeriodUtilHour() {
void AirTime::airtimeRotatePeriod() void AirTime::airtimeRotatePeriod()
{ {
if (this->airtimes.lastPeriodIndex != currentPeriodIndex()) { if (this->airtimes.lastPeriodIndex != this->currentPeriodIndex()) {
// DEBUG_MSG("Rotating airtimes to a new period = %u\n", currentPeriodIndex()); DEBUG_MSG("Rotating airtimes to a new period = %u\n", this->currentPeriodIndex());
for (int i = PERIODS_TO_LOG - 2; i >= 0; --i) { for (int i = PERIODS_TO_LOG - 2; i >= 0; --i) {
this->airtimes.periodTX[i + 1] = this->airtimes.periodTX[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_tx[0] = 0;
myNodeInfo.air_period_rx[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(); uint8_t utilPeriodTX = this->getPeriodUtilHour();
if (firstTime) { if (firstTime) {
airtimeRotatePeriod();
// Init utilizationTX window to all 0 // Init utilizationTX window to all 0
for (uint32_t i = 0; i < MINUTES_IN_HOUR; i++) { for (uint32_t i = 0; i < MINUTES_IN_HOUR; i++) {
@ -153,6 +152,7 @@ int32_t AirTime::runOnce()
lastUtilPeriod = utilPeriod; lastUtilPeriod = utilPeriod;
} else { } else {
this->airtimeRotatePeriod();
// Reset the channelUtilization window when we roll over // Reset the channelUtilization window when we roll over
if (lastUtilPeriod != utilPeriod) { if (lastUtilPeriod != utilPeriod) {

View File

@ -52,7 +52,6 @@ class AirTime : private concurrency::OSThread
uint32_t channelUtilization[CHANNEL_UTILIZATION_PERIODS]; uint32_t channelUtilization[CHANNEL_UTILIZATION_PERIODS];
uint32_t utilizationTX[MINUTES_IN_HOUR]; uint32_t utilizationTX[MINUTES_IN_HOUR];
uint8_t currentPeriodIndex();
void airtimeRotatePeriod(); void airtimeRotatePeriod();
uint8_t getPeriodsToLog(); uint8_t getPeriodsToLog();
uint32_t getSecondsPerPeriod(); uint32_t getSecondsPerPeriod();
@ -74,6 +73,7 @@ class AirTime : private concurrency::OSThread
uint8_t getPeriodUtilMinute(); uint8_t getPeriodUtilMinute();
uint8_t getPeriodUtilHour(); uint8_t getPeriodUtilHour();
uint8_t currentPeriodIndex();
protected: protected:
virtual int32_t runOnce() override; virtual int32_t runOnce() override;