reset next action state after command run

This commit is contained in:
technyon
2022-03-26 11:47:31 +01:00
parent a9a2bc6f7b
commit c3fddffa9a
2 changed files with 8 additions and 6 deletions

View File

@@ -42,19 +42,21 @@ void Nuki::update()
unsigned long ts = millis(); unsigned long ts = millis();
if(_lastLockStateUpdateTs == 0 || _lastLockStateUpdateTs + 60000 < ts) if(_nextLockStateUpdateTs == 0 || ts >= _nextLockStateUpdateTs)
{ {
_lastLockStateUpdateTs = ts; _nextLockStateUpdateTs = ts + 60000;
updateKeyTurnerState(); updateKeyTurnerState();
} }
if(_lastBatteryReportTs == 0 || _lastBatteryReportTs + 600000 < ts) if(_nextBatteryReportTs == 0 || ts > _nextBatteryReportTs)
{ {
_lastBatteryReportTs = ts; _nextBatteryReportTs = ts + 60000 * 30;
updateBatteryState(); updateBatteryState();
} }
if(_nextLockAction != (LockAction)0xff) if(_nextLockAction != (LockAction)0xff)
{ {
_nukiBle.lockAction(_nextLockAction, 0, 0); _nukiBle.lockAction(_nextLockAction, 0, 0);
_nextLockAction = (LockAction)0xff;
_nextLockStateUpdateTs = ts + 11000;
} }
} }

4
Nuki.h
View File

@@ -31,7 +31,7 @@ private:
BatteryReport _lastBatteryReport; BatteryReport _lastBatteryReport;
bool _paired = false; bool _paired = false;
unsigned long _lastLockStateUpdateTs = 0; unsigned long _nextLockStateUpdateTs = 0;
unsigned long _lastBatteryReportTs = 0; unsigned long _nextBatteryReportTs = 0;
LockAction _nextLockAction = (LockAction)0xff; LockAction _nextLockAction = (LockAction)0xff;
}; };