diff --git a/src/WebCfgServer.cpp b/src/WebCfgServer.cpp index 6370f78..6f5d07d 100644 --- a/src/WebCfgServer.cpp +++ b/src/WebCfgServer.cpp @@ -96,7 +96,6 @@ void WebCfgServer::initialize() } #endif }); - _psychicServer->on("/style.css", HTTP_GET, [&](PsychicRequest *request) { if(strlen(_credUser) > 0 && strlen(_credPassword) > 0 && !request->authenticate(_credUser, _credPassword)) @@ -113,37 +112,7 @@ void WebCfgServer::initialize() } return sendFavicon(request); }); - _psychicServer->on("/reboot", HTTP_GET, [&](PsychicRequest *request) - { - 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")) - { - const PsychicWebParameter* p = request->getParam("CONFIRMTOKEN"); - if(p->value() != "") - { - value = p->value(); - } - } - else - { - return buildConfirmHtml(request, "No confirm code set.", 3, true); - } - - if(value != _confirmCode) - { - return request->redirect("/"); - } - esp_err_t res = buildConfirmHtml(request, "Rebooting...", 2, true); - waitAndProcess(true, 1000); - restartEsp(RestartReason::RequestedViaWebServer); - return res; - }); - + if(_network->isApOpen()) { #ifndef CONFIG_IDF_TARGET_ESP32H2 @@ -173,247 +142,13 @@ void WebCfgServer::initialize() } return res; }); -#endif - } - else - { -#ifndef NUKI_HUB_UPDATER - _psychicServer->on("/import", HTTP_POST, [&](PsychicRequest *request) - { - 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 && !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 && !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 && !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 && !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 && !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 && !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 && !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 && !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 && !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 && !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 && !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 && !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 && !request->authenticate(_credUser, _credPassword)) - { - return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in."); - } - String value = ""; - if(request->hasParam("CONFIRMTOKEN")) - { - const PsychicWebParameter* p = request->getParam("CONFIRMTOKEN"); - if(p->value() != "") - { - value = p->value(); - } - } - else - { - return buildConfirmHtml(request, "No confirm code set.", 3, true); - } - if(value != _confirmCode) - { - return request->redirect("/"); - } - if(!_allowRestartToPortal) - { - return buildConfirmHtml(request, "Can't reset WiFi when network device is Ethernet", 3, true); - } - esp_err_t res = buildConfirmHtml(request, "Restarting. Connect to ESP access point (\"NukiHub\" with password \"NukiHubESP32\") to reconfigure Wi-Fi.", 0); - waitAndProcess(false, 1000); - _network->reconfigureDevice(); - return res; - }); -#endif - _psychicServer->on("/unpairlock", HTTP_POST, [&](PsychicRequest *request) - { - 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 && !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 && !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) - { - 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 && !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 && !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 && !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 && !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")); - waitAndProcess(true, 1000); - restartEsp(RestartReason::GpioConfigurationUpdated); - return res; - }); -#endif - _psychicServer->on("/ota", HTTP_GET, [&](PsychicRequest *request) - { - 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 && !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) + _psychicServer->on("/reboot", HTTP_GET, [&](PsychicRequest *request) { 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")) { @@ -432,23 +167,280 @@ void WebCfgServer::initialize() { return request->redirect("/"); } - esp_err_t res = buildConfirmHtml(request, "Rebooting to other partition...", 2, true); + esp_err_t res = buildConfirmHtml(request, "Rebooting...", 2, true); waitAndProcess(true, 1000); - esp_ota_set_boot_partition(esp_ota_get_next_update_partition(NULL)); - restartEsp(RestartReason::OTAReboot); + restartEsp(RestartReason::RequestedViaWebServer); return res; }); - _psychicServer->on("/autoupdate", HTTP_GET, [&](PsychicRequest *request) +#endif + } + else + { + _psychicServer->on("/get", HTTP_GET, [&](PsychicRequest *request) { 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 - return request->redirect("/"); -#endif + + String value = ""; + if(request->hasParam("page")) + { + const PsychicWebParameter* p = request->getParam("page"); + if(p->value() != "") + { + value = p->value(); + } + } + + if (value == "reboot") + { + String value = ""; + if(request->hasParam("CONFIRMTOKEN")) + { + const PsychicWebParameter* p = request->getParam("CONFIRMTOKEN"); + if(p->value() != "") + { + value = p->value(); + } + } + else + { + return buildConfirmHtml(request, "No confirm code set.", 3, true); + } + + if(value != _confirmCode) + { + return request->redirect("/"); + } + esp_err_t res = buildConfirmHtml(request, "Rebooting...", 2, true); + waitAndProcess(true, 1000); + restartEsp(RestartReason::RequestedViaWebServer); + return res; + } + #ifndef NUKI_HUB_UPDATER + else if (value == "info") + { + return buildInfoHtml(request); + } + else if (value == "debugon") + { + _preferences->putBool(preference_publish_debug_info, true); + return buildConfirmHtml(request, "Debug On", 3, true); + } + else if (value == "debugoff") + { + _preferences->putBool(preference_publish_debug_info, false); + return buildConfirmHtml(request, "Debug Off", 3, true); + } + else if (value == "export") + { + return sendSettings(request); + } + else if (value == "impexpcfg") + { + return buildImportExportHtml(request); + } + else if (value == "status") + { + return buildStatusHtml(request); + } + else if (value == "acclvl") + { + return buildAccLvlHtml(request); + } + else if (value == "custntw") + { + return buildCustomNetworkConfigHtml(request); + } + else if (value == "advanced") + { + return buildAdvancedConfigHtml(request); + } + else if (value == "cred") + { + return buildCredHtml(request); + } + else if (value == "ntwconfig") + { + return buildNetworkConfigHtml(request); + } + else if (value == "mqttconfig") + { + return buildMqttConfigHtml(request); + } + else if (value == "nukicfg") + { + return buildNukiConfigHtml(request); + } + else if (value == "gpiocfg") + { + return buildGpioConfigHtml(request); + } + #ifndef CONFIG_IDF_TARGET_ESP32H2 + else if (value == "wifi") + { + return buildConfigureWifiHtml(request); + } + else if (value == "wifimanager") + { + String value = ""; + if(request->hasParam("CONFIRMTOKEN")) + { + const PsychicWebParameter* p = request->getParam("CONFIRMTOKEN"); + if(p->value() != "") + { + value = p->value(); + } + } + else + { + return buildConfirmHtml(request, "No confirm code set.", 3, true); + } + if(value != _confirmCode) + { + return request->redirect("/"); + } + if(!_allowRestartToPortal) + { + return buildConfirmHtml(request, "Can't reset WiFi when network device is Ethernet", 3, true); + } + esp_err_t res = buildConfirmHtml(request, "Restarting. Connect to ESP access point (\"NukiHub\" with password \"NukiHubESP32\") to reconfigure Wi-Fi.", 0); + waitAndProcess(false, 1000); + _network->reconfigureDevice(); + return res; + } + #endif + #endif + else if (value == "ota") + { + return buildOtaHtml(request); + } + else if (value == "otadebug") + { + return buildOtaHtml(request, true); + } + else if (value == "reboottoota") + { + String value = ""; + if(request->hasParam("CONFIRMTOKEN")) + { + const PsychicWebParameter* p = request->getParam("CONFIRMTOKEN"); + if(p->value() != "") + { + value = p->value(); + } + } + else + { + return buildConfirmHtml(request, "No confirm code set.", 3, true); + } + + if(value != _confirmCode) + { + return request->redirect("/"); + } + esp_err_t res = buildConfirmHtml(request, "Rebooting to other partition...", 2, true); + waitAndProcess(true, 1000); + esp_ota_set_boot_partition(esp_ota_get_next_update_partition(NULL)); + restartEsp(RestartReason::OTAReboot); + return res; + } + else if (value == "autoupdate") + { + #ifndef NUKI_HUB_UPDATER + return processUpdate(request); + #else + return request->redirect("/"); + #endif + } + else + { + if(!_network->isApOpen()) + { + #ifndef NUKI_HUB_UPDATER + return buildHtml(request); + #else + return buildOtaHtml(request); + #endif + } + #ifndef CONFIG_IDF_TARGET_ESP32H2 + else + { + return buildWifiConnectHtml(request); + } + #endif + } + }); + _psychicServer->on("/post", HTTP_POST, [&](PsychicRequest *request) + { + 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("page")) + { + const PsychicWebParameter* p = request->getParam("page"); + if(p->value() != "") + { + value = p->value(); + } + } + + if (value == "savecfg") + { + String message = ""; + bool restart = processArgs(request, message); + return buildConfirmHtml(request, message, 3, true); + } + #ifndef NUKI_HUB_UPDATER + else if (value == "savegpiocfg") + { + processGpioArgs(request); + esp_err_t res = buildConfirmHtml(request, "Saving GPIO configuration. Restarting.", 3, true); + Log->println(F("Restarting")); + waitAndProcess(true, 1000); + restartEsp(RestartReason::GpioConfigurationUpdated); + return res; + } + else if (value == "unpairlock") + { + return processUnpair(request, false); + } + else if (value == "unpairopener") + { + return processUnpair(request, true); + } + else if (value == "factoryreset") + { + return processFactoryReset(request); + } + else if (value == "import") + { + String message = ""; + bool restart = processImport(request, message); + return buildConfirmHtml(request, message, 3, true); + } + #endif + else + { + if(!_network->isApOpen()) + { + #ifndef NUKI_HUB_UPDATER + return buildHtml(request); + #else + return buildOtaHtml(request); + #endif + } + #ifndef CONFIG_IDF_TARGET_ESP32H2 + else + { + return buildWifiConnectHtml(request); + } + #endif + } }); PsychicUploadHandler *updateHandler = new PsychicUploadHandler(); @@ -823,9 +815,9 @@ esp_err_t WebCfgServer::buildOtaHtml(PsychicRequest *request, bool debug) #else String build_type = "debug"; #endif - response.print("

