Not saving to flash anymore (flash wear prevention)

This commit is contained in:
2026-06-19 22:49:50 +02:00
parent 36a638230f
commit aed0d1a13e
+3 -5
View File
@@ -189,7 +189,6 @@ static void mqttCallback(char* topic, byte* payload, unsigned int len) {
float pct = meters[idx].currentValue / 100.0f * meters[idx].maxDuty / 100.0f; float pct = meters[idx].currentValue / 100.0f * meters[idx].maxDuty / 100.0f;
ledcWrite(idx, constrain((int)(pct * 1023), 0, 1023)); ledcWrite(idx, constrain((int)(pct * 1023), 0, 1023));
} }
saveConfig();
mqttPublishCurrent(idx); mqttPublishCurrent(idx);
} }
} }
@@ -401,14 +400,14 @@ static void handleRoot() {
String hostVal = escHtml(mqttCfg.host); String hostVal = escHtml(mqttCfg.host);
String userVal = escHtml(mqttCfg.user); String userVal = escHtml(mqttCfg.user);
String passVal = escHtml(mqttCfg.pass);
String prefVal = escHtml(mqttCfg.prefix); String prefVal = escHtml(mqttCfg.prefix);
const char* passHint = strlen(mqttCfg.pass) > 0 ? "set — leave blank to keep" : "enter password";
mqttSection += mqttSection +=
"<div class=row><label>Broker</label><input name=mqtt_host value='" + hostVal + "'></div>" "<div class=row><label>Broker</label><input name=mqtt_host value='" + hostVal + "'></div>"
"<div class=row><label>Port</label><input name=mqtt_port type=number value=" + String(portStr) + "></div>" "<div class=row><label>Port</label><input name=mqtt_port type=number value=" + String(portStr) + "></div>"
"<div class=row><label>User</label><input name=mqtt_user value='" + userVal + "'></div>" "<div class=row><label>User</label><input name=mqtt_user value='" + userVal + "'></div>"
"<div class=row><label>Pass</label><input name=mqtt_pass type=password value='" + passVal + "'></div>" "<div class=row><label>Pass</label><input name=mqtt_pass type=password placeholder='" + String(passHint) + "'></div>"
"<div class=row><label>Prefix</label><input name=mqtt_prefix value='" + prefVal + "'></div>"; "<div class=row><label>Prefix</label><input name=mqtt_prefix value='" + prefVal + "'></div>";
mqttSection += "</fieldset>"; mqttSection += "</fieldset>";
} }
@@ -485,7 +484,7 @@ static void handleConfig() {
mqttCfg.port = server.arg("mqtt_port").toInt(); mqttCfg.port = server.arg("mqtt_port").toInt();
if (server.hasArg("mqtt_user")) if (server.hasArg("mqtt_user"))
strlcpy(mqttCfg.user, server.arg("mqtt_user").c_str(), sizeof(mqttCfg.user)); strlcpy(mqttCfg.user, server.arg("mqtt_user").c_str(), sizeof(mqttCfg.user));
if (server.hasArg("mqtt_pass")) if (server.hasArg("mqtt_pass") && server.arg("mqtt_pass").length() > 0)
strlcpy(mqttCfg.pass, server.arg("mqtt_pass").c_str(), sizeof(mqttCfg.pass)); strlcpy(mqttCfg.pass, server.arg("mqtt_pass").c_str(), sizeof(mqttCfg.pass));
if (server.hasArg("mqtt_prefix")) if (server.hasArg("mqtt_prefix"))
strlcpy(mqttCfg.prefix, server.arg("mqtt_prefix").c_str(), sizeof(mqttCfg.prefix)); strlcpy(mqttCfg.prefix, server.arg("mqtt_prefix").c_str(), sizeof(mqttCfg.prefix));
@@ -548,7 +547,6 @@ static void handleSet() {
int duty = constrain((int)(pct * 1023), 0, 1023); int duty = constrain((int)(pct * 1023), 0, 1023);
ledcWrite(idx, duty); ledcWrite(idx, duty);
} }
saveConfig();
mqttPublishCurrent(idx); mqttPublishCurrent(idx);
server.send(200); server.send(200);
} }