Hello pert,
thank you for moving the question to the right forum.
I was unsecure where to post it.
OK I'm using Arduino IDE 1.8.12
I have installed the IniFile-file library (which supports SD-cart inside)
And I have installed the SPIFFSIniFile-library
If I do a plain copy&paste of the sourcecode given in the example
/*
Remeber to upload the data directory to your board!
Serial baud rate in this example is 9600
*/
#include "FS.h"
#include <SPIFFSIniFile.h>
void printErrorMessage(uint8_t e, bool eol = true)
{
switch (e) {
case SPIFFSIniFile::errorNoError:
Serial.print("no error");
break;
case SPIFFSIniFile::errorFileNotFound:
Serial.print("file not found");
break;
case SPIFFSIniFile::errorFileNotOpen:
Serial.print("file not open");
break;
case SPIFFSIniFile::errorBufferTooSmall:
Serial.print("buffer too small");
break;
case SPIFFSIniFile::errorSeekError:
Serial.print("seek error");
break;
case SPIFFSIniFile::errorSectionNotFound:
Serial.print("section not found");
break;
case SPIFFSIniFile::errorKeyNotFound:
Serial.print("key not found");
break;
case SPIFFSIniFile::errorEndOfFile:
Serial.print("end of file");
break;
case SPIFFSIniFile::errorUnknownError:
Serial.print("unknown error");
break;
default:
Serial.print("unknown error value");
break;
}
if (eol)
Serial.println();
}
void setup()
{
const size_t bufferLen = 80;
char buffer[bufferLen];
const char *filename = "/net.ini";
Serial.begin(9600);
//Mount the SPIFFS
if (!SPIFFS.begin())
while (1)
Serial.println("SPIFFS.begin() failed");
SPIFFSIniFile ini(filename);
if (!ini.open()) {
Serial.print("Ini file ");
Serial.print(filename);
Serial.println(" does not exist");
// Cannot do anything else
while (1)
;
}
Serial.println("Ini file exists");
// Check the file is valid. This can be used to warn if any lines
// are longer than the buffer.
if (!ini.validate(buffer, bufferLen)) {
Serial.print("ini file ");
Serial.print(ini.getFilename());
Serial.print(" not valid: ");
printErrorMessage(ini.getError());
// Cannot do anything else
while (1)
;
}
// Fetch a value from a key which is present
if (ini.getValue("network", "mac", buffer, bufferLen)) {
Serial.print("section 'network' has an entry 'mac' with value ");
Serial.println(buffer);
}
else {
Serial.print("Could not read 'mac' from section 'network', error was ");
printErrorMessage(ini.getError());
}
// Try fetching a value from a missing key (but section is present)
if (ini.getValue("network", "nosuchkey", buffer, bufferLen)) {
Serial.print("section 'network' has an entry 'nosuchkey' with value ");
Serial.println(buffer);
}
else {
Serial.print("Could not read 'nosuchkey' from section 'network', error was ");
printErrorMessage(ini.getError());
}
// Try fetching a key from a section which is not present
if (ini.getValue("nosuchsection", "nosuchkey", buffer, bufferLen)) {
Serial.print("section 'nosuchsection' has an entry 'nosuchkey' with value ");
Serial.println(buffer);
}
else {
Serial.print("Could not read 'nosuchkey' from section 'nosuchsection', error was ");
printErrorMessage(ini.getError());
}
// Fetch a boolean value
bool allowPut; // variable where result will be stored
bool found = ini.getValue("/upload", "allow put", buffer, bufferLen, allowPut);
if (found) {
Serial.print("The value of 'allow put' in section '/upload' is ");
// Print value, converting boolean to a string
Serial.println(allowPut ? "TRUE" : "FALSE");
}
else {
Serial.print("Could not get the value of 'allow put' in section '/upload': ");
printErrorMessage(ini.getError());
}
}
void loop()
{
}
I get these error-messages:
In file included from C:\Users\Stefan\Documents\Arduino\Original-SPIFFS-Ini-Demo\Original-SPIFFS-Ini-Demo.ino:9:0:
C:\Users\Stefan\Documents\Arduino\libraries\SPIFFSIniFile\src/SPIFFSIniFile.h:31:51: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
SPIFFSIniFile(const char* filename, char* mode = "r",
C:\Users\Stefan\Documents\Arduino\libraries\SPIFFSIniFile\src/SPIFFSIniFile.h: In member function 'bool SPIFFSIniFile::open()':
C:\Users\Stefan\Documents\Arduino\libraries\SPIFFSIniFile\src/SPIFFSIniFile.h:130:10: error: 'SPIFFS' was not declared in this scope
_file = SPIFFS.open(_filename, _mode);
C:\Users\Stefan\Documents\Arduino\Original-SPIFFS-Ini-Demo\Original-SPIFFS-Ini-Demo.ino: In function 'void setup()':
Original-SPIFFS-Ini-Demo:59:8: error: 'SPIFFS' was not declared in this scope
if (!SPIFFS.begin())
C:\Users\Stefan\Documents\Arduino\Original-SPIFFS-Ini-Demo\Original-SPIFFS-Ini-Demo.ino:63:29: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
SPIFFSIniFile ini(filename);
Bibliothek FS in Version 1.0 im Ordner: C:\Users\Stefan\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\FS wird verwendet
Bibliothek SPIFFSIniFile in Version 1.0.0 im Ordner: C:\Users\Stefan\Documents\Arduino\libraries\SPIFFSIniFile wird verwendet
exit status 1
'SPIFFS' was not declared in this scope
guys what the hell did the author tweak and screw up his Arduino-IDE to make such a code compiling?
OK any help would be much appreciciated.
best regards
Stefan