diff --git a/lib/nuki_ble b/lib/nuki_ble
index 0b4e590..19e82ce 160000
--- a/lib/nuki_ble
+++ b/lib/nuki_ble
@@ -1 +1 @@
-Subproject commit 0b4e5901c712a77417fda9a8a6ba54436e343e4a
+Subproject commit 19e82cea9739cadeebfbfac46c189e7cfdad2896
diff --git a/src/Config.h b/src/Config.h
index b82a95b..d032352 100644
--- a/src/Config.h
+++ b/src/Config.h
@@ -4,7 +4,7 @@
#define NUKI_HUB_VERSION "9.02"
#define NUKI_HUB_BUILD "unknownbuildnr"
-#define NUKI_HUB_DATE "2024-11-02"
+#define NUKI_HUB_DATE "2024-11-03"
#define GITHUB_LATEST_RELEASE_URL (char*)"https://github.com/technyon/nuki_hub/releases/latest"
#define GITHUB_OTA_MANIFEST_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/manifest.json"
diff --git a/src/NukiOpenerWrapper.cpp b/src/NukiOpenerWrapper.cpp
index 4fa6762..05a0983 100644
--- a/src/NukiOpenerWrapper.cpp
+++ b/src/NukiOpenerWrapper.cpp
@@ -218,72 +218,6 @@ void NukiOpenerWrapper::update()
_nukiOpener.updateConnectionState();
- if(_network->mqttConnectionState() == 2)
- {
- if(_statusUpdated || _nextLockStateUpdateTs == 0 || ts >= _nextLockStateUpdateTs || (queryCommands & QUERY_COMMAND_LOCKSTATE) > 0)
- {
- _statusUpdated = false;
- _nextLockStateUpdateTs = ts + _intervalLockstate * 1000;
- updateKeyTurnerState();
- _network->publishStatusUpdated(_statusUpdated);
- }
- if(_nextBatteryReportTs == 0 || ts > _nextBatteryReportTs || (queryCommands & QUERY_COMMAND_BATTERY) > 0)
- {
- _nextBatteryReportTs = ts + _intervalBattery * 1000;
- updateBatteryState();
- }
- if(_nextConfigUpdateTs == 0 || ts > _nextConfigUpdateTs || (queryCommands & QUERY_COMMAND_CONFIG) > 0)
- {
- _nextConfigUpdateTs = ts + _intervalConfig * 1000;
- updateConfig();
- }
- if(_waitAuthLogUpdateTs != 0 && ts > _waitAuthLogUpdateTs)
- {
- _waitAuthLogUpdateTs = 0;
- updateAuthData(true);
- }
- if(_waitKeypadUpdateTs != 0 && ts > _waitKeypadUpdateTs)
- {
- _waitKeypadUpdateTs = 0;
- updateKeypad(true);
- }
- if(_waitTimeControlUpdateTs != 0 && ts > _waitTimeControlUpdateTs)
- {
- _waitTimeControlUpdateTs = 0;
- updateTimeControl(true);
- }
- if(_waitAuthUpdateTs != 0 && ts > _waitAuthUpdateTs)
- {
- _waitAuthUpdateTs = 0;
- updateAuth(true);
- }
- if(_hassEnabled && _nukiConfigValid && _nukiAdvancedConfigValid && !_hassSetupCompleted)
- {
- setupHASS();
- }
- if(_rssiPublishInterval > 0 && (_nextRssiTs == 0 || ts > _nextRssiTs))
- {
- _nextRssiTs = ts + _rssiPublishInterval;
-
- int rssi = _nukiOpener.getRssi();
- if(rssi != _lastRssi)
- {
- _network->publishRssi(rssi);
- _lastRssi = rssi;
- }
- }
- if(_hasKeypad && _keypadEnabled && (_nextKeypadUpdateTs == 0 || ts > _nextKeypadUpdateTs || (queryCommands & QUERY_COMMAND_KEYPAD) > 0))
- {
- _nextKeypadUpdateTs = ts + _intervalKeypad * 1000;
- updateKeypad(false);
- }
- }
-
- if(_checkKeypadCodes && _invalidCount > 0 && (ts - (120000 * _invalidCount)) > _lastCodeCheck)
- {
- _invalidCount--;
- }
-
if(_nextLockAction != (NukiOpener::LockAction)0xff)
{
int retryCount = 0;
@@ -336,11 +270,78 @@ void NukiOpenerWrapper::update()
_nextLockAction = (NukiOpener::LockAction) 0xff;
}
}
-
- if(_clearAuthData)
+ if(_statusUpdated || _nextLockStateUpdateTs == 0 || ts >= _nextLockStateUpdateTs || (queryCommands & QUERY_COMMAND_LOCKSTATE) > 0)
{
- _network->clearAuthorizationInfo();
- _clearAuthData = false;
+ _statusUpdated = false;
+ _nextLockStateUpdateTs = ts + _intervalLockstate * 1000;
+ updateKeyTurnerState();
+ _network->publishStatusUpdated(_statusUpdated);
+ }
+ if(_network->mqttConnectionState() == 2)
+ {
+ if(!_statusUpdated)
+ {
+ if(_nextBatteryReportTs == 0 || ts > _nextBatteryReportTs || (queryCommands & QUERY_COMMAND_BATTERY) > 0)
+ {
+ _nextBatteryReportTs = ts + _intervalBattery * 1000;
+ updateBatteryState();
+ }
+ if(_nextConfigUpdateTs == 0 || ts > _nextConfigUpdateTs || (queryCommands & QUERY_COMMAND_CONFIG) > 0)
+ {
+ _nextConfigUpdateTs = ts + _intervalConfig * 1000;
+ updateConfig();
+ }
+ if(_waitAuthLogUpdateTs != 0 && ts > _waitAuthLogUpdateTs)
+ {
+ _waitAuthLogUpdateTs = 0;
+ updateAuthData(true);
+ }
+ if(_waitKeypadUpdateTs != 0 && ts > _waitKeypadUpdateTs)
+ {
+ _waitKeypadUpdateTs = 0;
+ updateKeypad(true);
+ }
+ if(_waitTimeControlUpdateTs != 0 && ts > _waitTimeControlUpdateTs)
+ {
+ _waitTimeControlUpdateTs = 0;
+ updateTimeControl(true);
+ }
+ if(_waitAuthUpdateTs != 0 && ts > _waitAuthUpdateTs)
+ {
+ _waitAuthUpdateTs = 0;
+ updateAuth(true);
+ }
+ if(_hassEnabled && _nukiConfigValid && _nukiAdvancedConfigValid && !_hassSetupCompleted)
+ {
+ setupHASS();
+ }
+ if(_rssiPublishInterval > 0 && (_nextRssiTs == 0 || ts > _nextRssiTs))
+ {
+ _nextRssiTs = ts + _rssiPublishInterval;
+
+ int rssi = _nukiOpener.getRssi();
+ if(rssi != _lastRssi)
+ {
+ _network->publishRssi(rssi);
+ _lastRssi = rssi;
+ }
+ }
+ if(_hasKeypad && _keypadEnabled && (_nextKeypadUpdateTs == 0 || ts > _nextKeypadUpdateTs || (queryCommands & QUERY_COMMAND_KEYPAD) > 0))
+ {
+ _nextKeypadUpdateTs = ts + _intervalKeypad * 1000;
+ updateKeypad(false);
+ }
+ }
+
+ if(_clearAuthData)
+ {
+ _network->clearAuthorizationInfo();
+ _clearAuthData = false;
+ }
+ if(_checkKeypadCodes && _invalidCount > 0 && (ts - (120000 * _invalidCount)) > _lastCodeCheck)
+ {
+ _invalidCount--;
+ }
}
memcpy(&_lastKeyTurnerState, &_keyTurnerState, sizeof(NukiOpener::OpenerState));
@@ -465,8 +466,15 @@ void NukiOpenerWrapper::updateKeyTurnerState()
_network->publishRing(false);
}
- _network->publishKeyTurnerState(_keyTurnerState, _lastKeyTurnerState);
+ if(_publishAuthData)
+ {
+ Log->println(F("Publishing auth data"));
+ updateAuthData(false);
+ Log->println(F("Done publishing auth data"));
+ }
+
updateGpioOutputs();
+ _network->publishKeyTurnerState(_keyTurnerState, _lastKeyTurnerState);
if(_keyTurnerState.nukiState == NukiOpener::State::ContinuousMode)
{
@@ -478,13 +486,6 @@ void NukiOpenerWrapper::updateKeyTurnerState()
Log->println(lockStateStr);
}
- if(_publishAuthData)
- {
- Log->println(F("Publishing auth data"));
- updateAuthData(false);
- Log->println(F("Done publishing auth data"));
- }
-
postponeBleWatchdog();
Log->println(F("Done querying opener state"));
}
@@ -540,7 +541,7 @@ void NukiOpenerWrapper::updateConfig()
if(_preferences->getUInt(preference_nuki_id_opener, 0) == _nukiConfig.nukiId)
{
- _hasKeypad = _nukiConfig.hasKeypad == 1 || _nukiConfig.hasKeypadV2 == 1;
+ _hasKeypad = _nukiConfig.hasKeypad == 1 || (_nukiConfig.hasKeypadV2 > 0 && _nukiConfig.hasKeypadV2 != 252);
_firmwareVersion = std::to_string(_nukiConfig.firmwareVersion[0]) + "." + std::to_string(_nukiConfig.firmwareVersion[1]) + "." + std::to_string(_nukiConfig.firmwareVersion[2]);
_hardwareVersion = std::to_string(_nukiConfig.hardwareRevision[0]) + "." + std::to_string(_nukiConfig.hardwareRevision[1]);
if(_preferences->getBool(preference_conf_info_enabled, true))
@@ -3879,11 +3880,21 @@ BleScanner::Scanner *NukiOpenerWrapper::bleScanner()
void NukiOpenerWrapper::notify(Nuki::EventType eventType)
{
- if(!_pairedAsApp && eventType == Nuki::EventType::KeyTurnerStatusUpdated && !_statusUpdated)
+ if(eventType == Nuki::EventType::KeyTurnerStatusReset)
{
- Log->println("KeyTurnerStatusUpdated");
- _statusUpdated = true;
- _network->publishStatusUpdated(_statusUpdated);
+ _newSignal = false;
+ Log->println("KeyTurnerStatusReset");
+ }
+ else if(eventType == Nuki::EventType::KeyTurnerStatusUpdated)
+ {
+ if(!_statusUpdated && !_newSignal)
+ {
+ _newSignal = true;
+ Log->println("KeyTurnerStatusUpdated");
+ _statusUpdated = true;
+ _statusUpdatedTs = espMillis();
+ _network->publishStatusUpdated(_statusUpdated);
+ }
}
}
diff --git a/src/NukiOpenerWrapper.h b/src/NukiOpenerWrapper.h
index 2dab4aa..177efa9 100644
--- a/src/NukiOpenerWrapper.h
+++ b/src/NukiOpenerWrapper.h
@@ -135,12 +135,14 @@ private:
bool _paired = false;
bool _statusUpdated = false;
+ bool _newSignal = false;
bool _hasKeypad = false;
bool _keypadEnabled = false;
uint _maxKeypadCodeCount = 0;
uint _maxTimeControlEntryCount = 0;
uint _maxAuthEntryCount = 0;
int _rssiPublishInterval = 0;
+ int64_t _statusUpdatedTs = 0;
int64_t _nextLockStateUpdateTs = 0;
int64_t _nextBatteryReportTs = 0;
int64_t _nextConfigUpdateTs = 0;
diff --git a/src/NukiWrapper.cpp b/src/NukiWrapper.cpp
index 799eb0c..e2ca06b 100644
--- a/src/NukiWrapper.cpp
+++ b/src/NukiWrapper.cpp
@@ -359,16 +359,16 @@ void NukiWrapper::update()
_nextLockAction = (NukiLock::LockAction) 0xff;
}
}
+ if(_nukiOfficial->getStatusUpdated() || _statusUpdated || _nextLockStateUpdateTs == 0 || ts >= _nextLockStateUpdateTs || (queryCommands & QUERY_COMMAND_LOCKSTATE) > 0)
+ {
+ Log->println("Updating Lock state based on status, timer or query");
+ _statusUpdated = false;
+ _nextLockStateUpdateTs = ts + _intervalLockstate * 1000;
+ updateKeyTurnerState();
+ _network->publishStatusUpdated(_statusUpdated);
+ }
if(_network->mqttConnectionState() == 2)
{
- if(_nukiOfficial->getStatusUpdated() || _statusUpdated || _nextLockStateUpdateTs == 0 || ts >= _nextLockStateUpdateTs || (queryCommands & QUERY_COMMAND_LOCKSTATE) > 0)
- {
- Log->println("Updating Lock state based on status, timer or query");
- _statusUpdated = false;
- _nextLockStateUpdateTs = ts + _intervalLockstate * 1000;
- updateKeyTurnerState();
- _network->publishStatusUpdated(_statusUpdated);
- }
if(!_statusUpdated)
{
if(_nextBatteryReportTs == 0 || ts > _nextBatteryReportTs || (queryCommands & QUERY_COMMAND_BATTERY) > 0)
@@ -628,7 +628,7 @@ void NukiWrapper::updateConfig()
if(_preferences->getUInt(preference_nuki_id_lock, 0) == _nukiConfig.nukiId)
{
- _hasKeypad = _nukiConfig.hasKeypad == 1 || _nukiConfig.hasKeypadV2 == 1;
+ _hasKeypad = _nukiConfig.hasKeypad == 1 || (_nukiConfig.hasKeypadV2 > 0 && _nukiConfig.hasKeypadV2 != 252);
_firmwareVersion = std::to_string(_nukiConfig.firmwareVersion[0]) + "." + std::to_string(_nukiConfig.firmwareVersion[1]) + "." + std::to_string(_nukiConfig.firmwareVersion[2]);
_hardwareVersion = std::to_string(_nukiConfig.hardwareRevision[0]) + "." + std::to_string(_nukiConfig.hardwareRevision[1]);
if(_preferences->getBool(preference_conf_info_enabled, true))
@@ -3998,12 +3998,21 @@ void NukiWrapper::notify(Nuki::EventType eventType)
}
else
{
- if(!_pairedAsApp && eventType == Nuki::EventType::KeyTurnerStatusUpdated && !_statusUpdated)
+ if(eventType == Nuki::EventType::KeyTurnerStatusReset)
{
- Log->println("KeyTurnerStatusUpdated");
- _statusUpdated = true;
- _statusUpdatedTs = espMillis();
- _network->publishStatusUpdated(_statusUpdated);
+ _newSignal = false;
+ Log->println("KeyTurnerStatusReset");
+ }
+ else if(eventType == Nuki::EventType::KeyTurnerStatusUpdated)
+ {
+ if(!_statusUpdated && !_newSignal)
+ {
+ _newSignal = true;
+ Log->println("KeyTurnerStatusUpdated");
+ _statusUpdated = true;
+ _statusUpdatedTs = espMillis();
+ _network->publishStatusUpdated(_statusUpdated);
+ }
}
}
}
diff --git a/src/NukiWrapper.h b/src/NukiWrapper.h
index 4cdb937..890f7b4 100644
--- a/src/NukiWrapper.h
+++ b/src/NukiWrapper.h
@@ -134,6 +134,7 @@ private:
bool _pairedAsApp = false;
bool _paired = false;
bool _statusUpdated = false;
+ bool _newSignal = false;
bool _hasKeypad = false;
bool _keypadEnabled = false;
uint _maxKeypadCodeCount = 0;
diff --git a/src/WebCfgServer.cpp b/src/WebCfgServer.cpp
index a94ce81..9d6f3eb 100644
--- a/src/WebCfgServer.cpp
+++ b/src/WebCfgServer.cpp
@@ -78,10 +78,10 @@ void WebCfgServer::initialize()
{
_psychicServer->on("/", HTTP_GET, [&](PsychicRequest *request)
{
- if(strlen(_credUser) > 0 && strlen(_credPassword) > 0) if(!request->authenticate(_credUser, _credPassword))
- {
- return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
- }
+ if(strlen(_credUser) > 0 && strlen(_credPassword) > 0 && !request->authenticate(_credUser, _credPassword))
+ {
+ return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
+ }
if(!_network->isApOpen())
{
#ifndef NUKI_HUB_UPDATER
@@ -100,26 +100,26 @@ void WebCfgServer::initialize()
_psychicServer->on("/style.css", HTTP_GET, [&](PsychicRequest *request)
{
- if(strlen(_credUser) > 0 && strlen(_credPassword) > 0) if(!request->authenticate(_credUser, _credPassword))
- {
- return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
- }
+ if(strlen(_credUser) > 0 && strlen(_credPassword) > 0 && !request->authenticate(_credUser, _credPassword))
+ {
+ return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
+ }
return sendCss(request);
});
_psychicServer->on("/favicon.ico", HTTP_GET, [&](PsychicRequest *request)
{
- if(strlen(_credUser) > 0 && strlen(_credPassword) > 0) if(!request->authenticate(_credUser, _credPassword))
- {
- return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
- }
+ if(strlen(_credUser) > 0 && strlen(_credPassword) > 0 && !request->authenticate(_credUser, _credPassword))
+ {
+ return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
+ }
return sendFavicon(request);
});
_psychicServer->on("/reboot", HTTP_GET, [&](PsychicRequest *request)
{
- if(strlen(_credUser) > 0 && strlen(_credPassword) > 0) if(!request->authenticate(_credUser, _credPassword))
- {
- return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
- }
+ if(strlen(_credUser) > 0 && strlen(_credPassword) > 0 && !request->authenticate(_credUser, _credPassword))
+ {
+ return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
+ }
String value = "";
if(request->hasParam("CONFIRMTOKEN"))
@@ -150,15 +150,15 @@ void WebCfgServer::initialize()
#ifndef CONFIG_IDF_TARGET_ESP32H2
_psychicServer->on("/ssidlist", HTTP_GET, [&](PsychicRequest *request)
{
- if(strlen(_credUser) > 0 && strlen(_credPassword) > 0) if(!request->authenticate(_credUser, _credPassword))
- {
- return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
- }
+ if(strlen(_credUser) > 0 && strlen(_credPassword) > 0 && !request->authenticate(_credUser, _credPassword))
+ {
+ return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
+ }
return buildSSIDListHtml(request);
});
_psychicServer->on("/savewifi", HTTP_POST, [&](PsychicRequest *request)
{
- if(strlen(_credUser) > 0 && strlen(_credPassword) > 0) if(!request->authenticate(_credUser, _credPassword))
+ if(strlen(_credUser) > 0 && strlen(_credPassword) > 0 && !request->authenticate(_credUser, _credPassword))
{
return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
}
@@ -181,117 +181,117 @@ void WebCfgServer::initialize()
#ifndef NUKI_HUB_UPDATER
_psychicServer->on("/import", HTTP_POST, [&](PsychicRequest *request)
{
- if(strlen(_credUser) > 0 && strlen(_credPassword) > 0) if(!request->authenticate(_credUser, _credPassword))
- {
- return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
- }
+ if(strlen(_credUser) > 0 && strlen(_credPassword) > 0 && !request->authenticate(_credUser, _credPassword))
+ {
+ return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
+ }
String message = "";
bool restart = processImport(request, message);
return buildConfirmHtml(request, message, 3, true);
});
_psychicServer->on("/export", HTTP_GET, [&](PsychicRequest *request)
{
- if(strlen(_credUser) > 0 && strlen(_credPassword) > 0) if(!request->authenticate(_credUser, _credPassword))
- {
- return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
- }
+ if(strlen(_credUser) > 0 && strlen(_credPassword) > 0 && !request->authenticate(_credUser, _credPassword))
+ {
+ return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
+ }
return sendSettings(request);
});
_psychicServer->on("/impexpcfg", HTTP_GET, [&](PsychicRequest *request)
{
- if(strlen(_credUser) > 0 && strlen(_credPassword) > 0) if(!request->authenticate(_credUser, _credPassword))
- {
- return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
- }
+ if(strlen(_credUser) > 0 && strlen(_credPassword) > 0 && !request->authenticate(_credUser, _credPassword))
+ {
+ return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
+ }
return buildImportExportHtml(request);
});
_psychicServer->on("/status", HTTP_GET, [&](PsychicRequest *request)
{
- if(strlen(_credUser) > 0 && strlen(_credPassword) > 0) if(!request->authenticate(_credUser, _credPassword))
- {
- return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
- }
+ if(strlen(_credUser) > 0 && strlen(_credPassword) > 0 && !request->authenticate(_credUser, _credPassword))
+ {
+ return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
+ }
return buildStatusHtml(request);
});
_psychicServer->on("/acclvl", HTTP_GET, [&](PsychicRequest *request)
{
- if(strlen(_credUser) > 0 && strlen(_credPassword) > 0) if(!request->authenticate(_credUser, _credPassword))
- {
- return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
- }
+ if(strlen(_credUser) > 0 && strlen(_credPassword) > 0 && !request->authenticate(_credUser, _credPassword))
+ {
+ return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
+ }
return buildAccLvlHtml(request);
});
_psychicServer->on("/custntw", HTTP_GET, [&](PsychicRequest *request)
{
- if(strlen(_credUser) > 0 && strlen(_credPassword) > 0) if(!request->authenticate(_credUser, _credPassword))
- {
- return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
- }
+ if(strlen(_credUser) > 0 && strlen(_credPassword) > 0 && !request->authenticate(_credUser, _credPassword))
+ {
+ return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
+ }
return buildCustomNetworkConfigHtml(request);
});
_psychicServer->on("/advanced", HTTP_GET, [&](PsychicRequest *request)
{
- if(strlen(_credUser) > 0 && strlen(_credPassword) > 0) if(!request->authenticate(_credUser, _credPassword))
- {
- return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
- }
+ if(strlen(_credUser) > 0 && strlen(_credPassword) > 0 && !request->authenticate(_credUser, _credPassword))
+ {
+ return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
+ }
return buildAdvancedConfigHtml(request);
});
_psychicServer->on("/cred", HTTP_GET, [&](PsychicRequest *request)
{
- if(strlen(_credUser) > 0 && strlen(_credPassword) > 0) if(!request->authenticate(_credUser, _credPassword))
- {
- return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
- }
+ if(strlen(_credUser) > 0 && strlen(_credPassword) > 0 && !request->authenticate(_credUser, _credPassword))
+ {
+ return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
+ }
return buildCredHtml(request);
});
_psychicServer->on("/ntwconfig", HTTP_GET, [&](PsychicRequest *request)
{
- if(strlen(_credUser) > 0 && strlen(_credPassword) > 0) if(!request->authenticate(_credUser, _credPassword))
- {
- return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
- }
+ if(strlen(_credUser) > 0 && strlen(_credPassword) > 0 && !request->authenticate(_credUser, _credPassword))
+ {
+ return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
+ }
return buildNetworkConfigHtml(request);
});
_psychicServer->on("/mqttconfig", HTTP_GET, [&](PsychicRequest *request)
{
- if(strlen(_credUser) > 0 && strlen(_credPassword) > 0) if(!request->authenticate(_credUser, _credPassword))
- {
- return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
- }
+ if(strlen(_credUser) > 0 && strlen(_credPassword) > 0 && !request->authenticate(_credUser, _credPassword))
+ {
+ return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
+ }
return buildMqttConfigHtml(request);
});
_psychicServer->on("/nukicfg", HTTP_GET, [&](PsychicRequest *request)
{
- if(strlen(_credUser) > 0 && strlen(_credPassword) > 0) if(!request->authenticate(_credUser, _credPassword))
- {
- return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
- }
+ if(strlen(_credUser) > 0 && strlen(_credPassword) > 0 && !request->authenticate(_credUser, _credPassword))
+ {
+ return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
+ }
return buildNukiConfigHtml(request);
});
_psychicServer->on("/gpiocfg", HTTP_GET, [&](PsychicRequest *request)
{
- if(strlen(_credUser) > 0 && strlen(_credPassword) > 0) if(!request->authenticate(_credUser, _credPassword))
- {
- return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
- }
+ if(strlen(_credUser) > 0 && strlen(_credPassword) > 0 && !request->authenticate(_credUser, _credPassword))
+ {
+ return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
+ }
return buildGpioConfigHtml(request);
});
#ifndef CONFIG_IDF_TARGET_ESP32H2
_psychicServer->on("/wifi", HTTP_GET, [&](PsychicRequest *request)
{
- if(strlen(_credUser) > 0 && strlen(_credPassword) > 0) if(!request->authenticate(_credUser, _credPassword))
- {
- return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
- }
+ if(strlen(_credUser) > 0 && strlen(_credPassword) > 0 && !request->authenticate(_credUser, _credPassword))
+ {
+ return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
+ }
return buildConfigureWifiHtml(request);
});
_psychicServer->on("/wifimanager", HTTP_GET, [&](PsychicRequest *request)
{
- if(strlen(_credUser) > 0 && strlen(_credPassword) > 0) if(!request->authenticate(_credUser, _credPassword))
- {
- return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
- }
+ if(strlen(_credUser) > 0 && strlen(_credPassword) > 0 && !request->authenticate(_credUser, _credPassword))
+ {
+ return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
+ }
if(_allowRestartToPortal)
{
esp_err_t res = buildConfirmHtml(request, "Restarting. Connect to ESP access point (\"NukiHub\" with password \"NukiHubESP32\") to reconfigure Wi-Fi.", 0);
@@ -304,70 +304,70 @@ void WebCfgServer::initialize()
#endif
_psychicServer->on("/unpairlock", HTTP_POST, [&](PsychicRequest *request)
{
- if(strlen(_credUser) > 0 && strlen(_credPassword) > 0) if(!request->authenticate(_credUser, _credPassword))
- {
- return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
- }
+ if(strlen(_credUser) > 0 && strlen(_credPassword) > 0 && !request->authenticate(_credUser, _credPassword))
+ {
+ return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
+ }
return processUnpair(request, false);
});
_psychicServer->on("/unpairopener", HTTP_POST, [&](PsychicRequest *request)
{
- if(strlen(_credUser) > 0 && strlen(_credPassword) > 0) if(!request->authenticate(_credUser, _credPassword))
- {
- return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
- }
+ if(strlen(_credUser) > 0 && strlen(_credPassword) > 0 && !request->authenticate(_credUser, _credPassword))
+ {
+ return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
+ }
return processUnpair(request, true);
});
_psychicServer->on("/factoryreset", HTTP_POST, [&](PsychicRequest *request)
{
- if(strlen(_credUser) > 0 && strlen(_credPassword) > 0) if(!request->authenticate(_credUser, _credPassword))
- {
- return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
- }
+ if(strlen(_credUser) > 0 && strlen(_credPassword) > 0 && !request->authenticate(_credUser, _credPassword))
+ {
+ return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
+ }
return processFactoryReset(request);
});
- _psychicServer->on("/infopg", HTTP_GET, [&](PsychicRequest *request)
+ _psychicServer->on("/info", HTTP_GET, [&](PsychicRequest *request)
{
- if(strlen(_credUser) > 0 && strlen(_credPassword) > 0) if(!request->authenticate(_credUser, _credPassword))
- {
- return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
- }
+ if(strlen(_credUser) > 0 && strlen(_credPassword) > 0 && !request->authenticate(_credUser, _credPassword))
+ {
+ return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
+ }
return buildInfoHtml(request);
});
_psychicServer->on("/debugon", HTTP_GET, [&](PsychicRequest *request)
{
- if(strlen(_credUser) > 0 && strlen(_credPassword) > 0) if(!request->authenticate(_credUser, _credPassword))
- {
- return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
- }
+ if(strlen(_credUser) > 0 && strlen(_credPassword) > 0 && !request->authenticate(_credUser, _credPassword))
+ {
+ return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
+ }
_preferences->putBool(preference_publish_debug_info, true);
return buildConfirmHtml(request, "Debug On", 3, true);
});
_psychicServer->on("/debugoff", HTTP_GET, [&](PsychicRequest *request)
{
- if(strlen(_credUser) > 0 && strlen(_credPassword) > 0) if(!request->authenticate(_credUser, _credPassword))
- {
- return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
- }
+ if(strlen(_credUser) > 0 && strlen(_credPassword) > 0 && !request->authenticate(_credUser, _credPassword))
+ {
+ return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
+ }
_preferences->putBool(preference_publish_debug_info, false);
return buildConfirmHtml(request, "Debug Off", 3, true);
});
_psychicServer->on("/savecfg", HTTP_POST, [&](PsychicRequest *request)
{
- if(strlen(_credUser) > 0 && strlen(_credPassword) > 0) if(!request->authenticate(_credUser, _credPassword))
- {
- return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
- }
+ if(strlen(_credUser) > 0 && strlen(_credPassword) > 0 && !request->authenticate(_credUser, _credPassword))
+ {
+ return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
+ }
String message = "";
bool restart = processArgs(request, message);
return buildConfirmHtml(request, message, 3, true);
});
_psychicServer->on("/savegpiocfg", HTTP_POST, [&](PsychicRequest *request)
{
- if(strlen(_credUser) > 0 && strlen(_credPassword) > 0) if(!request->authenticate(_credUser, _credPassword))
- {
- return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
- }
+ if(strlen(_credUser) > 0 && strlen(_credPassword) > 0 && !request->authenticate(_credUser, _credPassword))
+ {
+ return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
+ }
processGpioArgs(request);
esp_err_t res = buildConfirmHtml(request, "Saving GPIO configuration. Restarting.", 3, true);
Log->println(F("Restarting"));
@@ -378,26 +378,26 @@ void WebCfgServer::initialize()
#endif
_psychicServer->on("/ota", HTTP_GET, [&](PsychicRequest *request)
{
- if(strlen(_credUser) > 0 && strlen(_credPassword) > 0) if(!request->authenticate(_credUser, _credPassword))
- {
- return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
- }
+ if(strlen(_credUser) > 0 && strlen(_credPassword) > 0 && !request->authenticate(_credUser, _credPassword))
+ {
+ return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
+ }
return buildOtaHtml(request);
});
_psychicServer->on("/otadebug", HTTP_GET, [&](PsychicRequest *request)
{
- if(strlen(_credUser) > 0 && strlen(_credPassword) > 0) if(!request->authenticate(_credUser, _credPassword))
- {
- return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
- }
+ if(strlen(_credUser) > 0 && strlen(_credPassword) > 0 && !request->authenticate(_credUser, _credPassword))
+ {
+ return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
+ }
return buildOtaHtml(request, true);
});
_psychicServer->on("/reboottoota", HTTP_GET, [&](PsychicRequest *request)
{
- if(strlen(_credUser) > 0 && strlen(_credPassword) > 0) if(!request->authenticate(_credUser, _credPassword))
- {
- return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
- }
+ if(strlen(_credUser) > 0 && strlen(_credPassword) > 0 && !request->authenticate(_credUser, _credPassword))
+ {
+ return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
+ }
String value = "";
if(request->hasParam("CONFIRMTOKEN"))
{
@@ -424,10 +424,10 @@ void WebCfgServer::initialize()
});
_psychicServer->on("/autoupdate", HTTP_GET, [&](PsychicRequest *request)
{
- if(strlen(_credUser) > 0 && strlen(_credPassword) > 0) if(!request->authenticate(_credUser, _credPassword))
- {
- return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
- }
+ if(strlen(_credUser) > 0 && strlen(_credPassword) > 0 && !request->authenticate(_credUser, _credPassword))
+ {
+ return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
+ }
#ifndef NUKI_HUB_UPDATER
return processUpdate(request);
#else
@@ -438,20 +438,20 @@ void WebCfgServer::initialize()
PsychicUploadHandler *updateHandler = new PsychicUploadHandler();
updateHandler->onUpload([&](PsychicRequest *request, const String& filename, uint64_t index, uint8_t *data, size_t len, bool final)
{
- if(strlen(_credUser) > 0 && strlen(_credPassword) > 0) if(!request->authenticate(_credUser, _credPassword))
- {
- return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
- }
+ if(strlen(_credUser) > 0 && strlen(_credPassword) > 0 && !request->authenticate(_credUser, _credPassword))
+ {
+ return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
+ }
return handleOtaUpload(request, filename, index, data, len, final);
}
);
updateHandler->onRequest([&](PsychicRequest *request)
{
- if(strlen(_credUser) > 0 && strlen(_credPassword) > 0) if(!request->authenticate(_credUser, _credPassword))
- {
- return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
- }
+ if(strlen(_credUser) > 0 && strlen(_credPassword) > 0 && !request->authenticate(_credUser, _credPassword))
+ {
+ return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
+ }
String result;
if (!Update.hasError())
@@ -586,9 +586,8 @@ esp_err_t WebCfgServer::buildWifiConnectHtml(PsychicRequest *request)
response.print("");
response.print("
");
response.print("");
- response.print("