-
-
Notifications
You must be signed in to change notification settings - Fork 324
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Note: the configuration will be wiped and needs to be reconfigured afterwards! SPIFFS is replaced in favor of LittleFS being its successor.
- Loading branch information
1 parent
34c4e55
commit d1deba4
Showing
3 changed files
with
66 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ All rights reserverd by S.Lang <[email protected]> | |
#include "DallasTemperature.h" | ||
#include "DoubleResetDetector.h" // https://github.com/datacute/DoubleResetDetector | ||
#include "RunningMedian.h" | ||
#include "Sender.h" | ||
#include "WiFiManagerKT.h" | ||
#include "secrets.h" //AWS - Currently a file for Keys, Certs, etc - Need to make this a captured variable for iSpindle | ||
#include "tinyexpr.h" | ||
|
@@ -24,8 +25,7 @@ All rights reserverd by S.Lang <[email protected]> | |
#include <ESP8266WebServer.h> | ||
#include <ESP8266WiFi.h> //https://github.com/esp8266/Arduino | ||
#include <FS.h> //this needs to be first | ||
|
||
#include "Sender.h" | ||
#include <LittleFS.h> | ||
// !DEBUG 1 | ||
|
||
// definitions go here | ||
|
@@ -152,15 +152,15 @@ bool readConfig() | |
{ | ||
CONSOLE(F("mounting FS...")); | ||
|
||
if (!SPIFFS.begin()) | ||
if (!LittleFS.begin()) | ||
{ | ||
CONSOLELN(F(" ERROR: failed to mount FS!")); | ||
return false; | ||
} | ||
else | ||
{ | ||
CONSOLELN(F(" mounted!")); | ||
if (!SPIFFS.exists(CFGFILE)) | ||
if (!LittleFS.exists(CFGFILE)) | ||
{ | ||
CONSOLELN(F("ERROR: failed to load json config")); | ||
return false; | ||
|
@@ -169,7 +169,7 @@ bool readConfig() | |
{ | ||
// file exists, reading and loading | ||
CONSOLELN(F("reading config file")); | ||
File configFile = SPIFFS.open(CFGFILE, "r"); | ||
File configFile = LittleFS.open(CFGFILE, "r"); | ||
if (!configFile) | ||
{ | ||
CONSOLELN(F("ERROR: unable to open config file")); | ||
|
@@ -476,13 +476,13 @@ bool startConfiguration() | |
return false; | ||
} | ||
|
||
bool formatSpiffs() | ||
bool formatLittleFS() | ||
{ | ||
CONSOLE(F("\nneed to format SPIFFS: ")); | ||
SPIFFS.end(); | ||
SPIFFS.begin(); | ||
CONSOLELN(SPIFFS.format()); | ||
return SPIFFS.begin(); | ||
CONSOLE(F("\nneed to format LittleFS: ")); | ||
LittleFS.end(); | ||
LittleFS.begin(); | ||
CONSOLELN(LittleFS.format()); | ||
return LittleFS.begin(); | ||
} | ||
|
||
bool saveConfig(int16_t Offset[6]) | ||
|
@@ -499,11 +499,11 @@ bool saveConfig() | |
{ | ||
CONSOLE(F("saving config...\n")); | ||
|
||
// if SPIFFS is not usable | ||
if (!SPIFFS.begin()) | ||
// if LittleFS is not usable | ||
if (!LittleFS.begin()) | ||
{ | ||
Serial.println("Failed to mount file system"); | ||
if (!formatSpiffs()) | ||
if (!formatLittleFS()) | ||
{ | ||
Serial.println("Failed to format file system - hardware issues!"); | ||
return false; | ||
|
@@ -543,11 +543,11 @@ bool saveConfig() | |
array.add(i); | ||
} | ||
|
||
File configFile = SPIFFS.open(CFGFILE, "w"); | ||
File configFile = LittleFS.open(CFGFILE, "w"); | ||
if (!configFile) | ||
{ | ||
CONSOLELN(F("failed to open config file for writing")); | ||
SPIFFS.end(); | ||
LittleFS.end(); | ||
return false; | ||
} | ||
else | ||
|
@@ -558,8 +558,8 @@ bool saveConfig() | |
#endif | ||
configFile.flush(); | ||
configFile.close(); | ||
SPIFFS.gc(); | ||
SPIFFS.end(); | ||
LittleFS.gc(); | ||
LittleFS.end(); | ||
CONSOLELN(F("\nsaved successfully")); | ||
return true; | ||
} | ||
|