// WiFiManager & Autoconfig //callback notifying us of the need to save config void saveConfigCallback () { Serial.println("Should save config"); shouldSaveConfig = true; } void setupSpiffs() { //clean FS, for testing //SPIFFS.format(); //read configuration from FS json debugln("mounting FS..."); if (SPIFFS.begin()) { debugln("mounted file system"); if (SPIFFS.exists("/config.json")) { //file exists, reading and loading debugln("reading config file"); File configFile = SPIFFS.open("/config.json", "r"); if (configFile) { debugln("opened config file"); size_t size = configFile.size(); // Allocate a buffer to store contents of the file. std::unique_ptr buf(new char[size]); configFile.readBytes(buf.get(), size); DynamicJsonBuffer jsonBuffer; JsonObject& json = jsonBuffer.parseObject(buf.get()); json.printTo(Serial); if (json.success()) { debugln("\nparsed json"); strcpy(idx_windir, json["idx_windir"]); strcpy(idx_temp, json["idx_temp"]); strcpy(idx_rain, json["idex_rain"]); } else { Serial.println("failed to load json config"); } } } } else { Serial.println("failed to mount FS"); } }