"); - response.print("

"); - response.print("

"); + response.print("

"); + response.print("

"); + response.print("

"); response.print("

"); response.print("Current version: "); @@ -905,7 +897,8 @@ esp_err_t WebCfgServer::buildOtaHtml(PsychicRequest *request, bool debug) response.print("

Manually update Nuki Hub

"); response.print("

Reboot to Nuki Hub Updater

"); 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("

"); + response.print("
"); + response.print(""); response.print("


"); response.print("

Update Nuki Hub Updater

"); response.print("Select the latest Nuki Hub updater binary to update the Nuki Hub updater"); @@ -916,7 +909,8 @@ esp_err_t WebCfgServer::buildOtaHtml(PsychicRequest *request, bool debug) response.print("
"); response.print("

Reboot to Nuki Hub

"); response.print("Click on the button to reboot to Nuki Hub"); - response.print("

"); + response.print("
"); + response.print(""); response.print("


"); response.print("

Update Nuki Hub

"); response.print("Select the latest Nuki Hub binary to update Nuki Hub"); @@ -3313,11 +3307,11 @@ void WebCfgServer::processGpioArgs(PsychicRequest *request) { int params = request->params(); std::vector pinConfiguration; - + for(int index = 0; index < params; index++) { const PsychicWebParameter* p = request->getParam(index); - + if(p->name() == "RETGPIO") { if(_preferences->getBool(preference_retain_gpio, false) != (p->value() == "1")) @@ -3347,13 +3341,14 @@ esp_err_t WebCfgServer::buildImportExportHtml(PsychicRequest *request) response.beginSend(); buildHtmlHeader(&response); response.print("

