PsychicHTTP

This commit is contained in:
iranl
2024-08-28 23:59:36 +02:00
parent f7ef28e031
commit 52bd4f74c1
7 changed files with 64 additions and 61 deletions

View File

@@ -4,7 +4,7 @@
#define NUKI_HUB_VERSION "9.01"
#define NUKI_HUB_BUILD "unknownbuildnr"
#define NUKI_HUB_DATE "2024-08-27"
#define NUKI_HUB_DATE "2024-08-28"
#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"

View File

@@ -164,7 +164,7 @@ void WebCfgServer::initialize()
if(strlen(_credUser) > 0 && strlen(_credPassword) > 0) if(!request->authenticate(_credUser, _credPassword)) return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
return processFactoryReset(request);
});
_psychicServer->on("/info", HTTP_GET, [&](PsychicRequest *request){
_psychicServer->on("/infopg", 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.");
return buildInfoHtml(request);
});
@@ -2650,7 +2650,7 @@ esp_err_t WebCfgServer::buildHtml(PsychicRequest *request)
printParameter(&response, "Nuki Opener PIN status", openerState.c_str(), "", "openerPin");
}
}
printParameter(&response, "Firmware", NUKI_HUB_VERSION, "/info", "firmware");
printParameter(&response, "Firmware", NUKI_HUB_VERSION, "/infopg", "firmware");
if(_preferences->getBool(preference_check_updates))
{
printParameter(&response, "Latest Firmware", _preferences->getString(preference_latest_version).c_str(), "/ota", "ota");
@@ -3232,6 +3232,7 @@ esp_err_t WebCfgServer::buildConfigureWifiHtml(PsychicRequest *request)
esp_err_t WebCfgServer::buildInfoHtml(PsychicRequest *request)
{
Log->println("INFO HTML");
uint32_t aclPrefs[17];
_preferences->getBytes(preference_acl, &aclPrefs, sizeof(aclPrefs));
PsychicStreamResponse response(request, "text/plain");

View File

@@ -422,8 +422,8 @@ void setup()
psychicServer = new PsychicHttpServer;
webCfgServer = new WebCfgServer(network, preferences, network->networkDeviceType() == NetworkDeviceType::WiFi, partitionType, psychicServer);
webCfgServer->initialize();
psychicServer->onNotFound([](PsychicRequest* request) { return request->redirect("/"); });
psychicServer->listen(80);
psychicServer->onNotFound([](PsychicRequest* request) { return request->redirect("/"); });
}
#else
Log->print(F("Nuki Hub version "));