1
- #include < SD.h>
1
+ /*
2
+ Remeber to upload the data directory to your board!
3
+
4
+ Serial baud rate in this example is 9600
5
+ */
2
6
3
- #include < SPI.h>
4
- #include < IPAddress.h>
5
- #include < IniFile.h>
7
+ #include " FS.h"
6
8
7
- // The select pin used for the SD card
8
- // #define SD_SELECT 4
9
- #define SD_SELECT 22
10
- #define ETHERNET_SELECT 10
9
+ #include < SPIFFSIniFile.h>
11
10
12
11
void printErrorMessage (uint8_t e, bool eol = true )
13
12
{
14
13
switch (e) {
15
- case IniFile ::errorNoError:
14
+ case SPIFFSIniFile ::errorNoError:
16
15
Serial.print (" no error" );
17
16
break ;
18
- case IniFile ::errorFileNotFound:
17
+ case SPIFFSIniFile ::errorFileNotFound:
19
18
Serial.print (" file not found" );
20
19
break ;
21
- case IniFile ::errorFileNotOpen:
20
+ case SPIFFSIniFile ::errorFileNotOpen:
22
21
Serial.print (" file not open" );
23
22
break ;
24
- case IniFile ::errorBufferTooSmall:
23
+ case SPIFFSIniFile ::errorBufferTooSmall:
25
24
Serial.print (" buffer too small" );
26
25
break ;
27
- case IniFile ::errorSeekError:
26
+ case SPIFFSIniFile ::errorSeekError:
28
27
Serial.print (" seek error" );
29
28
break ;
30
- case IniFile ::errorSectionNotFound:
29
+ case SPIFFSIniFile ::errorSectionNotFound:
31
30
Serial.print (" section not found" );
32
31
break ;
33
- case IniFile ::errorKeyNotFound:
32
+ case SPIFFSIniFile ::errorKeyNotFound:
34
33
Serial.print (" key not found" );
35
34
break ;
36
- case IniFile ::errorEndOfFile:
35
+ case SPIFFSIniFile ::errorEndOfFile:
37
36
Serial.print (" end of file" );
38
37
break ;
39
- case IniFile ::errorUnknownError:
38
+ case SPIFFSIniFile ::errorUnknownError:
40
39
Serial.print (" unknown error" );
41
40
break ;
42
41
default :
@@ -49,26 +48,19 @@ void printErrorMessage(uint8_t e, bool eol = true)
49
48
50
49
void setup ()
51
50
{
52
- // Configure all of the SPI select pins as outputs and make SPI
53
- // devices inactive, otherwise the earlier init routines may fail
54
- // for devices which have not yet been configured.
55
- pinMode (SD_SELECT, OUTPUT);
56
- digitalWrite (SD_SELECT, HIGH); // disable SD card
57
51
58
- pinMode (ETHERNET_SELECT, OUTPUT);
59
- digitalWrite (ETHERNET_SELECT, HIGH); // disable Ethernet
60
-
61
52
const size_t bufferLen = 80 ;
62
53
char buffer[bufferLen];
63
54
64
55
const char *filename = " /net.ini" ;
65
56
Serial.begin (9600 );
66
- SPI.begin ();
67
- if (!SD.begin (SD_SELECT))
57
+
58
+ // Mount the SPIFFS
59
+ if (!SPIFFS.begin ())
68
60
while (1 )
69
- Serial.println (" SD .begin() failed" );
61
+ Serial.println (" SPIFFS .begin() failed" );
70
62
71
- IniFile ini (filename);
63
+ SPIFFSIniFile ini (filename);
72
64
if (!ini.open ()) {
73
65
Serial.print (" Ini file " );
74
66
Serial.print (filename);
0 commit comments