Import configuration

"); - response.print("

"); + response.print("
"); + response.print(""); response.print("


"); response.print("
"); response.print("

Export configuration


"); - response.print(""); - response.print("

"); - response.print("

"); + response.print(""); + response.print("

"); + response.print("

"); response.print("
"); return response.endSend(); } @@ -3364,7 +3359,8 @@ esp_err_t WebCfgServer::buildCustomNetworkConfigHtml(PsychicRequest *request) PsychicStreamResponse response(request, "text/html"); response.beginSend(); buildHtmlHeader(&response, header); - response.print("
"); + response.print(""); + response.print(""); response.print("

Custom Ethernet Configuration

"); response.print(""); printDropDown(&response, "NWCUSTPHY", "PHY", String(_preferences->getInt(preference_network_custom_phy)), getNetworkCustomPHYOptions(), ""); @@ -3390,7 +3386,7 @@ esp_err_t WebCfgServer::buildCustomNetworkConfigHtml(PsychicRequest *request) esp_err_t WebCfgServer::buildHtml(PsychicRequest *request) { - String header = ""; + String header = ""; PsychicStreamResponse response(request, "text/html"); response.beginSend(); buildHtmlHeader(&response, header); @@ -3448,40 +3444,40 @@ 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, "/get?page=info", "firmware"); if(_preferences->getBool(preference_check_updates)) { - printParameter(&response, "Latest Firmware", _preferences->getString(preference_latest_version).c_str(), "/ota?", "ota"); + printParameter(&response, "Latest Firmware", _preferences->getString(preference_latest_version).c_str(), "/get?page=ota", "ota"); } response.print("

