add retry delay

This commit is contained in:
technyon
2023-01-14 18:17:21 +01:00
parent 81f65c3ff4
commit 3cd57fb032
3 changed files with 6 additions and 3 deletions

View File

@@ -171,7 +171,7 @@ void NukiWrapper::update()
updateKeypad(); updateKeypad();
} }
if(_nextLockAction != (NukiLock::LockAction)0xff) if(_nextLockAction != (NukiLock::LockAction)0xff && ts > _nextRetryTs)
{ {
Nuki::CmdResult cmdResult = _nukiLock.lockAction(_nextLockAction, 0, 0); Nuki::CmdResult cmdResult = _nukiLock.lockAction(_nextLockAction, 0, 0);
@@ -187,6 +187,7 @@ void NukiWrapper::update()
{ {
_retryCount = 0; _retryCount = 0;
_nextLockAction = (NukiLock::LockAction) 0xff; _nextLockAction = (NukiLock::LockAction) 0xff;
_network->publishRetry("--");
if (_intervalLockstate > 10) if (_intervalLockstate > 10)
{ {
_nextLockStateUpdateTs = ts + 10 * 1000; _nextLockStateUpdateTs = ts + 10 * 1000;
@@ -205,7 +206,7 @@ void NukiWrapper::update()
_network->publishRetry(std::to_string(_retryCount + 1)); _network->publishRetry(std::to_string(_retryCount + 1));
_nextLockStateUpdateTs = millis() + _retryDelay; _nextRetryTs = millis() + _retryDelay;
++_retryCount; ++_retryCount;
} }
@@ -214,6 +215,7 @@ void NukiWrapper::update()
Log->println(F("Maximum number of retries exceeded, aborting.")); Log->println(F("Maximum number of retries exceeded, aborting."));
_network->publishRetry("failed"); _network->publishRetry("failed");
_retryCount = 0; _retryCount = 0;
_nextRetryTs = 0;
_nextLockAction = (NukiLock::LockAction) 0xff; _nextLockAction = (NukiLock::LockAction) 0xff;
} }
} }

View File

@@ -87,6 +87,7 @@ private:
int _nrOfRetries = 0; int _nrOfRetries = 0;
int _retryDelay = 0; int _retryDelay = 0;
int _retryCount = 0; int _retryCount = 0;
unsigned long _nextRetryTs = 0;
unsigned long _nextLockStateUpdateTs = 0; unsigned long _nextLockStateUpdateTs = 0;
unsigned long _nextBatteryReportTs = 0; unsigned long _nextBatteryReportTs = 0;
unsigned long _nextConfigUpdateTs = 0; unsigned long _nextConfigUpdateTs = 0;

View File

@@ -1,3 +1,3 @@
#pragma once #pragma once
#define nuki_hub_version "6.10-retry-2" #define nuki_hub_version "6.10-retry-3"