add enum for PIN state

This commit is contained in:
technyon
2025-02-03 15:43:58 +01:00
parent 6e45dabd94
commit 31fed84cae
7 changed files with 48 additions and 32 deletions

View File

@@ -5,6 +5,7 @@
#include "RestartReason.h"
#include <NukiLockUtils.h>
#include "Config.h"
#include "enums/NukiPinState.h"
#include "hal/wdt_hal.h"
#include <time.h>
#include "esp_sntp.h"
@@ -464,7 +465,7 @@ bool NukiWrapper::isPinSet()
bool NukiWrapper::isPinValid()
{
return _preferences->getInt(preference_lock_pin_status, 4) == 1;
return _preferences->getInt(preference_lock_pin_status, (int)NukiPinState::NotConfigured) == 1;
}
void NukiWrapper::setPin(const uint16_t pin)
@@ -658,7 +659,7 @@ void NukiWrapper::updateConfig()
updateAuth(false);
}
const int pinStatus = _preferences->getInt(preference_lock_pin_status, 4);
const int pinStatus = _preferences->getInt(preference_lock_pin_status, (int)NukiPinState::NotConfigured);
if(isPinSet())
{
@@ -684,7 +685,7 @@ void NukiWrapper::updateConfig()
Log->println(("Nuki Lock PIN is invalid"));
if(pinStatus != 2)
{
_preferences->putInt(preference_lock_pin_status, 2);
_preferences->putInt(preference_lock_pin_status, (int)NukiPinState::Invalid);
}
}
else
@@ -692,7 +693,7 @@ void NukiWrapper::updateConfig()
Log->println(("Nuki Lock PIN is valid"));
if(pinStatus != 1)
{
_preferences->putInt(preference_lock_pin_status, 1);
_preferences->putInt(preference_lock_pin_status, (int)NukiPinState::Valid);
}
}
}
@@ -701,7 +702,7 @@ void NukiWrapper::updateConfig()
Log->println(("Nuki Lock PIN is not set"));
if(pinStatus != 0)
{
_preferences->putInt(preference_lock_pin_status, 0);
_preferences->putInt(preference_lock_pin_status, (int)NukiPinState::NotSet);
}
}
}
@@ -4194,7 +4195,7 @@ void NukiWrapper::notify(Nuki::EventType eventType)
}
else if(eventType == Nuki::EventType::ERROR_BAD_PIN)
{
_preferences->putInt(preference_lock_pin_status, 2);
_preferences->putInt(preference_lock_pin_status, (int)NukiPinState::Invalid);
}
else if(eventType == Nuki::EventType::BLE_ERROR_ON_DISCONNECT)
{