"); response.print("
    "); - buildNavigationMenuEntry(&response, "Network Configuration", "/ntwconfig?"); - buildNavigationMenuEntry(&response, "MQTT Configuration", "/mqttconfig?", _brokerConfigured ? "" : "Please configure MQTT broker"); - buildNavigationMenuEntry(&response, "Nuki Configuration", "/nukicfg?"); - buildNavigationMenuEntry(&response, "Access Level Configuration", "/acclvl?"); - buildNavigationMenuEntry(&response, "Credentials", "/cred?", _pinsConfigured ? "" : "Please configure PIN"); - buildNavigationMenuEntry(&response, "GPIO Configuration", "/gpiocfg?"); - buildNavigationMenuEntry(&response, "Firmware update", "/ota?"); - buildNavigationMenuEntry(&response, "Import/Export Configuration", "/impexpcfg?"); + buildNavigationMenuEntry(&response, "Network Configuration", "/get?page=ntwconfig"); + buildNavigationMenuEntry(&response, "MQTT Configuration", "/get?page=mqttconfig", _brokerConfigured ? "" : "Please configure MQTT broker"); + buildNavigationMenuEntry(&response, "Nuki Configuration", "/get?page=nukicfg"); + buildNavigationMenuEntry(&response, "Access Level Configuration", "/get?page=acclvl"); + buildNavigationMenuEntry(&response, "Credentials", "/get?page=cred", _pinsConfigured ? "" : "Please configure PIN"); + buildNavigationMenuEntry(&response, "GPIO Configuration", "/get?page=gpiocfg"); + buildNavigationMenuEntry(&response, "Firmware update", "/get?page=ota"); + buildNavigationMenuEntry(&response, "Import/Export Configuration", "/get?page=impexpcfg"); if(_preferences->getInt(preference_network_hardware, 0) == 11) { - buildNavigationMenuEntry(&response, "Custom Ethernet Configuration", "/custntw?"); + buildNavigationMenuEntry(&response, "Custom Ethernet Configuration", "/get?page=custntw"); } if (_preferences->getBool(preference_publish_debug_info, false)) { - buildNavigationMenuEntry(&response, "Advanced Configuration", "/advanced?"); + buildNavigationMenuEntry(&response, "Advanced Configuration", "/get?page=advanced"); } if(_preferences->getBool(preference_webserial_enabled, false)) { - buildNavigationMenuEntry(&response, "Open Webserial", "/webserial?"); + buildNavigationMenuEntry(&response, "Open Webserial", "/get?page=webserial"); } #ifndef CONFIG_IDF_TARGET_ESP32H2 if(_allowRestartToPortal) { - buildNavigationMenuEntry(&response, "Configure Wi-Fi", "/wifi?"); + buildNavigationMenuEntry(&response, "Configure Wi-Fi", "/get?page=wifi"); } #endif - String rebooturl = "/reboot?CONFIRMTOKEN=" + _confirmCode; + String rebooturl = "/get?page=reboot&CONFIRMTOKEN=" + _confirmCode; buildNavigationMenuEntry(&response, "Reboot Nuki Hub", rebooturl.c_str()); response.print("
