Add Webserial (#444)

* Webserial

* Webserial
This commit is contained in:
iranl
2024-08-09 11:35:42 +02:00
committed by GitHub
parent 44b5f71b40
commit 43ac62a22d
86 changed files with 1846 additions and 1192 deletions

View File

@@ -299,6 +299,10 @@ void WebCfgServer::initialize()
waitAndProcess(true, 1000);
restartEsp(RestartReason::ConfigurationUpdated);
});
_server.on("/webserial", [&]() {
_server.sendHeader("Location", (String)"http://" + _network->localIP() + ":81/webserial");
_server.send(302, "text/plain", "");
});
#endif
_server.on("/ota", [&]() {
if (_hasCredentials && !_server.authenticate(_credUser, _credPassword)) {
@@ -1026,6 +1030,11 @@ bool WebCfgServer::processArgs(String& message)
_preferences->putBool(preference_mqtt_log_enabled, (value == "1"));
configChanged = true;
}
else if(key == "WEBLOG")
{
_preferences->putBool(preference_webserial_enabled, (value == "1"));
configChanged = true;
}
else if(key == "CHECKUPDATE")
{
_preferences->putBool(preference_check_updates, (value == "1"));
@@ -2061,6 +2070,11 @@ void WebCfgServer::buildHtml(String& response)
{
buildNavigationMenuEntry(response, "Advanced Configuration", "/advanced");
}
if(_preferences->getBool(preference_webserial_enabled, false))
{
buildNavigationMenuEntry(response, "Open Webserial", "/webserial");
}
if(_allowRestartToPortal)
{
@@ -2177,6 +2191,7 @@ void WebCfgServer::buildMqttConfigHtml(String &response)
printCheckBox(response, "RSTDISC", "Restart on disconnect", _preferences->getBool(preference_restart_on_disconnect), "");
printCheckBox(response, "RECNWTMQTTDIS", "Reconnect network on MQTT connection failure", _preferences->getBool(preference_recon_netw_on_mqtt_discon), "");
printCheckBox(response, "MQTTLOG", "Enable MQTT logging", _preferences->getBool(preference_mqtt_log_enabled), "");
printCheckBox(response, "WEBLOG", "Enable WebSerial logging", _preferences->getBool(preference_webserial_enabled), "");
printCheckBox(response, "CHECKUPDATE", "Check for Firmware Updates every 24h", _preferences->getBool(preference_check_updates), "");
printCheckBox(response, "UPDATEMQTT", "Allow updating using MQTT", _preferences->getBool(preference_update_from_mqtt), "");
printCheckBox(response, "DISNONJSON", "Disable some extraneous non-JSON topics", _preferences->getBool(preference_disable_non_json), "");