logging: compile out LOG_TRACE by default, demote chatty DEBUG lines, drop redundant logs (#11391)

* logging: gate LOG_TRACE behind MESHTASTIC_TRACE_LOGGING, drop redundant reclock logs

LOG_TRACE now compiles out by default so trace-level diagnostics cost no
flash; enable with -DMESHTASTIC_TRACE_LOGGING. Portduino keeps it on for
the traceFilename packet-trace feature.

Remove the 66 caller-side I2C reclock/restore log lines in the telemetry
sensors: ReClockI2C::setClock/restoreClock already log both frequencies
internally (now at trace level, since they fire every sensor read).

Also unify near-duplicate literals (colon/case/punctuation variants) so
linker string dedup applies, and drop an information-free bare 'done'.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LBiZc9sfPrH1MZ2L3Fxgt1

* logging: demote chatty per-packet/per-poll DEBUG lines to trace level

With LOG_TRACE compiled out by default, per-iteration chatter (packet
bookkeeping, sensor poll values, e-ink refresh reasons, GPS pin states,
UI runState traces) now costs no flash on device builds while remaining
one -DMESHTASTIC_TRACE_LOGGING away. 108 lines demoted, 4 information-
free lines removed; failure paths, drop reasons, and one-time init logs
all stay at debug level.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LBiZc9sfPrH1MZ2L3Fxgt1

* logging: address CodeRabbit review on trace-gate PR

- GPS: pass serial-derived buffers as %s args, never as format strings
  (untrusted bytes could contain % directives)
- 0x%08x for packet id / NodeNum per convention (Router, CannedMessage,
  NeighborInfo); unsigned casts for size_t args; %u for uint32_t delta
- EInk: async full-refresh begin/complete back to DEBUG (rare state
  transitions); per-frame SKIPPED lines stay trace

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LBiZc9sfPrH1MZ2L3Fxgt1

* logging: gate trace on the flag's value, not its presence

-DMESHTASTIC_TRACE_LOGGING=0 previously *enabled* trace logging because
the gate tested definedness. The flag now defaults per-platform
(portduino 1, else 0) and both backends test the value, so =0 disables,
=1 or a bare -D enables. Also cast tx_after-millis() to uint32_t for %u
(millis() is unsigned long on native).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LBiZc9sfPrH1MZ2L3Fxgt1

* logging: clang-format rewrap after specifier widening

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LBiZc9sfPrH1MZ2L3Fxgt1

* Even fewer bytes!

* logging: keep compile-gated debug lines at debug level; fix native-suite-count

Lines already inside default-off #ifdef blocks (GPS_DEBUG,
DEBUG_LOOP_TIMING) cost no flash and should stay visible at debug level
when their gate is enabled, rather than also requiring
MESHTASTIC_TRACE_LOGGING.

test/native-suite-count lags the two test_event_channel_* suites added
by #11045 (develop's Native Suite Count check has the same mismatch);
bump 46 -> 47.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LBiZc9sfPrH1MZ2L3Fxgt1