"); return response.endSend(); @@ -3492,7 +3488,8 @@ esp_err_t WebCfgServer::buildCredHtml(PsychicRequest *request) PsychicStreamResponse response(request, "text/html"); response.beginSend(); buildHtmlHeader(&response); - response.print(""); + response.print(""); + response.print(""); response.print("

Credentials

"); response.print(""); printInputField(&response, "CREDUSER", "User (# to clear)", _preferences->getString(preference_cred_user).c_str(), 30, "id=\"inputuser\"", false, true); @@ -3503,7 +3500,8 @@ esp_err_t WebCfgServer::buildCredHtml(PsychicRequest *request) response.print(""); if(_nuki != nullptr) { - response.print("

"); + response.print("

"); + response.print(""); response.print("

Nuki Lock PIN

"); response.print("
"); printInputField(&response, "NUKIPIN", "PIN Code (# to clear)", "*", 20, "", true); @@ -3513,7 +3511,8 @@ esp_err_t WebCfgServer::buildCredHtml(PsychicRequest *request) } if(_nukiOpener != nullptr) { - response.print("

"); + response.print("

"); + response.print(""); response.print("

Nuki Opener PIN

"); response.print("
"); printInputField(&response, "NUKIOPPIN", "PIN Code (# to clear)", "*", 20, "", true); @@ -3524,7 +3523,8 @@ esp_err_t WebCfgServer::buildCredHtml(PsychicRequest *request) if(_nuki != nullptr) { response.print("

Unpair Nuki Lock

"); - response.print(""); + response.print(""); + response.print(""); response.print("
"); String message = "Type "; message.concat(_confirmCode); @@ -3536,7 +3536,8 @@ esp_err_t WebCfgServer::buildCredHtml(PsychicRequest *request) if(_nukiOpener != nullptr) { response.print("

Unpair Nuki Opener

"); - response.print(""); + response.print(""); + response.print(""); response.print("
"); String message = "Type "; message.concat(_confirmCode); @@ -3551,7 +3552,8 @@ esp_err_t WebCfgServer::buildCredHtml(PsychicRequest *request) response.print("Optionally will also reset WiFi settings and reopen WiFi manager portal."); #endif response.print(""); - response.print(""); + response.print(""); + response.print(""); response.print("
"); String message = "Type "; message.concat(_confirmCode); @@ -3571,7 +3573,8 @@ esp_err_t WebCfgServer::buildNetworkConfigHtml(PsychicRequest *request) PsychicStreamResponse response(request, "text/html"); response.beginSend(); buildHtmlHeader(&response); - response.print(""); + response.print(""); + response.print(""); response.print("

Network Configuration

"); response.print("
"); printInputField(&response, "HOSTNAME", "Host name", _preferences->getString(preference_hostname).c_str(), 100, ""); @@ -3603,7 +3606,8 @@ esp_err_t WebCfgServer::buildMqttConfigHtml(PsychicRequest *request) PsychicStreamResponse response(request, "text/html"); response.beginSend(); buildHtmlHeader(&response); - response.print(""); + response.print(""); + response.print(""); response.print("

Basic MQTT Configuration

"); response.print("
"); printInputField(&response, "MQTTSERVER", "MQTT Broker", _preferences->getString(preference_mqtt_broker).c_str(), 100, ""); @@ -3648,7 +3652,8 @@ esp_err_t WebCfgServer::buildAdvancedConfigHtml(PsychicRequest *request) PsychicStreamResponse response(request, "text/html"); response.beginSend(); buildHtmlHeader(&response); - response.print(""); + response.print(""); + response.print(""); response.print("

Advanced Configuration

"); response.print("

Warning: Changing these settings can lead to bootloops that might require you to erase the ESP32 and reflash nukihub using USB/serial

"); response.print("
"); @@ -3824,7 +3829,8 @@ esp_err_t WebCfgServer::buildAccLvlHtml(PsychicRequest *request) uint32_t aclPrefs[17]; _preferences->getBytes(preference_acl, &aclPrefs, sizeof(aclPrefs)); - response.print(""); + response.print(""); + response.print(""); response.print(""); response.print("

Nuki General Access Control

"); response.print("
"); @@ -4003,7 +4009,8 @@ esp_err_t WebCfgServer::buildNukiConfigHtml(PsychicRequest *request) PsychicStreamResponse response(request, "text/html"); response.beginSend(); buildHtmlHeader(&response); - response.print(""); + response.print(""); + response.print(""); response.print("

Basic Nuki Configuration

"); response.print("
SettingEnabled
"); printCheckBox(&response, "LOCKENA", "Nuki Lock enabled", _preferences->getBool(preference_lock_enabled), ""); @@ -4045,11 +4052,12 @@ esp_err_t WebCfgServer::buildGpioConfigHtml(PsychicRequest *request) PsychicStreamResponse response(request, "text/html"); response.beginSend(); buildHtmlHeader(&response); - response.print(""); + response.print(""); + response.print(""); response.print("

GPIO Configuration

"); response.print("
"); printCheckBox(&response, "RETGPIO", "Retain Input GPIO MQTT state", _preferences->getBool(preference_retain_gpio, false), ""); - + std::vector> options; String gpiopreselects = "var gpio = []; "; @@ -4099,7 +4107,8 @@ esp_err_t WebCfgServer::buildConfigureWifiHtml(PsychicRequest *request) PsychicStreamResponse response(request, "text/html"); response.beginSend(); buildHtmlHeader(&response); - response.print(""); + response.print(""); + response.print(""); response.print("

Wi-Fi

"); response.print("Click confirm to remove saved WiFi settings and restart ESP into Wi-Fi configuration mode. After restart, connect to ESP access point to reconfigure Wi-Fi.


"); response.print(""); diff --git a/src/main.cpp b/src/main.cpp index 56c0ea2..930cfc9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -534,7 +534,7 @@ void setup() if(!doOta) { psychicServer = new PsychicHttpServer; - psychicServer->config.max_uri_handlers = 40; + psychicServer->config.max_uri_handlers = 10; psychicServer->config.stack_size = HTTPD_TASK_SIZE; psychicServer->listen(80); webCfgServer = new WebCfgServer(network, preferences, network->networkDeviceType() == NetworkDeviceType::WiFi, partitionType, psychicServer); @@ -630,7 +630,7 @@ void setup() if(!doOta && !disableNetwork && (forceEnableWebServer || preferences->getBool(preference_webserver_enabled, true) || preferences->getBool(preference_webserial_enabled, false))) { psychicServer = new PsychicHttpServer; - psychicServer->config.max_uri_handlers = 40; + psychicServer->config.max_uri_handlers = 10; psychicServer->config.stack_size = HTTPD_TASK_SIZE; psychicServer->listen(80);