bugfix: prevent preset loading from resetting other errors

without this fix, any not-yet reported error - like filesystem problems at startup, or out-of-memory - was rest by successfully loading a preset.
This commit is contained in:
Frank 2024-10-19 18:43:10 +02:00
parent e9d2182390
commit 0a97e28aab

View File

@ -143,6 +143,7 @@ void applyPresetWithFallback(uint8_t index, uint8_t callMode, uint8_t effectID,
void handlePresets() void handlePresets()
{ {
byte presetErrFlag = ERR_NONE;
if (presetToSave) { if (presetToSave) {
strip.suspend(); strip.suspend();
doSaveState(); doSaveState();
@ -166,14 +167,16 @@ void handlePresets()
#ifdef ARDUINO_ARCH_ESP32 #ifdef ARDUINO_ARCH_ESP32
if (tmpPreset==255 && tmpRAMbuffer!=nullptr) { if (tmpPreset==255 && tmpRAMbuffer!=nullptr) {
deserializeJson(*pDoc,tmpRAMbuffer); deserializeJson(*pDoc,tmpRAMbuffer);
errorFlag = ERR_NONE;
} else } else
#endif #endif
{ {
errorFlag = readObjectFromFileUsingId(getPresetsFileName(tmpPreset < 255), tmpPreset, pDoc) ? ERR_NONE : ERR_FS_PLOAD; presetErrFlag = readObjectFromFileUsingId(getPresetsFileName(tmpPreset < 255), tmpPreset, pDoc) ? ERR_NONE : ERR_FS_PLOAD;
} }
fdo = pDoc->as<JsonObject>(); fdo = pDoc->as<JsonObject>();
// only reset errorflag if previous error was preset-related
if ((errorFlag == ERR_NONE) || (errorFlag == ERR_FS_PLOAD)) errorFlag = presetErrFlag;
//HTTP API commands //HTTP API commands
const char* httpwin = fdo["win"]; const char* httpwin = fdo["win"];
if (httpwin) { if (httpwin) {