Skip to content

Commit b4b80ae

Browse files
committed
Fixed the example to work with SPIFFS
1 parent 7b5b465 commit b4b80ae

File tree

3 files changed

+21
-58
lines changed

3 files changed

+21
-58
lines changed

examples/IniFileExample/README.md

Lines changed: 0 additions & 29 deletions
This file was deleted.

examples/IniFileExample/IniFileExample.ino renamed to examples/SPIFFSIniFileExample/SPIFFSIniFileExample.ino

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,41 @@
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+
*/
26

3-
#include <SPI.h>
4-
#include <IPAddress.h>
5-
#include <IniFile.h>
7+
#include "FS.h"
68

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>
1110

1211
void printErrorMessage(uint8_t e, bool eol = true)
1312
{
1413
switch (e) {
15-
case IniFile::errorNoError:
14+
case SPIFFSIniFile::errorNoError:
1615
Serial.print("no error");
1716
break;
18-
case IniFile::errorFileNotFound:
17+
case SPIFFSIniFile::errorFileNotFound:
1918
Serial.print("file not found");
2019
break;
21-
case IniFile::errorFileNotOpen:
20+
case SPIFFSIniFile::errorFileNotOpen:
2221
Serial.print("file not open");
2322
break;
24-
case IniFile::errorBufferTooSmall:
23+
case SPIFFSIniFile::errorBufferTooSmall:
2524
Serial.print("buffer too small");
2625
break;
27-
case IniFile::errorSeekError:
26+
case SPIFFSIniFile::errorSeekError:
2827
Serial.print("seek error");
2928
break;
30-
case IniFile::errorSectionNotFound:
29+
case SPIFFSIniFile::errorSectionNotFound:
3130
Serial.print("section not found");
3231
break;
33-
case IniFile::errorKeyNotFound:
32+
case SPIFFSIniFile::errorKeyNotFound:
3433
Serial.print("key not found");
3534
break;
36-
case IniFile::errorEndOfFile:
35+
case SPIFFSIniFile::errorEndOfFile:
3736
Serial.print("end of file");
3837
break;
39-
case IniFile::errorUnknownError:
38+
case SPIFFSIniFile::errorUnknownError:
4039
Serial.print("unknown error");
4140
break;
4241
default:
@@ -49,26 +48,19 @@ void printErrorMessage(uint8_t e, bool eol = true)
4948

5049
void setup()
5150
{
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
5751

58-
pinMode(ETHERNET_SELECT, OUTPUT);
59-
digitalWrite(ETHERNET_SELECT, HIGH); // disable Ethernet
60-
6152
const size_t bufferLen = 80;
6253
char buffer[bufferLen];
6354

6455
const char *filename = "/net.ini";
6556
Serial.begin(9600);
66-
SPI.begin();
67-
if (!SD.begin(SD_SELECT))
57+
58+
//Mount the SPIFFS
59+
if (!SPIFFS.begin())
6860
while (1)
69-
Serial.println("SD.begin() failed");
61+
Serial.println("SPIFFS.begin() failed");
7062

71-
IniFile ini(filename);
63+
SPIFFSIniFile ini(filename);
7264
if (!ini.open()) {
7365
Serial.print("Ini file ");
7466
Serial.print(filename);

0 commit comments

Comments
 (0)