* gps: route GPS_DEBUG diagnostics through a LOG_DEBUG_GPS() macro (#11414)

Replaces 27 log-only #ifdef GPS_DEBUG blocks across GPS.cpp,
PositionModule, MeshService, and GPSStatus.h with a single-line
LOG_DEBUG_GPS() call (src/gps/GPSLog.h, modeled on LOG_MIGRATION:
value-gated, ((void)0) when off). Blocks containing declarations,
control flow, hexDump, or nested conditionals keep an explicit
'#if GPS_DEBUG' guard. RTC.cpp's per-reading raw time dumps and
per-candidate rejection chatter fold under the same gate; quality
transitions and boot-time seeding stay at debug.

Also fixes the '// define GPS_DEBUG' missing-# typo in two variant
headers and updates all seven commented examples to the value form
('#define GPS_DEBUG 1') required by the value-based gate.


Claude-Session: https://claude.ai/code/session_01LBiZc9sfPrH1MZ2L3Fxgt1

Co-authored-by: Claude <noreply@anthropic.com>

* gps: declare RTC gmtime result as pointer to const (cppcheck)

With the setTime debug dump gated behind GPS_DEBUG, all remaining uses
of t are reads; cppcheck (constVariablePointer) now flags it.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LBiZc9sfPrH1MZ2L3Fxgt1

---------

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Jonathan Bennett
2026-08-12 00:05:51 +00:00
committed by GitHub
co-authored by Claude Fable 5
parent c5979a85bf
commit 5baad2e2a8
47 changed files with 216 additions and 310 deletions
+2 -2
View File
@@ -151,7 +151,7 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta
LOG_INFO("Ignore admin response from 0x%08x, no outstanding request", mp.from);
return handled;
}
LOG_DEBUG("Allow admin response message");
LOG_TRACE("Allow admin response message");
} else if (mp.from == 0) {
// Local admin from a BLE/USB/TCP client. from == 0 cannot arrive from the
// mesh: RF drops packets without a sender (RadioLibInterface) and MQTT treats
@@ -2168,7 +2168,7 @@ bool AdminModule::messageIsRequest(const meshtastic_AdminMessage *r)
void AdminModule::handleSendInputEvent(const meshtastic_AdminMessage_InputEvent &inputEvent)
{
LOG_DEBUG("Processing input event: event_code=%u, kb_char=%u, touch_x=%u, touch_y=%u", inputEvent.event_code,
LOG_TRACE("Processing input event: event_code=%u, kb_char=%u, touch_x=%u, touch_y=%u", inputEvent.event_code,
inputEvent.kb_char, inputEvent.touch_x, inputEvent.touch_y);
// Create InputEvent for injection.
+5 -6
View File
@@ -112,7 +112,7 @@ void CannedMessageModule::LaunchWithDestination(NodeNum newDest, uint8_t newChan
e.action = UIFrameEvent::Action::REGENERATE_FRAMESET;
notifyObservers(&e);
LOG_DEBUG("[CannedMessage] LaunchWithDestination dest=0x%08x ch=%d", dest, channel);
LOG_TRACE("[CannedMessage] LaunchWithDestination dest=0x%08x ch=%d", dest, channel);
}
void CannedMessageModule::LaunchFreetextWithDestination(NodeNum newDest, uint8_t newChannel)
@@ -135,7 +135,7 @@ void CannedMessageModule::LaunchFreetextWithDestination(NodeNum newDest, uint8_t
e.action = UIFrameEvent::Action::REGENERATE_FRAMESET;
notifyObservers(&e);
LOG_DEBUG("[CannedMessage] LaunchFreetextWithDestination dest=0x%08x ch=%d", dest, channel);
LOG_TRACE("[CannedMessage] LaunchFreetextWithDestination dest=0x%08x ch=%d", dest, channel);
}
static bool returnToCannedList = false;
@@ -891,8 +891,8 @@ bool CannedMessageModule::handleFreeTextInput(const InputEvent *event)
// Confirm select (Enter)
bool isSelect = isSelectEvent(event);
if (isSelect) {
LOG_DEBUG("[SELECT] handleFreeTextInput: runState=%d, dest=%u, channel=%d, freetext='%s'", (int)runState, dest, channel,
freetext.c_str());
LOG_TRACE("[SELECT] handleFreeTextInput: runState=%d, dest=0x%08x, channel=%d, freetext='%s'", (int)runState, dest,
channel, freetext.c_str());
if (dest == 0)
dest = NODENUM_BROADCAST;
// Defensive: If channel isn't valid, pick the first available channel
@@ -2336,7 +2336,6 @@ AdminMessageHandleResult CannedMessageModule::handleAdminMessageForModule(const
void CannedMessageModule::handleGetCannedMessageModuleMessages(const meshtastic_MeshPacket &req,
meshtastic_AdminMessage *response)
{
LOG_DEBUG("*** handleGetCannedMessageModuleMessages");
if (req.decoded.want_response) {
response->which_payload_variant = meshtastic_AdminMessage_get_canned_message_module_messages_response_tag;
strncpy(response->get_canned_message_module_messages_response, cannedMessageModuleConfig.messages,
@@ -2351,7 +2350,7 @@ void CannedMessageModule::handleSetCannedMessageModuleMessages(const char *from_
if (*from_msg) {
changed |= strcmp(cannedMessageModuleConfig.messages, from_msg);
strncpy(cannedMessageModuleConfig.messages, from_msg, sizeof(cannedMessageModuleConfig.messages));
LOG_DEBUG("*** from_msg.text:%s", from_msg);
LOG_TRACE("*** from_msg.text:%s", from_msg);
}
if (changed) {
+8 -9
View File
@@ -14,11 +14,11 @@ NOTE: For debugging only
*/
void NeighborInfoModule::printNeighborInfo(const char *header, const meshtastic_NeighborInfo *np)
{
LOG_DEBUG("%s NEIGHBORINFO PACKET from Node 0x%08x to Node 0x%08x (last sent by 0x%08x)", header, np->node_id,
LOG_TRACE("%s NEIGHBORINFO PACKET from Node 0x%08x to Node 0x%08x (last sent by 0x%08x)", header, np->node_id,
nodeDB->getNodeNum(), np->last_sent_by_id);
LOG_DEBUG("Packet contains %d neighbors", np->neighbors_count);
LOG_TRACE("Packet contains %d neighbors", np->neighbors_count);
for (int i = 0; i < np->neighbors_count; i++) {
LOG_DEBUG("Neighbor %d: node_id=0x%08x, snr=%.2f", i, np->neighbors[i].node_id, np->neighbors[i].snr);
LOG_TRACE("Neighbor %d: node_id=0x%08x, snr=%.2f", i, np->neighbors[i].node_id, np->neighbors[i].snr);
}
}
@@ -28,9 +28,9 @@ NOTE: for debugging only
*/
void NeighborInfoModule::printNodeDBNeighbors()
{
LOG_DEBUG("Our NodeDB contains %d neighbors", neighbors.size());
LOG_TRACE("Our NodeDB contains %u neighbors", (unsigned)neighbors.size());
for (size_t i = 0; i < neighbors.size(); i++) {
LOG_DEBUG("Node %d: node_id=0x%08x, snr=%.2f", i, neighbors[i].node_id, neighbors[i].snr);
LOG_TRACE("Node %u: node_id=0x%08x, snr=%.2f", (unsigned)i, neighbors[i].node_id, neighbors[i].snr);
}
}
@@ -162,18 +162,18 @@ Pass it to an upper client; do not persist this data on the mesh
*/
bool NeighborInfoModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_NeighborInfo *np)
{
LOG_DEBUG("NeighborInfo: handleReceivedProtobuf");
LOG_TRACE("NeighborInfo: handleReceivedProtobuf");
if (np) {
printNeighborInfo("RECEIVED", np);
// Ignore dummy/interceptable packets: single neighbor with nodeId 0 and snr 0
if (np->neighbors_count != 1 || np->neighbors[0].node_id != 0 || np->neighbors[0].snr != 0.0f) {
LOG_DEBUG(" Updating neighbours");
LOG_TRACE(" Updating neighbours");
updateNeighbors(mp, np);
} else {
LOG_DEBUG(" Ignoring dummy neighbor info packet (single neighbor with nodeId 0, snr 0)");
}
} else if (getHopsAway(mp) == 0) {
LOG_DEBUG("Get or create neighbor: %u with snr %f", mp.from, mp.rx_snr);
LOG_TRACE("Get or create neighbor: 0x%08x with snr %f", mp.from, mp.rx_snr);
// If the hopLimit is the same as hopStart, then it is a neighbor
getOrCreateNeighbor(mp.from, mp.from, 0,
mp.rx_snr); // Set the broadcast interval to 0, as we don't know it
@@ -202,7 +202,6 @@ void NeighborInfoModule::resetNeighbors()
void NeighborInfoModule::updateNeighbors(const meshtastic_MeshPacket &mp, const meshtastic_NeighborInfo *np)
{
LOG_DEBUG("updateNeighbors");
// The last sent ID will be 0 if the packet is from the phone, which we don't
// count as an edge. So we assume that if it's zero, then this packet is from
// our node.
+7 -16
View File
@@ -10,6 +10,7 @@
#include "TypeConversions.h"
#include "airtime.h"
#include "configuration.h"
#include "gps/GPSLog.h"
#include "gps/GeoCoord.h"
#include "gps/RTC.h"
#include "main.h"
@@ -81,13 +82,13 @@ bool PositionModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, mes
nodeDB->setLocalPosition(p, true);
return false;
} else {
LOG_DEBUG("Incoming update from MYSELF");
LOG_TRACE("Incoming update from MYSELF");
nodeDB->setLocalPosition(p);
}
}
// Log packet size and data fields
LOG_DEBUG("POSITION node=0x%08x l=%d lat=%d lon=%d msl=%d hae=%d geo=%d pdop=%d hdop=%d vdop=%d siv=%d fxq=%d fxt=%d pts=%d "
LOG_TRACE("POSITION node=0x%08x l=%d lat=%d lon=%d msl=%d hae=%d geo=%d pdop=%d hdop=%d vdop=%d siv=%d fxq=%d fxt=%d pts=%d "
"time=%d",
getFrom(&mp), mp.decoded.payload.size, p.latitude_i, p.longitude_i, p.altitude, p.altitude_hae,
p.altitude_geoidal_separation, p.PDOP, p.HDOP, p.VDOP, p.sats_in_view, p.fix_quality, p.fix_type, p.timestamp,
@@ -363,7 +364,7 @@ meshtastic_MeshPacket *PositionModule::allocAtakPli()
memcpy(mp->decoded.payload.bytes + 1, protobuf_bytes, proto_size);
mp->decoded.payload.size = proto_size + 1;
LOG_DEBUG("TAK V2 PLI payload: %zu bytes (1 flags + %zu protobuf)", mp->decoded.payload.size, proto_size);
LOG_TRACE("TAK V2 PLI payload: %zu bytes (1 flags + %zu protobuf)", mp->decoded.payload.size, proto_size);
return mp;
}
@@ -557,9 +558,7 @@ int32_t PositionModule::runOnce()
if (lastGpsSend == 0 || msSinceLastSend >= effectiveIntervalMs) {
if (waitingForFreshPosition) {
#ifdef GPS_DEBUG
LOG_DEBUG("Skip initial position send; no fresh position since boot");
#endif
LOG_DEBUG_GPS("Skip initial position send; no fresh position since boot");
} else if (nodeDB->hasValidPosition(node)) {
lastGpsSend = now;
@@ -591,11 +590,7 @@ int32_t PositionModule::runOnce()
if (smartPosition.hasTraveledOverThreshold &&
Throttle::execute(
&lastGpsSend, minimumTimeThreshold, []() { positionModule->sendOurPosition(); },
[]() {
#ifdef GPS_DEBUG
LOG_DEBUG("Skip smart broadcast: time throttled");
#endif
})) {
[]() { LOG_DEBUG_GPS("Skip smart broadcast: time throttled"); })) {
LOG_DEBUG("Sent smart pos@%x:6 to mesh (distanceTraveled=%fm, minDistanceThreshold=%im, timeElapsed=%ims, "
"minTimeInterval=%ims)",
@@ -701,11 +696,7 @@ void PositionModule::handleNewPosition()
if (smartPosition.hasTraveledOverThreshold &&
Throttle::execute(
&lastGpsSend, minimumTimeThreshold, []() { positionModule->sendOurPosition(); },
[]() {
#ifdef GPS_DEBUG
LOG_DEBUG("Skip smart broadcast: time throttled");
#endif
})) {
[]() { LOG_DEBUG_GPS("Skip smart broadcast: time throttled"); })) {
LOG_DEBUG("Sent smart pos@%x:6 to mesh (distanceTraveled=%fm, minDistanceThreshold=%im, timeElapsed=%ims, "
"minTimeInterval=%ims)",
localPosition.timestamp, smartPosition.distanceTraveled, smartPosition.distanceThreshold, msSinceLastSend,
+1 -1
View File
@@ -99,7 +99,7 @@ int32_t RangeTestModule::runOnce()
}
}
} else {
LOG_INFO("Range Test Module - Disabled");
LOG_INFO("Range Test Module Disabled");
}
#endif
@@ -187,7 +187,7 @@ int32_t AirQualityTelemetryModule::runOnce()
// - We can publish the data on the mesh shortly
// - Or we can send it to the phone
// TODO: This will need to be refurbished once we implement separate intervals
LOG_INFO("Waking up sensors");
LOG_INFO("Waking sensors");
for (TelemetrySensor *sensor : sensors) {
if (!sensor->canSleep()) {
LOG_DEBUG("%s: no sleep support, skip", sensor->sensorName);
@@ -207,7 +207,7 @@ int32_t AirQualityTelemetryModule::runOnce()
}
if (!sensor->isActive()) {
LOG_DEBUG("Waking up: %s", sensor->sensorName);
LOG_DEBUG("Waking %s", sensor->sensorName);
if (awakeAheadOfTimeMs == 0)
startAirQualityTelemetryCycle = millis();
awakeAheadOfTimeMs = max(awakeAheadOfTimeMs, sensor->wakeUpTimeMs());
+1 -1
View File
@@ -312,7 +312,7 @@ bool PowerTelemetryModule::sendTelemetry(NodeNum dest, bool phoneOnly)
LOG_WARN("Power telemetry unavailable this cycle, sleep without sending");
sleepOnNextExecution = true;
preflightSleepDeferrals = 0;
LOG_DEBUG("Start next execution in 5s then sleep");
LOG_DEBUG("Start next execution in 5s, then sleep");
setIntervalFromNow(FIVE_SECONDS_MS);
}
return validTelemetry;
@@ -136,7 +136,7 @@ void BME680Sensor::loadState()
file.read((uint8_t *)&bsecState, BSEC_MAX_STATE_BLOB_SIZE);
file.close();
bme680.setState(bsecState);
LOG_INFO("%s state read from %s", sensorName, bsecConfigFileName);
LOG_INFO("%s: state read from %s", sensorName, bsecConfigFileName);
} else {
LOG_INFO("No %s state found (File: %s)", sensorName, bsecConfigFileName);
}
@@ -177,7 +177,7 @@ void BME680Sensor::updateState()
}
auto file = FSCom.open(bsecConfigFileName, FILE_O_WRITE);
if (file) {
LOG_INFO("%s state write to %s", sensorName, bsecConfigFileName);
LOG_INFO("%s: state write to %s", sensorName, bsecConfigFileName);
file.write((uint8_t *)&bsecState, BSEC_MAX_STATE_BLOB_SIZE);
file.flush();
file.close();
@@ -63,8 +63,6 @@ bool DS248XSensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
#ifdef DS248X_I2C_CLOCK_SPEED
reClockI2C.setup(_bus, _port);
LOG_INFO("%s: attempting to reclock speed to %uHz", sensorName, DS248X_I2C_CLOCK_SPEED);
reClockI2C.setClock(DS248X_I2C_CLOCK_SPEED);
#endif /* DS248X_I2C_CLOCK_SPEED */
@@ -176,7 +174,6 @@ bool DS248XSensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
}
#ifdef DS248X_I2C_CLOCK_SPEED
LOG_INFO("%s: restoring clock speed", sensorName);
reClockI2C.restoreClock();
#endif /* DS248X_I2C_CLOCK_SPEED */
@@ -193,7 +190,6 @@ bool DS248XSensor::isValidROM(const uint8_t *rom)
float DS248XSensor::readTemperatureROM(const uint8_t *rom)
{
#ifdef DS248X_I2C_CLOCK_SPEED
LOG_DEBUG("%s: attempting to reclock speed to %uHz", sensorName, DS248X_I2C_CLOCK_SPEED);
reClockI2C.setClock(DS248X_I2C_CLOCK_SPEED);
#endif /* DS248X_I2C_CLOCK_SPEED */
@@ -224,7 +220,6 @@ float DS248XSensor::readTemperatureROM(const uint8_t *rom)
}
#ifdef DS248X_I2C_CLOCK_SPEED
LOG_DEBUG("%s: restoring clock speed", sensorName);
reClockI2C.restoreClock();
#endif /* DS248X_I2C_CLOCK_SPEED */
@@ -17,14 +17,11 @@ bool HM330XSensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
#ifdef HM330X_I2C_CLOCK_SPEED
_port = dev->address.port;
reClockI2C.setup(_bus, _port);
LOG_INFO("%s: attempting to reclock speed to %uHz", sensorName, HM330X_I2C_CLOCK_SPEED);
reClockI2C.setClock(HM330X_I2C_CLOCK_SPEED);
#endif /* HM330X_I2C_CLOCK_SPEED */
if (hm330x.init(_bus) != HM330XErrorCode::NO_ERROR) {
#ifdef HM330X_I2C_CLOCK_SPEED
LOG_INFO("%s: restoring clock speed", sensorName);
reClockI2C.restoreClock();
#endif /* HM330X_I2C_CLOCK_SPEED */
LOG_WARN("%s error in sensor init", sensorName);
@@ -32,7 +29,6 @@ bool HM330XSensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
}
#ifdef HM330X_I2C_CLOCK_SPEED
LOG_INFO("%s: restoring clock speed", sensorName);
reClockI2C.restoreClock();
#endif /* HM330X_I2C_CLOCK_SPEED */
@@ -83,21 +79,18 @@ int32_t HM330XSensor::pendingForReadyMs()
bool HM330XSensor::getMetrics(meshtastic_Telemetry *measurement)
{
#ifdef HM330X_I2C_CLOCK_SPEED
LOG_DEBUG("%s: attempting to reclock speed to %uHz", sensorName, HM330X_I2C_CLOCK_SPEED);
reClockI2C.setClock(HM330X_I2C_CLOCK_SPEED);
#endif /* HM330X_I2C_CLOCK_SPEED */
if (hm330x.read_sensor_value(buffer, 29)) {
LOG_WARN("%s: read result failed", sensorName);
#ifdef HM330X_I2C_CLOCK_SPEED
LOG_INFO("%s: restoring clock speed", sensorName);
reClockI2C.restoreClock();
#endif /* HM330X_I2C_CLOCK_SPEED */
return false;
}
#ifdef HM330X_I2C_CLOCK_SPEED
LOG_INFO("%s: restoring clock speed", sensorName);
reClockI2C.restoreClock();
#endif /* HM330X_I2C_CLOCK_SPEED */
@@ -53,7 +53,7 @@ bool MAX17048Singleton::isBatteryCharging()
chargeState = MAX17048ChargeState::IDLE;
}
LOG_DEBUG("%s::isBatteryCharging %s volts: %.3f soc: %.3f rate: %.3f", sensorStr, chargeLabels[chargeState], volts,
LOG_TRACE("%s::isBatteryCharging %s volts: %.3f soc: %.3f rate: %.3f", sensorStr, chargeLabels[chargeState], volts,
sample.cellPercent, sample.chargeRate);
return chargeState == MAX17048ChargeState::IMPORT;
}
@@ -65,14 +65,14 @@ uint16_t MAX17048Singleton::getBusVoltageMv()
LOG_DEBUG("%s::getBusVoltageMv is not connected", sensorStr);
return 0;
}
LOG_DEBUG("%s::getBusVoltageMv %.3fmV", sensorStr, volts);
LOG_TRACE("%s::getBusVoltageMv %.3fmV", sensorStr, volts);
return (uint16_t)(volts * 1000.0f);
}
uint8_t MAX17048Singleton::getBusBatteryPercent()
{
float soc = cellPercent();
LOG_DEBUG("%s::getBusBatteryPercent %.1f%%", sensorStr, soc);
LOG_TRACE("%s::getBusBatteryPercent %.1f%%", sensorStr, soc);
return clamp(static_cast<uint8_t>(round(soc)), static_cast<uint8_t>(0), static_cast<uint8_t>(100));
}
@@ -82,7 +82,7 @@ uint16_t MAX17048Singleton::getTimeToGoSecs()
float soc = cellPercent(); // state of charge in percent 0 to 100
soc = clamp(soc, 0.0f, 100.0f); // clamp soc between 0 and 100%
float ttg = ((100.0f - soc) / rate) * 3600.0f; // calculate seconds to charge/discharge
LOG_DEBUG("%s::getTimeToGoSecs %.0f seconds", sensorStr, ttg);
LOG_TRACE("%s::getTimeToGoSecs %.0f seconds", sensorStr, ttg);
return (uint16_t)ttg;
}
@@ -108,7 +108,7 @@ bool MAX17048Singleton::isExternallyPowered()
}
// if the bus voltage is over MAX17048_BUS_POWER_VOLTS, then the external power
// is assumed to be connected
LOG_DEBUG("%s::isExternallyPowered %s connected", sensorStr, volts >= MAX17048_BUS_POWER_VOLTS ? "is" : "is not");
LOG_TRACE("%s::isExternallyPowered %s connected", sensorStr, volts >= MAX17048_BUS_POWER_VOLTS ? "is" : "is not");
return volts >= MAX17048_BUS_POWER_VOLTS;
}
@@ -140,7 +140,7 @@ void MAX17048Sensor::setup() {}
bool MAX17048Sensor::getMetrics(meshtastic_Telemetry *measurement)
{
LOG_DEBUG("MAX17048 getMetrics id: %i", measurement->which_variant);
LOG_TRACE("MAX17048 getMetrics id: %i", measurement->which_variant);
float volts = max17048->cellVoltage();
if (isnan(volts)) {
@@ -24,8 +24,6 @@ bool PMSA003ISensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
#ifdef PMSA003I_I2C_CLOCK_SPEED
_port = dev->address.port;
reClockI2C.setup(_bus, _port);
LOG_INFO("%s: attempting to reclock speed to %uHz", sensorName, PMSA003I_I2C_CLOCK_SPEED);
reClockI2C.setClock(PMSA003I_I2C_CLOCK_SPEED);
#endif /* PMSA003I_I2C_CLOCK_SPEED */
@@ -33,7 +31,6 @@ bool PMSA003ISensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
if (_bus->endTransmission() != 0) {
LOG_WARN("%s not found on I2C at 0x12", sensorName);
#ifdef PMSA003I_I2C_CLOCK_SPEED
LOG_INFO("%s: restoring clock speed", sensorName);
reClockI2C.restoreClock();
#endif /* PMSA003I_I2C_CLOCK_SPEED */
sleep();
@@ -41,7 +38,6 @@ bool PMSA003ISensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
}
#ifdef PMSA003I_I2C_CLOCK_SPEED
LOG_INFO("%s: restoring clock speed", sensorName);
reClockI2C.restoreClock();
#endif /* PMSA003I_I2C_CLOCK_SPEED */
@@ -61,7 +57,6 @@ bool PMSA003ISensor::getMetrics(meshtastic_Telemetry *measurement)
}
#ifdef PMSA003I_I2C_CLOCK_SPEED
LOG_DEBUG("%s: attempting to reclock speed to %uHz", sensorName, PMSA003I_I2C_CLOCK_SPEED);
reClockI2C.setClock(PMSA003I_I2C_CLOCK_SPEED);
#endif /* PMSA003I_I2C_CLOCK_SPEED */
@@ -69,7 +64,6 @@ bool PMSA003ISensor::getMetrics(meshtastic_Telemetry *measurement)
if (_bus->available() < PMSA003I_FRAME_LENGTH) {
LOG_WARN("%s: read failed: incomplete data (%d bytes)", sensorName, _bus->available());
#ifdef PMSA003I_I2C_CLOCK_SPEED
LOG_DEBUG("%s: restoring clock speed", sensorName);
reClockI2C.restoreClock();
#endif /* PMSA003I_I2C_CLOCK_SPEED */
return false;
@@ -80,7 +74,6 @@ bool PMSA003ISensor::getMetrics(meshtastic_Telemetry *measurement)
}
#ifdef PMSA003I_I2C_CLOCK_SPEED
LOG_DEBUG("%s: restoring clock speed", sensorName);
reClockI2C.restoreClock();
#endif /* PMSA003I_I2C_CLOCK_SPEED */
@@ -199,7 +192,7 @@ void PMSA003ISensor::sleep()
uint32_t PMSA003ISensor::wakeUp()
{
#ifdef PMSA003I_ENABLE_PIN
LOG_INFO("%s: Waking up", sensorName);
LOG_INFO("%s Waking", sensorName);
digitalWrite(PMSA003I_ENABLE_PIN, HIGH);
state = PMSA003I_ACTIVE;
pmMeasureStarted = getTime();
@@ -18,8 +18,6 @@ bool SCD30Sensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
#ifdef SCD30_I2C_CLOCK_SPEED
_port = dev->address.port;
reClockI2C.setup(_bus, _port);
LOG_INFO("%s: reclock to %uHz", sensorName, SCD30_I2C_CLOCK_SPEED);
reClockI2C.setClock(SCD30_I2C_CLOCK_SPEED);
#endif /* SCD30_I2C_CLOCK_SPEED */
@@ -28,7 +26,6 @@ bool SCD30Sensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
if (!startMeasurement()) {
LOG_ERROR("%s: Periodic measurement start failed", sensorName);
#ifdef SCD30_I2C_CLOCK_SPEED
LOG_INFO("%s: restoring clock speed", sensorName);
reClockI2C.restoreClock();
#endif /* SCD30_I2C_CLOCK_SPEED */
return false;
@@ -39,7 +36,6 @@ bool SCD30Sensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
}
#ifdef SCD30_I2C_CLOCK_SPEED
LOG_INFO("%s: restoring clock speed", sensorName);
reClockI2C.restoreClock();
#endif /* SCD30_I2C_CLOCK_SPEED */
@@ -59,21 +55,18 @@ bool SCD30Sensor::getMetrics(meshtastic_Telemetry *measurement)
float co2, temperature, humidity;
#ifdef SCD30_I2C_CLOCK_SPEED
LOG_DEBUG("%s: reclock to %uHz", sensorName, SCD30_I2C_CLOCK_SPEED);
reClockI2C.setClock(SCD30_I2C_CLOCK_SPEED);
#endif /* SCD30_I2C_CLOCK_SPEED */
if (scd30.readMeasurementData(co2, temperature, humidity) != SCD30_NO_ERROR) {
LOG_ERROR("%s: Measurement read failed", sensorName);
#ifdef SCD30_I2C_CLOCK_SPEED
LOG_DEBUG("%s: restoring clock speed", sensorName);
reClockI2C.restoreClock();
#endif /* SCD30_I2C_CLOCK_SPEED */
return false;
}
#ifdef SCD30_I2C_CLOCK_SPEED
LOG_DEBUG("%s: restoring clock speed", sensorName);
reClockI2C.restoreClock();
#endif /* SCD30_I2C_CLOCK_SPEED */
@@ -366,14 +359,12 @@ bool SCD30Sensor::isActive()
uint32_t SCD30Sensor::wakeUp()
{
#ifdef SCD30_I2C_CLOCK_SPEED
LOG_INFO("%s: reclock to %uHz", sensorName, SCD30_I2C_CLOCK_SPEED);
reClockI2C.setClock(SCD30_I2C_CLOCK_SPEED);
#endif /* SCD30_I2C_CLOCK_SPEED */
startMeasurement();
#ifdef SCD30_I2C_CLOCK_SPEED
LOG_INFO("%s: restoring clock speed", sensorName);
reClockI2C.restoreClock();
#endif /* SCD30_I2C_CLOCK_SPEED */
@@ -387,14 +378,12 @@ uint32_t SCD30Sensor::wakeUp()
void SCD30Sensor::sleep()
{
#ifdef SCD30_I2C_CLOCK_SPEED
LOG_INFO("%s: reclock to %uHz", sensorName, SCD30_I2C_CLOCK_SPEED);
reClockI2C.setClock(SCD30_I2C_CLOCK_SPEED);
#endif /* SCD30_I2C_CLOCK_SPEED */
stopMeasurement();
#ifdef SCD30_I2C_CLOCK_SPEED
LOG_INFO("%s: restoring clock speed", sensorName);
reClockI2C.restoreClock();
#endif /* SCD30_I2C_CLOCK_SPEED */
}
@@ -420,7 +409,6 @@ AdminMessageHandleResult SCD30Sensor::handleAdminMessage(const meshtastic_MeshPa
AdminMessageHandleResult result;
#ifdef SCD30_I2C_CLOCK_SPEED
LOG_INFO("%s: reclock to %uHz", sensorName, SCD30_I2C_CLOCK_SPEED);
reClockI2C.setClock(SCD30_I2C_CLOCK_SPEED);
#endif /* SCD30_I2C_CLOCK_SPEED */
@@ -478,7 +466,6 @@ AdminMessageHandleResult SCD30Sensor::handleAdminMessage(const meshtastic_MeshPa
}
#ifdef SCD30_I2C_CLOCK_SPEED
LOG_INFO("%s: restoring clock speed", sensorName);
reClockI2C.restoreClock();
#endif /* SCD30_I2C_CLOCK_SPEED */
+3 -24
View File
@@ -19,8 +19,6 @@ bool SCD4XSensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
#ifdef SCD4X_I2C_CLOCK_SPEED
_port = dev->address.port;
reClockI2C.setup(_bus, _port);
LOG_INFO("%s: reclock to %uHz", sensorName, SCD4X_I2C_CLOCK_SPEED);
reClockI2C.setClock(SCD4X_I2C_CLOCK_SPEED);
#endif /* SCD4X_I2C_CLOCK_SPEED */
@@ -32,7 +30,6 @@ bool SCD4XSensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
// Stop periodic measurement
if (!stopMeasurement()) {
#ifdef SCD4X_I2C_CLOCK_SPEED
LOG_INFO("%s: restoring clock speed", sensorName);
reClockI2C.restoreClock();
#endif /* SCD4X_I2C_CLOCK_SPEED */
return false;
@@ -46,7 +43,6 @@ bool SCD4XSensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
if (!powerUp()) {
LOG_ERROR("%s: powerUp() failed", sensorName);
#ifdef SCD4X_I2C_CLOCK_SPEED
LOG_INFO("%s: restoring clock speed", sensorName);
reClockI2C.restoreClock();
#endif /* SCD4X_I2C_CLOCK_SPEED */
return false;
@@ -56,7 +52,6 @@ bool SCD4XSensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
if (!getASC(ascActive)) {
LOG_ERROR("%s: Can't check if ASC enabled", sensorName);
#ifdef SCD4X_I2C_CLOCK_SPEED
LOG_INFO("%s: restoring clock speed", sensorName);
reClockI2C.restoreClock();
#endif /* SCD4X_I2C_CLOCK_SPEED */
return false;
@@ -66,14 +61,12 @@ bool SCD4XSensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
if (!startMeasurement()) {
LOG_ERROR("%s: Can't start measurement", sensorName);
#ifdef SCD4X_I2C_CLOCK_SPEED
LOG_INFO("%s: restoring clock speed", sensorName);
reClockI2C.restoreClock();
#endif /* SCD4X_I2C_CLOCK_SPEED */
return false;
}
#ifdef SCD4X_I2C_CLOCK_SPEED
LOG_INFO("%s: restoring clock speed", sensorName);
reClockI2C.restoreClock();
#endif /* SCD4X_I2C_CLOCK_SPEED */
@@ -100,7 +93,6 @@ bool SCD4XSensor::getMetrics(meshtastic_Telemetry *measurement)
float temperature, humidity;
#ifdef SCD4X_I2C_CLOCK_SPEED
LOG_DEBUG("%s: reclock to %uHz", sensorName, SCD4X_I2C_CLOCK_SPEED);
reClockI2C.setClock(SCD4X_I2C_CLOCK_SPEED);
#endif /* SCD4X_I2C_CLOCK_SPEED */
@@ -118,7 +110,6 @@ bool SCD4XSensor::getMetrics(meshtastic_Telemetry *measurement)
if (error != SCD4X_NO_ERROR || !dataReady) {
#ifdef SCD4X_I2C_CLOCK_SPEED
LOG_DEBUG("%s: restoring clock speed", sensorName);
reClockI2C.restoreClock();
#endif /* SCD4X_I2C_CLOCK_SPEED */
LOG_ERROR("SCD4X: Data is not ready");
@@ -128,7 +119,6 @@ bool SCD4XSensor::getMetrics(meshtastic_Telemetry *measurement)
error = scd4x.readMeasurement(co2, temperature, humidity);
#ifdef SCD4X_I2C_CLOCK_SPEED
LOG_DEBUG("%s: restoring clock speed", sensorName);
reClockI2C.restoreClock();
#endif /* SCD4X_I2C_CLOCK_SPEED */
@@ -290,7 +280,7 @@ bool SCD4XSensor::getASC(uint16_t &_ascActive)
return false;
}
LOG_INFO("%s ASC is %s", sensorName, _ascActive ? "enabled" : "disabled");
LOG_INFO("%s: ASC is %s", sensorName, _ascActive ? "enabled" : "disabled");
return true;
}
@@ -308,7 +298,7 @@ bool SCD4XSensor::setASC(bool ascEnabled)
{
uint16_t error;
LOG_INFO("%s %s ASC", sensorName, ascEnabled ? "Enabling" : "Disabling");
LOG_INFO("%s: %s ASC", sensorName, ascEnabled ? "Enabling" : "Disabling");
if (!stopMeasurement()) {
return false;
@@ -644,13 +634,11 @@ bool SCD4XSensor::powerDown()
}
#ifdef SCD4X_I2C_CLOCK_SPEED
LOG_INFO("%s: reclock to %uHz", sensorName, SCD4X_I2C_CLOCK_SPEED);
reClockI2C.setClock(SCD4X_I2C_CLOCK_SPEED);
#endif /* SCD4X_I2C_CLOCK_SPEED */
if (!stopMeasurement()) {
#ifdef SCD4X_I2C_CLOCK_SPEED
LOG_INFO("%s: restoring clock speed", sensorName);
reClockI2C.restoreClock();
#endif /* SCD4X_I2C_CLOCK_SPEED */
return false;
@@ -659,14 +647,12 @@ bool SCD4XSensor::powerDown()
if (scd4x.powerDown() != SCD4X_NO_ERROR) {
LOG_ERROR("%s: sleep() failed", sensorName);
#ifdef SCD4X_I2C_CLOCK_SPEED
LOG_INFO("%s: restoring clock speed", sensorName);
reClockI2C.restoreClock();
#endif /* SCD4X_I2C_CLOCK_SPEED */
return false;
}
#ifdef SCD4X_I2C_CLOCK_SPEED
LOG_INFO("%s: restoring clock speed", sensorName);
reClockI2C.restoreClock();
#endif /* SCD4X_I2C_CLOCK_SPEED */
@@ -687,7 +673,7 @@ bool SCD4XSensor::powerDown()
*/
bool SCD4XSensor::powerUp()
{
LOG_INFO("%s: Waking up", sensorName);
LOG_INFO("%s Waking", sensorName);
if (scd4x.wakeUp() != SCD4X_NO_ERROR) {
LOG_ERROR("%s: wakeUp() failed", sensorName);
@@ -715,21 +701,18 @@ uint32_t SCD4XSensor::wakeUp()
{
#ifdef SCD4X_I2C_CLOCK_SPEED
LOG_INFO("%s: reclock to %uHz", sensorName, SCD4X_I2C_CLOCK_SPEED);
reClockI2C.setClock(SCD4X_I2C_CLOCK_SPEED);
#endif /* SCD4X_I2C_CLOCK_SPEED */
if (startMeasurement()) {
co2MeasureStarted = getTime();
#ifdef SCD4X_I2C_CLOCK_SPEED
LOG_INFO("%s: restoring clock speed", sensorName);
reClockI2C.restoreClock();
#endif /* SCD4X_I2C_CLOCK_SPEED */
return SCD4X_WARMUP_MS;
}
#ifdef SCD4X_I2C_CLOCK_SPEED
LOG_INFO("%s: restoring clock speed", sensorName);
reClockI2C.restoreClock();
#endif /* SCD4X_I2C_CLOCK_SPEED */
@@ -743,14 +726,12 @@ uint32_t SCD4XSensor::wakeUp()
void SCD4XSensor::sleep()
{
#ifdef SCD4X_I2C_CLOCK_SPEED
LOG_INFO("%s: reclock to %uHz", sensorName, SCD4X_I2C_CLOCK_SPEED);
reClockI2C.setClock(SCD4X_I2C_CLOCK_SPEED);
#endif /* SCD4X_I2C_CLOCK_SPEED */
stopMeasurement();
#ifdef SCD4X_I2C_CLOCK_SPEED
LOG_INFO("%s: restoring clock speed", sensorName);
reClockI2C.restoreClock();
#endif /* SCD4X_I2C_CLOCK_SPEED */
}
@@ -792,7 +773,6 @@ AdminMessageHandleResult SCD4XSensor::handleAdminMessage(const meshtastic_MeshPa
AdminMessageHandleResult result;
#ifdef SCD4X_I2C_CLOCK_SPEED
LOG_INFO("%s: reclock to %uHz", sensorName, SCD4X_I2C_CLOCK_SPEED);
reClockI2C.setClock(SCD4X_I2C_CLOCK_SPEED);
#endif /* SCD4X_I2C_CLOCK_SPEED */
@@ -897,7 +877,6 @@ AdminMessageHandleResult SCD4XSensor::handleAdminMessage(const meshtastic_MeshPa
this->startMeasurement();
#ifdef SCD4X_I2C_CLOCK_SPEED
LOG_INFO("%s: restoring clock speed", sensorName);
reClockI2C.restoreClock();
#endif /* SCD4X_I2C_CLOCK_SPEED */
+10 -16
View File
@@ -132,7 +132,6 @@ bool SEN5XSensor::sendCommand(uint16_t command, uint8_t *buffer, uint8_t byteNum
}
#ifdef SEN5X_I2C_CLOCK_SPEED
LOG_DEBUG("%s: Reclock to %uHz", sensorName, SEN5X_I2C_CLOCK_SPEED);
reClockI2C.setClock(SEN5X_I2C_CLOCK_SPEED);
#endif /* SEN5X_I2C_CLOCK_SPEED */
@@ -145,7 +144,6 @@ bool SEN5XSensor::sendCommand(uint16_t command, uint8_t *buffer, uint8_t byteNum
uint8_t i2c_error = _bus->endTransmission();
#ifdef SEN5X_I2C_CLOCK_SPEED
LOG_DEBUG("%s: restoring clock speed", sensorName);
reClockI2C.restoreClock();
#endif /* SEN5X_I2C_CLOCK_SPEED */
@@ -164,7 +162,6 @@ bool SEN5XSensor::sendCommand(uint16_t command, uint8_t *buffer, uint8_t byteNum
uint8_t SEN5XSensor::readBuffer(uint8_t *buffer, uint8_t byteNumber)
{
#ifdef SEN5X_I2C_CLOCK_SPEED
LOG_DEBUG("%s: Reclock to %uHz", sensorName, SEN5X_I2C_CLOCK_SPEED);
reClockI2C.setClock(SEN5X_I2C_CLOCK_SPEED);
#endif /* SEN5X_I2C_CLOCK_SPEED */
@@ -172,7 +169,6 @@ uint8_t SEN5XSensor::readBuffer(uint8_t *buffer, uint8_t byteNumber)
if (readBytes != byteNumber) {
LOG_ERROR("%s: Error reading I2C bus", sensorName);
#ifdef SEN5X_I2C_CLOCK_SPEED
LOG_DEBUG("%s: restoring clock speed", sensorName);
reClockI2C.restoreClock();
#endif /* SEN5X_I2C_CLOCK_SPEED */
return 0;
@@ -188,7 +184,6 @@ uint8_t SEN5XSensor::readBuffer(uint8_t *buffer, uint8_t byteNumber)
if (recvCRC != calcCRC) {
LOG_ERROR("%s: Checksum error receiving msg", sensorName);
#ifdef SEN5X_I2C_CLOCK_SPEED
LOG_DEBUG("%s: restoring clock speed", sensorName);
reClockI2C.restoreClock();
#endif /* SEN5X_I2C_CLOCK_SPEED */
return 0;
@@ -198,7 +193,6 @@ uint8_t SEN5XSensor::readBuffer(uint8_t *buffer, uint8_t byteNumber)
}
#ifdef SEN5X_I2C_CLOCK_SPEED
LOG_DEBUG("%s: restoring clock speed", sensorName);
reClockI2C.restoreClock();
#endif /* SEN5X_I2C_CLOCK_SPEED */
@@ -489,7 +483,7 @@ bool SEN5XSensor::isActive()
uint32_t SEN5XSensor::wakeUp()
{
LOG_DEBUG("%s: Waking up sensor", sensorName);
LOG_TRACE("%s Waking", sensorName);
if (!sendCommand(SEN5X_START_MEASUREMENT)) {
LOG_ERROR("%s: Error starting measurement", sensorName);
@@ -513,7 +507,7 @@ bool SEN5XSensor::vocStateStable()
uint32_t now;
now = getTime();
uint32_t sinceFirstMeasureStarted = (now - rhtGasMeasureStarted);
LOG_DEBUG("%s: sinceFirstMeasureStarted: %us", sensorName, sinceFirstMeasureStarted);
LOG_TRACE("%s: sinceFirstMeasureStarted: %us", sensorName, sinceFirstMeasureStarted);
return sinceFirstMeasureStarted > SEN5X_VOC_STATE_WARMUP_S;
}
@@ -661,7 +655,7 @@ bool SEN5XSensor::readValues()
LOG_ERROR("%s: Error sending read command", sensorName);
return false;
}
LOG_DEBUG("%s: Reading PM Values", sensorName);
LOG_TRACE("%s: Reading PM Values", sensorName);
delay(20); // From Sensirion Datasheet
uint8_t dataBuffer[16]{};
@@ -692,16 +686,16 @@ bool SEN5XSensor::readValues()
sen5xmeasurement.vocIndex = !isnan(int_vocIndex) ? int_vocIndex / 10.0f : FLT_MAX;
sen5xmeasurement.noxIndex = !isnan(int_noxIndex) ? int_noxIndex / 10.0f : FLT_MAX;
LOG_DEBUG("%s: Got readings: pM1p0=%u, pM2p5=%u, pM4p0=%u, pM10p0=%u", sensorName, sen5xmeasurement.pM1p0,
LOG_TRACE("%s: Got readings: pM1p0=%u, pM2p5=%u, pM4p0=%u, pM10p0=%u", sensorName, sen5xmeasurement.pM1p0,
sen5xmeasurement.pM2p5, sen5xmeasurement.pM4p0, sen5xmeasurement.pM10p0);
if (model != SEN50) {
LOG_DEBUG("%s: Got readings: humidity=%.2f, temperature=%.2f, vocIndex=%.2f", sensorName, sen5xmeasurement.humidity,
LOG_TRACE("%s: Got readings: humidity=%.2f, temperature=%.2f, vocIndex=%.2f", sensorName, sen5xmeasurement.humidity,
sen5xmeasurement.temperature, sen5xmeasurement.vocIndex);
}
if (model == SEN55) {
LOG_DEBUG("%s: Got readings: noxIndex=%.2f", sensorName, sen5xmeasurement.noxIndex);
LOG_TRACE("%s: Got readings: noxIndex=%.2f", sensorName, sen5xmeasurement.noxIndex);
}
return true;
@@ -714,7 +708,7 @@ bool SEN5XSensor::readPNValues(bool cumulative)
return false;
}
LOG_DEBUG("%s: Reading PN Values", sensorName);
LOG_TRACE("%s: Reading PN Values", sensorName);
delay(20); // From Sensirion Datasheet
uint8_t dataBuffer[20]{};
@@ -754,7 +748,7 @@ bool SEN5XSensor::readPNValues(bool cumulative)
sen5xmeasurement.pN1p0 -= sen5xmeasurement.pN0p5;
}
LOG_DEBUG("%s: Got readings: pN0p5=%u, pN1p0=%u, pN2p5=%u, pN4p0=%u, pN10p0=%u, tSize=%.2f", sensorName,
LOG_TRACE("%s: Got readings: pN0p5=%u, pN1p0=%u, pN2p5=%u, pN4p0=%u, pN10p0=%u, tSize=%.2f", sensorName,
sen5xmeasurement.pN0p5, sen5xmeasurement.pN1p0, sen5xmeasurement.pN2p5, sen5xmeasurement.pN4p0,
sen5xmeasurement.pN10p0, sen5xmeasurement.tSize);
@@ -813,7 +807,7 @@ int32_t SEN5XSensor::pendingForReadyMs()
uint32_t now;
now = getTime();
uint32_t sincePmMeasureStarted = (now - pmMeasureStarted) * 1000;
LOG_DEBUG("%s: Since measure started: %ums", sensorName, sincePmMeasureStarted);
LOG_TRACE("%s: Since measure started: %ums", sensorName, sincePmMeasureStarted);
switch (state) {
case SEN5X_MEASUREMENT: {
@@ -857,7 +851,7 @@ bool SEN5XSensor::getMetrics(meshtastic_Telemetry *measurement)
{
LOG_INFO("%s: Get metrics", sensorName);
if (!isActive()) {
LOG_INFO("%s: not in measurement mode", sensorName);
LOG_INFO("%s: Not in measurement mode", sensorName);
return false;
}
+3 -16
View File
@@ -17,8 +17,6 @@ bool SFA30Sensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
#ifdef SFA30_I2C_CLOCK_SPEED
_port = dev->address.port;
reClockI2C.setup(_bus, _port);
LOG_INFO("%s attempting to reclock speed to %uHz", sensorName, SFA30_I2C_CLOCK_SPEED);
reClockI2C.setClock(SFA30_I2C_CLOCK_SPEED);
#endif /* SFA30_I2C_CLOCK_SPEED */
@@ -27,7 +25,6 @@ bool SFA30Sensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
if (this->isError(sfa30.deviceReset())) {
#ifdef SFA30_I2C_CLOCK_SPEED
LOG_INFO("%s restoring clock speed", sensorName);
reClockI2C.restoreClock();
#endif /* SFA30_I2C_CLOCK_SPEED */
return false;
@@ -36,7 +33,6 @@ bool SFA30Sensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
state = State::IDLE;
if (this->isError(sfa30.startContinuousMeasurement())) {
#ifdef SFA30_I2C_CLOCK_SPEED
LOG_INFO("%s restoring clock speed", sensorName);
reClockI2C.restoreClock();
#endif /* SFA30_I2C_CLOCK_SPEED */
return false;
@@ -45,14 +41,13 @@ bool SFA30Sensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
LOG_INFO("%s starting measurement", sensorName);
#ifdef SFA30_I2C_CLOCK_SPEED
LOG_INFO("%s restoring clock speed", sensorName);
reClockI2C.restoreClock();
#endif /* SFA30_I2C_CLOCK_SPEED */
status = 1;
state = State::ACTIVE;
measureStarted = getTime();
LOG_INFO("%s Enabled", sensorName);
LOG_INFO("%s: Enabled", sensorName);
initI2CSensor();
return true;
@@ -71,17 +66,15 @@ bool SFA30Sensor::isError(uint16_t response)
void SFA30Sensor::sleep()
{
#ifdef SFA30_I2C_CLOCK_SPEED
LOG_DEBUG("%s attempting to reclock speed to %uHz", sensorName, SFA30_I2C_CLOCK_SPEED);
reClockI2C.setClock(SFA30_I2C_CLOCK_SPEED);
#endif /* SFA30_I2C_CLOCK_SPEED */
// Note - not recommended for this sensor on a periodic basis
if (this->isError(sfa30.stopMeasurement())) {
LOG_ERROR("%s: can't stop measurement", sensorName);
LOG_ERROR("%s: Can't stop measurement", sensorName);
};
#ifdef SFA30_I2C_CLOCK_SPEED
LOG_DEBUG("%s restoring clock speed", sensorName);
reClockI2C.restoreClock();
#endif /* SFA30_I2C_CLOCK_SPEED */
@@ -93,21 +86,18 @@ void SFA30Sensor::sleep()
uint32_t SFA30Sensor::wakeUp()
{
#ifdef SFA30_I2C_CLOCK_SPEED
LOG_DEBUG("%s attempting to reclock speed to %uHz", sensorName, SFA30_I2C_CLOCK_SPEED);
reClockI2C.setClock(SFA30_I2C_CLOCK_SPEED);
#endif /* SFA30_I2C_CLOCK_SPEED */
LOG_DEBUG("Waking up %s", sensorName);
LOG_DEBUG("Waking %s", sensorName);
if (this->isError(sfa30.startContinuousMeasurement())) {
#ifdef SFA30_I2C_CLOCK_SPEED
LOG_DEBUG("%s restoring clock speed", sensorName);
reClockI2C.restoreClock();
#endif /* SFA30_I2C_CLOCK_SPEED */
return 0;
}
#ifdef SFA30_I2C_CLOCK_SPEED
LOG_DEBUG("%s restoring clock speed", sensorName);
reClockI2C.restoreClock();
#endif /* SFA30_I2C_CLOCK_SPEED */
@@ -154,21 +144,18 @@ bool SFA30Sensor::getMetrics(meshtastic_Telemetry *measurement)
float temperature = 0.0;
#ifdef SFA30_I2C_CLOCK_SPEED
LOG_DEBUG("%s attempting to reclock speed to %uHz", sensorName, SFA30_I2C_CLOCK_SPEED);
reClockI2C.setClock(SFA30_I2C_CLOCK_SPEED);
#endif /* SFA30_I2C_CLOCK_SPEED */
if (this->isError(sfa30.readMeasuredValues(hcho, humidity, temperature))) {
LOG_WARN("%s: No values", sensorName);
#ifdef SFA30_I2C_CLOCK_SPEED
LOG_DEBUG("%s restoring clock speed", sensorName);
reClockI2C.restoreClock();
#endif /* SFA30_I2C_CLOCK_SPEED */
return false;
}
#ifdef SFA30_I2C_CLOCK_SPEED
LOG_DEBUG("%s restoring clock speed", sensorName);
reClockI2C.restoreClock();
#endif /* SFA30_I2C_CLOCK_SPEED */
+2 -2
View File
@@ -50,12 +50,12 @@ bool SHTXXSensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
_address = dev->address.address;
if (sht.init(*_bus)) {
LOG_INFO("%s: init(): success", sensorName);
LOG_INFO("%s init success", sensorName);
getSensorVariant(sht.mSensorType);
LOG_INFO("%s Sensor detected: %s on 0x%x", sensorName, sensorVariant, _address);
status = 1;
} else {
LOG_ERROR("%s: init(): failed", sensorName);
LOG_ERROR("%s init failed", sensorName);
}
initI2CSensor();
+4 -3
View File
@@ -19,6 +19,7 @@
#include <algorithm>
#include <cstring>
#define TM_LOG_TRACE(fmt, ...) LOG_TRACE("[TM] " fmt, ##__VA_ARGS__)
#define TM_LOG_DEBUG(fmt, ...) LOG_DEBUG("[TM] " fmt, ##__VA_ARGS__)
#define TM_LOG_INFO(fmt, ...) LOG_INFO("[TM] " fmt, ##__VA_ARGS__)
#define TM_LOG_WARN(fmt, ...) LOG_WARN("[TM] " fmt, ##__VA_ARGS__)
@@ -634,7 +635,7 @@ void TrafficManagementModule::maintainNodeInfoCacheLocked()
// O(entries x members) every 60 s under cacheLock. The hourly reconcile pass
// owns it (see reconcileNodeInfoFromNodeDBLocked).
}
TM_LOG_DEBUG("NodeInfo cache: %u/%u (%u went stale)", static_cast<unsigned>(countNodeInfoEntriesLocked()),
TM_LOG_TRACE("NodeInfo cache: %u/%u (%u went stale)", static_cast<unsigned>(countNodeInfoEntriesLocked()),
static_cast<unsigned>(nodeInfoTargetEntries()), static_cast<unsigned>(nodeInfoSaturated));
// Anti-entropy: seed identities NodeDB knows but this cache lacks - a full pass at
@@ -1323,7 +1324,7 @@ int32_t TrafficManagementModule::runOnce()
}
}
TM_LOG_DEBUG("Maintenance: %u active, %u expired, %u/%u slots, %lums elapsed", activeEntries, expiredEntries,
TM_LOG_TRACE("Maintenance: %u active, %u expired, %u/%u slots, %lums elapsed", activeEntries, expiredEntries,
static_cast<unsigned>(activeEntries), static_cast<unsigned>(cacheSize()),
static_cast<unsigned long>(TrafficManagementModule::clockMs() - sweepStartMs));
@@ -1400,7 +1401,7 @@ bool TrafficManagementModule::shouldDropPosition(const meshtastic_MeshPacket *p,
const bool withinInterval =
hasPositionState && (windowTicks != 0) && (static_cast<uint8_t>(nowPosTick - entry->pos_time) < windowTicks);
TM_LOG_DEBUG("Position dedup 0x%08x: fp=0x%02x prev=0x%02x same=%d within=%d new=%d", p->from, fingerprint,
TM_LOG_TRACE("Position dedup 0x%08x: fp=0x%02x prev=0x%02x same=%d within=%d new=%d", p->from, fingerprint,
entry->pos_fingerprint, samePosition, withinInterval, isNew);
// Update cache entry (raw tick; 0 is a valid tick value)