only reboot after missing beacons if device has been detected at least once

This commit is contained in:
technyon
2023-01-11 23:03:25 +01:00
parent 9fcd0b82f3
commit d047d99bf9
2 changed files with 16 additions and 12 deletions

View File

@@ -81,7 +81,8 @@ void NukiOpenerWrapper::update()
Nuki::AuthorizationIdType::App :
Nuki::AuthorizationIdType::Bridge;
if (_nukiOpener.pairNuki(idType) == NukiOpener::PairingResult::Success) {
if (_nukiOpener.pairNuki(idType) == NukiOpener::PairingResult::Success)
{
Log->println(F("Nuki opener paired"));
_paired = true;
_network->publishBleAddress(_nukiOpener.getBleAddress().toString());
@@ -93,7 +94,12 @@ void NukiOpenerWrapper::update()
}
}
if(_restartBeaconTimeout > 0 && (millis() - _nukiOpener.getLastReceivedBeaconTs() > _restartBeaconTimeout * 1000))
unsigned long ts = millis();
unsigned long lastReceivedBeaconTs = _nukiOpener.getLastReceivedBeaconTs();
if(_restartBeaconTimeout > 0 &&
ts > 60000 &&
lastReceivedBeaconTs > 0 &&
(ts - lastReceivedBeaconTs > _restartBeaconTimeout * 1000))
{
Log->print("No BLE beacon received from the opener for ");
Log->print((millis() - _nukiOpener.getLastReceivedBeaconTs()) / 1000);
@@ -104,8 +110,6 @@ void NukiOpenerWrapper::update()
_nukiOpener.updateConnectionState();
unsigned long ts = millis();
if(_statusUpdated || _nextLockStateUpdateTs == 0 || ts >= _nextLockStateUpdateTs)
{
_nextLockStateUpdateTs = ts + _intervalLockstate * 1000;