initialize retry parameters on first start
This commit is contained in:
@@ -34,7 +34,7 @@ NukiWrapper::~NukiWrapper()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void NukiWrapper::initialize()
|
void NukiWrapper::initialize(const bool& firstStart)
|
||||||
{
|
{
|
||||||
|
|
||||||
_nukiLock.initialize();
|
_nukiLock.initialize();
|
||||||
@@ -51,6 +51,11 @@ void NukiWrapper::initialize()
|
|||||||
_nrOfRetries = _preferences->getInt(preference_command_nr_of_retries);
|
_nrOfRetries = _preferences->getInt(preference_command_nr_of_retries);
|
||||||
_retryDelay = _preferences->getInt(preference_command_retry_delay);
|
_retryDelay = _preferences->getInt(preference_command_retry_delay);
|
||||||
|
|
||||||
|
if(firstStart)
|
||||||
|
{
|
||||||
|
_preferences->putInt(preference_command_nr_of_retries, 3);
|
||||||
|
_preferences->putInt(preference_command_retry_delay, 1000);
|
||||||
|
}
|
||||||
if(_retryDelay <= 100)
|
if(_retryDelay <= 100)
|
||||||
{
|
{
|
||||||
_retryDelay = 100;
|
_retryDelay = 100;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ public:
|
|||||||
NukiWrapper(const std::string& deviceName, uint32_t id, BleScanner::Scanner* scanner, NetworkLock* network, Preferences* preferences);
|
NukiWrapper(const std::string& deviceName, uint32_t id, BleScanner::Scanner* scanner, NetworkLock* network, Preferences* preferences);
|
||||||
virtual ~NukiWrapper();
|
virtual ~NukiWrapper();
|
||||||
|
|
||||||
void initialize();
|
void initialize(const bool& firstStart);
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
void lock();
|
void lock();
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define preference_started_befores "run"
|
#define preference_started_before "run"
|
||||||
#define preference_deviceId "deviceId"
|
#define preference_deviceId "deviceId"
|
||||||
#define preference_mqtt_broker "mqttbroker"
|
#define preference_mqtt_broker "mqttbroker"
|
||||||
#define preference_mqtt_broker_port "mqttport"
|
#define preference_mqtt_broker_port "mqttport"
|
||||||
|
|||||||
14
main.cpp
14
main.cpp
@@ -140,14 +140,16 @@ void initEthServer(const NetworkDeviceType device)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void initPreferences()
|
bool initPreferences()
|
||||||
{
|
{
|
||||||
preferences = new Preferences();
|
preferences = new Preferences();
|
||||||
preferences->begin("nukihub", false);
|
preferences->begin("nukihub", false);
|
||||||
|
|
||||||
if(!preferences->getBool(preference_started_befores))
|
bool firstStart = !preferences->getBool(preference_started_before);
|
||||||
|
|
||||||
|
if(firstStart)
|
||||||
{
|
{
|
||||||
preferences->putBool(preference_started_befores, true);
|
preferences->putBool(preference_started_before, true);
|
||||||
preferences->putBool(preference_lock_enabled, true);
|
preferences->putBool(preference_lock_enabled, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,6 +157,8 @@ void initPreferences()
|
|||||||
{
|
{
|
||||||
preferences->putInt(preference_restart_timer, -1);
|
preferences->putInt(preference_restart_timer, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return firstStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
@@ -163,7 +167,7 @@ void setup()
|
|||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
Log = &Serial;
|
Log = &Serial;
|
||||||
|
|
||||||
initPreferences();
|
bool firstStart = initPreferences();
|
||||||
|
|
||||||
if(preferences->getInt(preference_restart_timer) > 0)
|
if(preferences->getInt(preference_restart_timer) > 0)
|
||||||
{
|
{
|
||||||
@@ -196,7 +200,7 @@ void setup()
|
|||||||
if(lockEnabled)
|
if(lockEnabled)
|
||||||
{
|
{
|
||||||
nuki = new NukiWrapper("NukiHub", deviceId, bleScanner, networkLock, preferences);
|
nuki = new NukiWrapper("NukiHub", deviceId, bleScanner, networkLock, preferences);
|
||||||
nuki->initialize();
|
nuki->initialize(firstStart);
|
||||||
|
|
||||||
if(preferences->getBool(preference_gpio_locking_enabled))
|
if(preferences->getBool(preference_gpio_locking_enabled))
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user