Skip to content

Commit 5bfaa57

Browse files
author
Thorsten Ludewig
committed
format uninitialized littlefs
1 parent 729f028 commit 5bfaa57

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

lib/App/App.cpp

+23
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
#include <WebHandler.hpp>
1313
#include <Util.hpp>
1414

15+
#include <FS.h>
16+
#include <LittleFS.h>
17+
1518
time_t appStartTime = 0l;
1619
char appUptimeBuffer[64];
1720

@@ -71,6 +74,26 @@ void appSetup()
7174

7275
Serial.println();
7376

77+
if(LittleFS.begin())
78+
{
79+
if ( !LittleFS.exists( APP_CONFIG_FILE ))
80+
{
81+
LOG0( "Config-File <" APP_CONFIG_FILE "> not exists.\n" );
82+
LOG0( "Formatting LittleFS... " );
83+
LittleFS.format();
84+
Serial.println( "done.\n");
85+
File config = LittleFS.open( APP_CONFIG_FILE, "w" );
86+
config.write(0);
87+
config.close();
88+
}
89+
else
90+
{
91+
LOG0( "Config-File <" APP_CONFIG_FILE "> found.\n\n" );
92+
}
93+
94+
LittleFS.end();
95+
}
96+
7497
showChipInfo();
7598

7699
configTime( TIMEZONE, NTP_SERVER1, NTP_SERVER2, NTP_SERVER3 );

0 commit comments

Comments
 (0)