Skip to content

Commit

Permalink
Revert "DetectionSensor: broadcast all state changes" (#4776)
Browse files Browse the repository at this point in the history
  • Loading branch information
thebentern authored Sep 19, 2024
1 parent 6473cf0 commit 91b4199
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
14 changes: 4 additions & 10 deletions src/modules/DetectionSensorModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/modules/DetectionSensorModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 91b4199

Please sign in to comment.