sblantipodi / arduino_bootstrapper

Utility classes for bootstrapping Arduino projects with Wifi management, OTA upload management, memory management, MQTT and queue management. (ESP8266/ESP32 ready)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

BootstrapManager::readSPIFFS: missing jsonDoc initialization and configFile.close

Pronoe opened this issue · comments

Hello,
Instruction DynamicJsonDocument jsonDoc(1024); and configFile.close();are missing in readSPIFFS but are part of readLittleFS function.
This was mentioned in issue #12 but not identified as the root cause of this issue.
During testing of the release 1.12.6 with an ESP32, reading a SPIFFS file leads in one occasion to deserialization errors and these missing instructions might be the cause.
These missing instructions should preferably be included in a future version.

Extract of locally modified code:

// read json file from storage
#if defined(ESP32)
DynamicJsonDocument BootstrapManager::readSPIFFS(String filename)
{

  // Helpers classes
  Helpers helper;
  DynamicJsonDocument jsonDoc(1024); // added by Pronoe on 02/03/2022

and

        DeserializationError deserializeError = deserializeJson(jsonDoc, (const char *)buf.get());
        Serial.println("\nReading " + filename);
        if (filename != "setup.json")
          serializeJsonPretty(jsonDoc, Serial);
        
        configFile.close();   // added by Pronoe on 02/03/2022
        if (!deserializeError)
        {
          helper.smartPrintln(F("JSON parsed"));
        }

I fixed something on 1.2.7 but it still lack some of the parts you pointed out.
waiting for the pull request 👍