Revert "DetectionSensor: broadcast all state changes" (#4776)

This commit is contained in:
Ben Meadors 2024-09-19 10:46:18 -05:00 committed by GitHub
parent 6473cf0b69
commit 91b4199f9d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 11 deletions

View File

@ -49,16 +49,10 @@ int32_t DetectionSensorModule::runOnce()
// LOG_DEBUG("Detection Sensor Module: Current pin state: %i\n", digitalRead(moduleConfig.detection_sensor.monitor_pin)); // LOG_DEBUG("Detection Sensor Module: Current pin state: %i\n", digitalRead(moduleConfig.detection_sensor.monitor_pin));
if ((millis() - lastSentToMesh) >= Default::getConfiguredOrDefaultMs(moduleConfig.detection_sensor.minimum_broadcast_secs)) { if ((millis() - lastSentToMesh) >= Default::getConfiguredOrDefaultMs(moduleConfig.detection_sensor.minimum_broadcast_secs) &&
if (hasDetectionEvent()) { hasDetectionEvent()) {
wasDetected = true; sendDetectionMessage();
sendDetectionMessage(); return DELAYED_INTERVAL;
return DELAYED_INTERVAL;
} else if (wasDetected) {
wasDetected = false;
sendCurrentStateMessage();
return DELAYED_INTERVAL;
}
} }
// Even if we haven't detected an event, broadcast our current state to the mesh on the scheduled interval as a sort // Even if we haven't detected an event, broadcast our current state to the mesh on the scheduled interval as a sort
// of heartbeat. We only do this if the minimum broadcast interval is greater than zero, otherwise we'll only broadcast state // of heartbeat. We only do this if the minimum broadcast interval is greater than zero, otherwise we'll only broadcast state

View File

@ -15,7 +15,6 @@ class DetectionSensorModule : public SinglePortModule, private concurrency::OSTh
private: private:
bool firstTime = true; bool firstTime = true;
uint32_t lastSentToMesh = 0; uint32_t lastSentToMesh = 0;
bool wasDetected = false;
void sendDetectionMessage(); void sendDetectionMessage();
void sendCurrentStateMessage(); void sendCurrentStateMessage();
bool hasDetectionEvent(); bool hasDetectionEvent();