Skip to content

Commit b696e08

Browse files
authored
Log antispam (#8241)
* less power spam * Don't warn about the first 4 GPS checksum failures
1 parent fc1737c commit b696e08

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

src/Power.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -828,8 +828,11 @@ void Power::readPowerStatus()
828828

829829
// Notify any status instances that are observing us
830830
const PowerStatus powerStatus2 = PowerStatus(hasBattery, usbPowered, isChargingNow, batteryVoltageMv, batteryChargePercent);
831-
LOG_DEBUG("Battery: usbPower=%d, isCharging=%d, batMv=%d, batPct=%d", powerStatus2.getHasUSB(), powerStatus2.getIsCharging(),
832-
powerStatus2.getBatteryVoltageMv(), powerStatus2.getBatteryChargePercent());
831+
if (millis() > lastLogTime + 50 * 1000) {
832+
LOG_DEBUG("Battery: usbPower=%d, isCharging=%d, batMv=%d, batPct=%d", powerStatus2.getHasUSB(),
833+
powerStatus2.getIsCharging(), powerStatus2.getBatteryVoltageMv(), powerStatus2.getBatteryChargePercent());
834+
lastLogTime = millis();
835+
}
833836
newStatus.notifyObservers(&powerStatus2);
834837
#ifdef DEBUG_HEAP
835838
if (lastheap != memGet.getFreeHeap()) {

src/gps/GPS.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1589,8 +1589,12 @@ bool GPS::lookForLocation()
15891589

15901590
#ifndef TINYGPS_OPTION_NO_STATISTICS
15911591
if (reader.failedChecksum() > lastChecksumFailCount) {
1592-
LOG_WARN("%u new GPS checksum failures, for a total of %u", reader.failedChecksum() - lastChecksumFailCount,
1593-
reader.failedChecksum());
1592+
// In a GPS_DEBUG build we want to log all of these. In production, we only care if there are many of them.
1593+
#ifndef GPS_DEBUG
1594+
if (reader.failedChecksum() > 4)
1595+
#endif
1596+
LOG_WARN("%u new GPS checksum failures, for a total of %u", reader.failedChecksum() - lastChecksumFailCount,
1597+
reader.failedChecksum());
15941598
lastChecksumFailCount = reader.failedChecksum();
15951599
}
15961600
#endif

src/power.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ class Power : private concurrency::OSThread
138138
void reboot();
139139
// open circuit voltage lookup table
140140
uint8_t low_voltage_counter;
141+
int32_t lastLogTime = 0;
141142
#ifdef DEBUG_HEAP
142143
uint32_t lastheap;
143144
#endif

0 commit comments

Comments
 (0)