mirror of
https://github.com/meshtastic/firmware.git
synced 2025-10-07 15:12:45 +00:00
Compare commits
No commits in common. "cb40c2878da564699e323959820dad52655068b6" and "1720403e4c939ab95289c23986c1c1691f4ff7d6" have entirely different histories.
cb40c2878d
...
1720403e4c
@ -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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user