Merge remote-tracking branch 'upstream/master' into home-assistant-checkbox
This commit is contained in:
Submodule lib/nuki_ble updated: 0b4e5901c7...19e82cea97
@@ -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"
|
||||
|
||||
@@ -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,12 +270,79 @@ void NukiOpenerWrapper::update()
|
||||
_nextLockAction = (NukiOpener::LockAction) 0xff;
|
||||
}
|
||||
}
|
||||
if(_statusUpdated || _nextLockStateUpdateTs == 0 || ts >= _nextLockStateUpdateTs || (queryCommands & QUERY_COMMAND_LOCKSTATE) > 0)
|
||||
{
|
||||
_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,13 +3880,23 @@ BleScanner::Scanner *NukiOpenerWrapper::bleScanner()
|
||||
|
||||
void NukiOpenerWrapper::notify(Nuki::EventType eventType)
|
||||
{
|
||||
if(!_pairedAsApp && eventType == Nuki::EventType::KeyTurnerStatusUpdated && !_statusUpdated)
|
||||
if(eventType == Nuki::EventType::KeyTurnerStatusReset)
|
||||
{
|
||||
_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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NukiOpenerWrapper::readConfig()
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -359,8 +359,6 @@ void NukiWrapper::update()
|
||||
_nextLockAction = (NukiLock::LockAction) 0xff;
|
||||
}
|
||||
}
|
||||
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");
|
||||
@@ -369,6 +367,8 @@ void NukiWrapper::update()
|
||||
updateKeyTurnerState();
|
||||
_network->publishStatusUpdated(_statusUpdated);
|
||||
}
|
||||
if(_network->mqttConnectionState() == 2)
|
||||
{
|
||||
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,8 +3998,16 @@ void NukiWrapper::notify(Nuki::EventType eventType)
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!_pairedAsApp && eventType == Nuki::EventType::KeyTurnerStatusUpdated && !_statusUpdated)
|
||||
if(eventType == Nuki::EventType::KeyTurnerStatusReset)
|
||||
{
|
||||
_newSignal = false;
|
||||
Log->println("KeyTurnerStatusReset");
|
||||
}
|
||||
else if(eventType == Nuki::EventType::KeyTurnerStatusUpdated)
|
||||
{
|
||||
if(!_statusUpdated && !_newSignal)
|
||||
{
|
||||
_newSignal = true;
|
||||
Log->println("KeyTurnerStatusUpdated");
|
||||
_statusUpdated = true;
|
||||
_statusUpdatedTs = espMillis();
|
||||
@@ -4008,6 +4016,7 @@ void NukiWrapper::notify(Nuki::EventType eventType)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NukiWrapper::readConfig()
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -78,7 +78,7 @@ void WebCfgServer::initialize()
|
||||
{
|
||||
_psychicServer->on("/", HTTP_GET, [&](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.");
|
||||
}
|
||||
@@ -100,7 +100,7 @@ void WebCfgServer::initialize()
|
||||
|
||||
_psychicServer->on("/style.css", HTTP_GET, [&](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.");
|
||||
}
|
||||
@@ -108,7 +108,7 @@ void WebCfgServer::initialize()
|
||||
});
|
||||
_psychicServer->on("/favicon.ico", HTTP_GET, [&](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.");
|
||||
}
|
||||
@@ -116,7 +116,7 @@ void WebCfgServer::initialize()
|
||||
});
|
||||
_psychicServer->on("/reboot", HTTP_GET, [&](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.");
|
||||
}
|
||||
@@ -150,7 +150,7 @@ 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))
|
||||
if(strlen(_credUser) > 0 && strlen(_credPassword) > 0 && !request->authenticate(_credUser, _credPassword))
|
||||
{
|
||||
return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
|
||||
}
|
||||
@@ -158,7 +158,7 @@ void WebCfgServer::initialize()
|
||||
});
|
||||
_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,7 +181,7 @@ 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))
|
||||
if(strlen(_credUser) > 0 && strlen(_credPassword) > 0 && !request->authenticate(_credUser, _credPassword))
|
||||
{
|
||||
return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
|
||||
}
|
||||
@@ -191,7 +191,7 @@ void WebCfgServer::initialize()
|
||||
});
|
||||
_psychicServer->on("/export", HTTP_GET, [&](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.");
|
||||
}
|
||||
@@ -199,7 +199,7 @@ void WebCfgServer::initialize()
|
||||
});
|
||||
_psychicServer->on("/impexpcfg", HTTP_GET, [&](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.");
|
||||
}
|
||||
@@ -207,7 +207,7 @@ void WebCfgServer::initialize()
|
||||
});
|
||||
_psychicServer->on("/status", HTTP_GET, [&](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.");
|
||||
}
|
||||
@@ -215,7 +215,7 @@ void WebCfgServer::initialize()
|
||||
});
|
||||
_psychicServer->on("/acclvl", HTTP_GET, [&](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.");
|
||||
}
|
||||
@@ -223,7 +223,7 @@ void WebCfgServer::initialize()
|
||||
});
|
||||
_psychicServer->on("/custntw", HTTP_GET, [&](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.");
|
||||
}
|
||||
@@ -231,7 +231,7 @@ void WebCfgServer::initialize()
|
||||
});
|
||||
_psychicServer->on("/advanced", HTTP_GET, [&](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.");
|
||||
}
|
||||
@@ -239,7 +239,7 @@ void WebCfgServer::initialize()
|
||||
});
|
||||
_psychicServer->on("/cred", HTTP_GET, [&](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.");
|
||||
}
|
||||
@@ -247,7 +247,7 @@ void WebCfgServer::initialize()
|
||||
});
|
||||
_psychicServer->on("/ntwconfig", HTTP_GET, [&](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.");
|
||||
}
|
||||
@@ -255,7 +255,7 @@ void WebCfgServer::initialize()
|
||||
});
|
||||
_psychicServer->on("/mqttconfig", HTTP_GET, [&](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.");
|
||||
}
|
||||
@@ -263,7 +263,7 @@ void WebCfgServer::initialize()
|
||||
});
|
||||
_psychicServer->on("/nukicfg", HTTP_GET, [&](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.");
|
||||
}
|
||||
@@ -271,7 +271,7 @@ void WebCfgServer::initialize()
|
||||
});
|
||||
_psychicServer->on("/gpiocfg", HTTP_GET, [&](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.");
|
||||
}
|
||||
@@ -280,7 +280,7 @@ void WebCfgServer::initialize()
|
||||
#ifndef CONFIG_IDF_TARGET_ESP32H2
|
||||
_psychicServer->on("/wifi", HTTP_GET, [&](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.");
|
||||
}
|
||||
@@ -288,7 +288,7 @@ void WebCfgServer::initialize()
|
||||
});
|
||||
_psychicServer->on("/wifimanager", HTTP_GET, [&](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.");
|
||||
}
|
||||
@@ -304,7 +304,7 @@ void WebCfgServer::initialize()
|
||||
#endif
|
||||
_psychicServer->on("/unpairlock", 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.");
|
||||
}
|
||||
@@ -312,7 +312,7 @@ void WebCfgServer::initialize()
|
||||
});
|
||||
_psychicServer->on("/unpairopener", 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.");
|
||||
}
|
||||
@@ -320,15 +320,15 @@ void WebCfgServer::initialize()
|
||||
});
|
||||
_psychicServer->on("/factoryreset", 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.");
|
||||
}
|
||||
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))
|
||||
if(strlen(_credUser) > 0 && strlen(_credPassword) > 0 && !request->authenticate(_credUser, _credPassword))
|
||||
{
|
||||
return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
|
||||
}
|
||||
@@ -336,7 +336,7 @@ void WebCfgServer::initialize()
|
||||
});
|
||||
_psychicServer->on("/debugon", HTTP_GET, [&](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.");
|
||||
}
|
||||
@@ -345,7 +345,7 @@ void WebCfgServer::initialize()
|
||||
});
|
||||
_psychicServer->on("/debugoff", HTTP_GET, [&](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.");
|
||||
}
|
||||
@@ -354,7 +354,7 @@ void WebCfgServer::initialize()
|
||||
});
|
||||
_psychicServer->on("/savecfg", 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.");
|
||||
}
|
||||
@@ -364,7 +364,7 @@ void WebCfgServer::initialize()
|
||||
});
|
||||
_psychicServer->on("/savegpiocfg", 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.");
|
||||
}
|
||||
@@ -378,7 +378,7 @@ void WebCfgServer::initialize()
|
||||
#endif
|
||||
_psychicServer->on("/ota", HTTP_GET, [&](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.");
|
||||
}
|
||||
@@ -386,7 +386,7 @@ void WebCfgServer::initialize()
|
||||
});
|
||||
_psychicServer->on("/otadebug", HTTP_GET, [&](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.");
|
||||
}
|
||||
@@ -394,7 +394,7 @@ void WebCfgServer::initialize()
|
||||
});
|
||||
_psychicServer->on("/reboottoota", HTTP_GET, [&](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.");
|
||||
}
|
||||
@@ -424,7 +424,7 @@ void WebCfgServer::initialize()
|
||||
});
|
||||
_psychicServer->on("/autoupdate", HTTP_GET, [&](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.");
|
||||
}
|
||||
@@ -438,7 +438,7 @@ 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))
|
||||
if(strlen(_credUser) > 0 && strlen(_credPassword) > 0 && !request->authenticate(_credUser, _credPassword))
|
||||
{
|
||||
return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
|
||||
}
|
||||
@@ -448,7 +448,7 @@ void WebCfgServer::initialize()
|
||||
|
||||
updateHandler->onRequest([&](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.");
|
||||
}
|
||||
@@ -586,9 +586,8 @@ esp_err_t WebCfgServer::buildWifiConnectHtml(PsychicRequest *request)
|
||||
response.print("</table>");
|
||||
response.print("<br><input type=\"submit\" name=\"submit\" value=\"Save\">");
|
||||
response.print("</form>");
|
||||
response.print("<form action=\"/reboot?CONFIRMTOKEN=");
|
||||
response.print(_confirmCode);
|
||||
response.print("\" method=\"get\"><br><input type=\"submit\" value=\"Reboot\" /></form>");
|
||||
response.print("<form action=\"/reboot\" method=\"get\"><br>");
|
||||
response.print("<input type=\"hidden\" name=\"CONFIRMTOKEN\" value=\"" + _confirmCode + "\" /><input type=\"submit\" value=\"Reboot\" /></form>");
|
||||
response.print("</body></html>");
|
||||
return response.endSend();
|
||||
}
|
||||
@@ -882,9 +881,8 @@ esp_err_t WebCfgServer::buildOtaHtml(PsychicRequest *request, bool debug)
|
||||
response.print("<h4><a onclick=\"hideshowmanual();\">Manually update Nuki Hub</a></h4><div id=\"manualupdate\" style=\"display: none\">");
|
||||
response.print("<div id=\"rebootform\"><h4>Reboot to Nuki Hub Updater</h4>");
|
||||
response.print("Click on the button to reboot to the Nuki Hub updater, where you can select the latest Nuki Hub binary to update");
|
||||
response.print("<form action=\"/reboottoota?CONFIRMTOKEN=");
|
||||
response.print(_confirmCode);
|
||||
response.print("\" method=\"get\"><br><input type=\"submit\" value=\"Reboot to Nuki Hub Updater\" /></form><br><br></div>");
|
||||
response.print("<form action=\"/reboottoota\" method=\"get\"><br>");
|
||||
response.print("<input type=\"hidden\" name=\"CONFIRMTOKEN\" value=\"" + _confirmCode + "\" /><input type=\"submit\" value=\"Reboot to Nuki Hub Updater\" /></form><br><br></div>");
|
||||
response.print("<div id=\"upform\"><h4>Update Nuki Hub Updater</h4>");
|
||||
response.print("Select the latest Nuki Hub updater binary to update the Nuki Hub updater");
|
||||
response.print("<form enctype=\"multipart/form-data\" action=\"/uploadota\" method=\"post\">Choose the nuki_hub_updater.bin file to upload: <input name=\"uploadedfile\" type=\"file\" accept=\".bin\" /><br/>");
|
||||
@@ -894,9 +892,8 @@ esp_err_t WebCfgServer::buildOtaHtml(PsychicRequest *request, bool debug)
|
||||
response.print("<div id=\"manualupdate\">");
|
||||
response.print("<div id=\"rebootform\"><h4>Reboot to Nuki Hub</h4>");
|
||||
response.print("Click on the button to reboot to Nuki Hub");
|
||||
response.print("<form action=\"/reboottoota?CONFIRMTOKEN=");
|
||||
response.print(_confirmCode);
|
||||
response.print("\" method=\"get\"><br><input type=\"submit\" value=\"Reboot to Nuki Hub\" /></form><br><br></div>");
|
||||
response.print("<form action=\"/reboottoota\" method=\"get\"><br>");
|
||||
response.print("<input type=\"hidden\" name=\"CONFIRMTOKEN\" value=\"" + _confirmCode + "\" /><input type=\"submit\" value=\"Reboot to Nuki Hub\" /></form><br><br></div>");
|
||||
response.print("<div id=\"upform\"><h4>Update Nuki Hub</h4>");
|
||||
response.print("Select the latest Nuki Hub binary to update Nuki Hub");
|
||||
response.print("<form enctype=\"multipart/form-data\" action=\"/uploadota\" method=\"post\">Choose the nuki_hub.bin file to upload: <input name=\"uploadedfile\" type=\"file\" accept=\".bin\" /><br/>");
|
||||
@@ -3382,7 +3379,7 @@ esp_err_t WebCfgServer::buildHtml(PsychicRequest *request)
|
||||
printParameter(&response, "Nuki Opener PIN status", openerState.c_str(), "", "openerPin");
|
||||
}
|
||||
}
|
||||
printParameter(&response, "Firmware", NUKI_HUB_VERSION, "/infopg", "firmware");
|
||||
printParameter(&response, "Firmware", NUKI_HUB_VERSION, "/info", "firmware");
|
||||
if(_preferences->getBool(preference_check_updates))
|
||||
{
|
||||
printParameter(&response, "Latest Firmware", _preferences->getString(preference_latest_version).c_str(), "/ota", "ota");
|
||||
|
||||
@@ -201,7 +201,7 @@ void nukiTask(void *pvParameters)
|
||||
|
||||
if (needsPairing)
|
||||
{
|
||||
delay(5000);
|
||||
delay(2500);
|
||||
}
|
||||
else if (!whiteListed)
|
||||
{
|
||||
@@ -500,9 +500,11 @@ void setup()
|
||||
if(!doOta)
|
||||
{
|
||||
psychicServer = new PsychicHttpServer;
|
||||
psychicServer->config.max_uri_handlers = 40;
|
||||
psychicServer->config.stack_size = HTTPD_TASK_SIZE;
|
||||
psychicServer->listen(80);
|
||||
webCfgServer = new WebCfgServer(network, preferences, network->networkDeviceType() == NetworkDeviceType::WiFi, partitionType, psychicServer);
|
||||
webCfgServer->initialize();
|
||||
psychicServer->listen(80);
|
||||
psychicServer->onNotFound([](PsychicRequest* request)
|
||||
{
|
||||
return request->redirect("/");
|
||||
@@ -591,8 +593,6 @@ void setup()
|
||||
psychicServer = new PsychicHttpServer;
|
||||
psychicServer->config.max_uri_handlers = 40;
|
||||
psychicServer->config.stack_size = HTTPD_TASK_SIZE;
|
||||
psychicServer->maxUploadSize = 8192;
|
||||
psychicServer->maxRequestBodySize = 8192;
|
||||
psychicServer->listen(80);
|
||||
|
||||
if(forceEnableWebServer || preferences->getBool(preference_webserver_enabled, true))
|
||||
|
||||
Reference in New Issue
Block a user