snapshot
This commit is contained in:
@@ -117,11 +117,11 @@ void DoorbellLogic::update() {
|
||||
|
||||
switch (_state) {
|
||||
case DeviceState::ALERTING:
|
||||
if (now - _alertStart > ALERT_TIMEOUT_MS) {
|
||||
Serial.println("[ALERT] Timeout — auto-silencing");
|
||||
handleSilence("timeout");
|
||||
break;
|
||||
}
|
||||
// if (now - _alertStart > ALERT_TIMEOUT_MS) {
|
||||
// Serial.println("[ALERT] Timeout — auto-silencing");
|
||||
// handleSilence("timeout");
|
||||
// break;
|
||||
// }
|
||||
if (now - _lastBlink >= BLINK_INTERVAL_MS) {
|
||||
_lastBlink = now;
|
||||
_blinkState = !_blinkState;
|
||||
@@ -251,7 +251,21 @@ void DoorbellLogic::transitionTo(DeviceState newState) {
|
||||
void DoorbellLogic::handleAlert(const String& msg) {
|
||||
if (_state == DeviceState::ALERTING && _currentMessage == msg) return;
|
||||
_currentMessage = msg;
|
||||
_alertMsgEpoch = _lastParsedMsgEpoch; // store ntfy server time of this alert
|
||||
_alertMsgEpoch = _lastParsedMsgEpoch;
|
||||
|
||||
// Push into history (shift older entries down)
|
||||
for (int i = ALERT_HISTORY_SIZE - 1; i > 0; i--) {
|
||||
_screen.alertHistory[i] = _screen.alertHistory[i - 1];
|
||||
}
|
||||
strncpy(_screen.alertHistory[0].message, msg.c_str(), 63);
|
||||
_screen.alertHistory[0].message[63] = '\0';
|
||||
strncpy(_screen.alertHistory[0].timestamp,
|
||||
_ntpSynced ? _timeClient->getFormattedTime().c_str() : "??:??:??", 11);
|
||||
_screen.alertHistory[0].timestamp[11] = '\0';
|
||||
|
||||
if (_screen.alertHistoryCount < ALERT_HISTORY_SIZE)
|
||||
_screen.alertHistoryCount++;
|
||||
|
||||
Serial.printf("[ALERT] Accepted. ntfy time=%ld\n", (long)_alertMsgEpoch);
|
||||
transitionTo(DeviceState::ALERTING);
|
||||
queueStatus("ALERTING", msg);
|
||||
|
||||
Reference in New Issue
Block a user