From aed0d1a13eaf9388e81e139b8cda78ce00c03afc Mon Sep 17 00:00:00 2001 From: "Adrian A. Baumann" Date: Fri, 19 Jun 2026 22:49:50 +0200 Subject: [PATCH] Not saving to flash anymore (flash wear prevention) --- src/main.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index ab24ae9..2fb7c0c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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; ledcWrite(idx, constrain((int)(pct * 1023), 0, 1023)); } - saveConfig(); mqttPublishCurrent(idx); } } @@ -401,14 +400,14 @@ static void handleRoot() { String hostVal = escHtml(mqttCfg.host); String userVal = escHtml(mqttCfg.user); - String passVal = escHtml(mqttCfg.pass); String prefVal = escHtml(mqttCfg.prefix); + const char* passHint = strlen(mqttCfg.pass) > 0 ? "set — leave blank to keep" : "enter password"; mqttSection += "
" "
" "
" - "
" + "
" "
"; mqttSection += ""; } @@ -485,7 +484,7 @@ static void handleConfig() { mqttCfg.port = server.arg("mqtt_port").toInt(); if (server.hasArg("mqtt_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)); if (server.hasArg("mqtt_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); ledcWrite(idx, duty); } - saveConfig(); mqttPublishCurrent(idx); server.send(200); }