add /info endpoint to publish preference content

This commit is contained in:
technyon
2023-02-05 12:11:10 +01:00
parent 327038119e
commit 2094595e78
7 changed files with 149 additions and 1 deletions

View File

@@ -159,6 +159,14 @@ void WebCfgServer::initialize()
handleOtaUpload();
});
_server.on("/info", [&]() {
if (_hasCredentials && !_server.authenticate(_credUser, _credPassword)) {
return _server.requestAuthentication();
}
String response = "";
buildInfoHtml(response);
_server.send(200, "text/html", response);
});
_server.begin();
@@ -698,6 +706,22 @@ void WebCfgServer::buildConfigureWifiHtml(String &response)
response.concat("</BODY></HTML>");
}
void WebCfgServer::buildInfoHtml(String &response)
{
DebugPreferences debugPreferences;
buildHtmlHeader(response);
response.concat("<h3>Info</h3> <pre>");
response.concat(debugPreferences.preferencesToString(_preferences));
response.concat("Lock PIN set: ");
response.concat(_nuki->isPinSet() ? "Yes\n" : "No\n");
response.concat("Opener PIN set: ");
response.concat(_nukiOpener->isPinSet() ? "Yes\n" : "No\n");
response.concat("</pre> </BODY></HTML>");
}
void WebCfgServer::processUnpair(bool opener)
{
String response = "";
@@ -981,4 +1005,4 @@ const std::vector<std::pair<String, String>> WebCfgServer::getNetworkGpioOptions
}
return options;
}
}