allow configure mqtt broker port via web server

This commit is contained in:
technyon
2022-03-27 12:21:53 +02:00
parent a8ce3fc44c
commit 3eaaab0c66
4 changed files with 29 additions and 5 deletions

View File

@@ -66,6 +66,11 @@ void WebCfgServer::update()
_preferences->putString(preference_mqtt_broker, token);
configChanged = true;
}
else if(lastTokenType == TokenType::MqttPort && tokenType == TokenType::None)
{
_preferences->putInt(preference_mqtt_broker_port, String(token).toInt());
configChanged = true;
}
else if(lastTokenType == TokenType::QueryIntervalLockstate && tokenType == TokenType::None)
{
_preferences->putInt(preference_query_interval_lockstate, String(token).toInt());
@@ -109,10 +114,14 @@ void WebCfgServer::serveHtml(WiFiClient &client)
client.println("<FORM ACTION=method=get >");
client.print("MQTT Server: <INPUT TYPE=TEXT VALUE=\"");
client.print("MQTT Broker: <INPUT TYPE=TEXT VALUE=\"");
client.print(_preferences->getString(preference_mqtt_broker));
client.println("\" NAME=\"MQTTSERVER\" SIZE=\"25\" MAXLENGTH=\"40\"><BR>");
client.print("MQTT Broker port: <INPUT TYPE=TEXT VALUE=\"");
client.print(_preferences->getInt(preference_mqtt_broker_port));
client.println("\" NAME=\"MQTTPORT\" SIZE=\"25\" MAXLENGTH=\"40\"><BR>");
client.print("Query interval lock state (seconds): <INPUT TYPE=TEXT VALUE=\"");
client.print(_preferences->getInt(preference_query_interval_lockstate));
client.println("\" NAME=\"LSTINT\" SIZE=\"25\" MAXLENGTH=\"16\"><BR>");
@@ -145,6 +154,10 @@ TokenType WebCfgServer::getParameterType(char *&token)
{
return TokenType::QueryIntervalBattery;
}
if (strcmp(token, "MQTTPORT") == 0)
{
return TokenType::MqttPort;
}
return TokenType::None;
}