Skip to content

Commit

Permalink
Fixed the example to work with SPIFFS
Browse files Browse the repository at this point in the history
  • Loading branch information
yurilopes committed Feb 17, 2019
1 parent 7b5b465 commit b4b80ae
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 58 deletions.
29 changes: 0 additions & 29 deletions examples/IniFileExample/README.md

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,42 +1,41 @@
#include <SD.h>
/*
Remeber to upload the data directory to your board!
Serial baud rate in this example is 9600
*/

#include <SPI.h>
#include <IPAddress.h>
#include <IniFile.h>
#include "FS.h"

// The select pin used for the SD card
//#define SD_SELECT 4
#define SD_SELECT 22
#define ETHERNET_SELECT 10
#include <SPIFFSIniFile.h>

void printErrorMessage(uint8_t e, bool eol = true)
{
switch (e) {
case IniFile::errorNoError:
case SPIFFSIniFile::errorNoError:
Serial.print("no error");
break;
case IniFile::errorFileNotFound:
case SPIFFSIniFile::errorFileNotFound:
Serial.print("file not found");
break;
case IniFile::errorFileNotOpen:
case SPIFFSIniFile::errorFileNotOpen:
Serial.print("file not open");
break;
case IniFile::errorBufferTooSmall:
case SPIFFSIniFile::errorBufferTooSmall:
Serial.print("buffer too small");
break;
case IniFile::errorSeekError:
case SPIFFSIniFile::errorSeekError:
Serial.print("seek error");
break;
case IniFile::errorSectionNotFound:
case SPIFFSIniFile::errorSectionNotFound:
Serial.print("section not found");
break;
case IniFile::errorKeyNotFound:
case SPIFFSIniFile::errorKeyNotFound:
Serial.print("key not found");
break;
case IniFile::errorEndOfFile:
case SPIFFSIniFile::errorEndOfFile:
Serial.print("end of file");
break;
case IniFile::errorUnknownError:
case SPIFFSIniFile::errorUnknownError:
Serial.print("unknown error");
break;
default:
Expand All @@ -49,26 +48,19 @@ void printErrorMessage(uint8_t e, bool eol = true)

void setup()
{
// Configure all of the SPI select pins as outputs and make SPI
// devices inactive, otherwise the earlier init routines may fail
// for devices which have not yet been configured.
pinMode(SD_SELECT, OUTPUT);
digitalWrite(SD_SELECT, HIGH); // disable SD card

pinMode(ETHERNET_SELECT, OUTPUT);
digitalWrite(ETHERNET_SELECT, HIGH); // disable Ethernet

const size_t bufferLen = 80;
char buffer[bufferLen];

const char *filename = "/net.ini";
Serial.begin(9600);
SPI.begin();
if (!SD.begin(SD_SELECT))

//Mount the SPIFFS
if (!SPIFFS.begin())
while (1)
Serial.println("SD.begin() failed");
Serial.println("SPIFFS.begin() failed");

IniFile ini(filename);
SPIFFSIniFile ini(filename);
if (!ini.open()) {
Serial.print("Ini file ");
Serial.print(filename);
Expand Down
File renamed without changes.

0 comments on commit b4b80ae

Please sign in to comment.