Compare commits

...

2 Commits

Author SHA1 Message Date
Colin B.
cb40c2878d Merge branch 'upstream-pmsa003i' of github.com:vogon/meshtastic-firmware into upstream-pmsa003i 2025-04-28 20:39:09 -07:00
Colin B.
de9fe88da0 fix indentation 2025-04-28 20:39:05 -07:00
2 changed files with 30 additions and 30 deletions

View File

@ -79,41 +79,41 @@ int32_t AirQualityTelemetryModule::runOnce()
switch (state) { switch (state) {
#ifdef PMSA003I_ENABLE_PIN #ifdef PMSA003I_ENABLE_PIN
case State::IDLE: case State::IDLE:
// sensor is in standby; fire it up and sleep // sensor is in standby; fire it up and sleep
LOG_DEBUG("runOnce(): state = idle"); LOG_DEBUG("runOnce(): state = idle");
digitalWrite(PMSA003I_ENABLE_PIN, HIGH); digitalWrite(PMSA003I_ENABLE_PIN, HIGH);
state = State::ACTIVE; state = State::ACTIVE;
return PMSA003I_WARMUP_MS; return PMSA003I_WARMUP_MS;
#endif /* PMSA003I_ENABLE_PIN */ #endif /* PMSA003I_ENABLE_PIN */
case State::ACTIVE: case State::ACTIVE:
// sensor is already warmed up; grab telemetry and send it // sensor is already warmed up; grab telemetry and send it
LOG_DEBUG("runOnce(): state = active"); LOG_DEBUG("runOnce(): state = active");
if (((lastSentToMesh == 0) || if (((lastSentToMesh == 0) ||
!Throttle::isWithinTimespanMs(lastSentToMesh, Default::getConfiguredOrDefaultMsScaled( !Throttle::isWithinTimespanMs(lastSentToMesh, Default::getConfiguredOrDefaultMsScaled(
moduleConfig.telemetry.air_quality_interval, moduleConfig.telemetry.air_quality_interval,
default_telemetry_broadcast_interval_secs, numOnlineNodes))) && default_telemetry_broadcast_interval_secs, numOnlineNodes))) &&
airTime->isTxAllowedChannelUtil(config.device.role != meshtastic_Config_DeviceConfig_Role_SENSOR) && airTime->isTxAllowedChannelUtil(config.device.role != meshtastic_Config_DeviceConfig_Role_SENSOR) &&
airTime->isTxAllowedAirUtil()) { airTime->isTxAllowedAirUtil()) {
sendTelemetry(); sendTelemetry();
lastSentToMesh = millis(); lastSentToMesh = millis();
} else if (service->isToPhoneQueueEmpty()) { } else if (service->isToPhoneQueueEmpty()) {
// Just send to phone when it's not our time to send to mesh yet // Just send to phone when it's not our time to send to mesh yet
// Only send while queue is empty (phone assumed connected) // Only send while queue is empty (phone assumed connected)
sendTelemetry(NODENUM_BROADCAST, true); sendTelemetry(NODENUM_BROADCAST, true);
} }
#ifdef PMSA003I_ENABLE_PIN #ifdef PMSA003I_ENABLE_PIN
// put sensor back to sleep // put sensor back to sleep
digitalWrite(PMSA003I_ENABLE_PIN, LOW); digitalWrite(PMSA003I_ENABLE_PIN, LOW);
state = State::IDLE; state = State::IDLE;
#endif /* PMSA003I_ENABLE_PIN */ #endif /* PMSA003I_ENABLE_PIN */
return sendToPhoneIntervalMs; return sendToPhoneIntervalMs;
default: default:
return disable(); return disable();
} }
} }
} }

View File

@ -51,8 +51,8 @@ class AirQualityTelemetryModule : private concurrency::OSThread, public Protobuf
private: private:
enum State { enum State {
IDLE = 0, IDLE = 0,
ACTIVE = 1, ACTIVE = 1,
}; };
State state; State state;