From 91b4199f9d63526f254f1ced374c20194a98b749 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 19 Sep 2024 10:46:18 -0500 Subject: [PATCH] Revert "DetectionSensor: broadcast all state changes" (#4776) --- src/modules/DetectionSensorModule.cpp | 14 ++++---------- src/modules/DetectionSensorModule.h | 1 - 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/modules/DetectionSensorModule.cpp b/src/modules/DetectionSensorModule.cpp index d637fa7c6..20d91a381 100644 --- a/src/modules/DetectionSensorModule.cpp +++ b/src/modules/DetectionSensorModule.cpp @@ -49,16 +49,10 @@ int32_t DetectionSensorModule::runOnce() // 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 (hasDetectionEvent()) { - wasDetected = true; - sendDetectionMessage(); - return DELAYED_INTERVAL; - } else if (wasDetected) { - wasDetected = false; - sendCurrentStateMessage(); - return DELAYED_INTERVAL; - } + if ((millis() - lastSentToMesh) >= Default::getConfiguredOrDefaultMs(moduleConfig.detection_sensor.minimum_broadcast_secs) && + hasDetectionEvent()) { + sendDetectionMessage(); + 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 // of heartbeat. We only do this if the minimum broadcast interval is greater than zero, otherwise we'll only broadcast state diff --git a/src/modules/DetectionSensorModule.h b/src/modules/DetectionSensorModule.h index eb17bf3a2..ed6cddda5 100644 --- a/src/modules/DetectionSensorModule.h +++ b/src/modules/DetectionSensorModule.h @@ -15,7 +15,6 @@ class DetectionSensorModule : public SinglePortModule, private concurrency::OSTh private: bool firstTime = true; uint32_t lastSentToMesh = 0; - bool wasDetected = false; void sendDetectionMessage(); void sendCurrentStateMessage(); bool hasDetectionEvent();