Skip to content

Commit d7d3be5

Browse files
committed
Display spiffs storage details
1 parent 1872e84 commit d7d3be5

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ A simple ESP32 Based RFID Access Control System for tools or door.
114114
- Create a generic shipMetric(String metricname, String metricvalue) function rather than individual ship* functions. Why: Too messy.
115115

116116
## Done
117+
- Display spiffs storage details
117118
- Web Admin: Scan i2c devices and print out
118119
- Merge /backlighton and /backlightoff into /backlight?state=on/off
119120
- If no settings file, set default from defaults.h

eeh-esp32-rfid.ino

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
// file upload progress based upon https://codepen.io/PerfectIsShit/pen/zogMXP
2626
// wifi scanning based upon https://github.com/me-no-dev/ESPAsyncWebServer#scanning-for-available-wifi-networks
2727

28-
#define FIRMWARE_VERSION "v1.7.6-ota"
28+
#define FIRMWARE_VERSION "v1.7.7-ota"
2929

3030
// configuration structure
3131
struct Config {
@@ -156,6 +156,10 @@ void setup() {
156156
SPIFFS.remove(filename);
157157
}
158158

159+
Serial.print("SPIFFS Free: "); Serial.println(humanReadableSize((SPIFFS.totalBytes() - SPIFFS.usedBytes())));
160+
Serial.print("SPIFFS Used: "); Serial.println(humanReadableSize(SPIFFS.usedBytes()));
161+
Serial.print("SPIFFS Total: "); Serial.println(humanReadableSize(SPIFFS.totalBytes()));
162+
159163
Serial.println(listFiles());
160164

161165
Serial.println("Loading Configuration ...");
@@ -642,6 +646,9 @@ String getFullStatus() {
642646
fullStatusDoc["TelegrafServer"] = config.telegrafserver;
643647
fullStatusDoc["TelegrafServerPort"] = config.telegrafserverport;
644648
fullStatusDoc["TelegrafShipTime"] = config.telegrafshiptime;
649+
fullStatusDoc["SPIFFSFree"] = (SPIFFS.totalBytes() - SPIFFS.usedBytes());
650+
fullStatusDoc["SPIFFSUsed"] = SPIFFS.usedBytes();
651+
fullStatusDoc["SPIFFSTotal"] = SPIFFS.totalBytes();
645652

646653
String fullStatus = "";
647654
serializeJson(fullStatusDoc, fullStatus);

webpages.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const char index_html[] PROGMEM = R"rawliteral(
2323
<h2>%EEH_HOSTNAME%</h2>
2424
<h3 id="maintenancemode">%MAINTENANCEMODE%</h3>
2525
<p>Device Time: <span id="ntptime">%DEVICETIME%</span> | Firmware Version: %FIRMWARE%</p>
26+
<p>Free Storage: <span id="freespiffs">%FREESPIFFS%</span> | Used Storage: <span id="usedspiffs">%USEDSPIFFS%</span> | Total Storage: <span id="totalspiffs">%TOTALSPIFFS%</span></p>
2627
<button onclick="logoutButton()">Logout Web Admin</button>
2728
<button onclick="getUserDetailsButton()">Refresh Current Card User Details</button>
2829
<button onclick="grantAccessButton()" %GRANTBUTTONENABLE%>Grant Access to Current Card</button>

webserver_functions.ino

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,18 @@ String processor(const String& var) {
178178
return String(config.webpagedelay * 1000);
179179
}
180180

181+
if (var == "FREESPIFFS") {
182+
return humanReadableSize((SPIFFS.totalBytes() - SPIFFS.usedBytes()));
183+
}
184+
185+
if (var == "USEDSPIFFS") {
186+
return humanReadableSize(SPIFFS.usedBytes());
187+
}
188+
189+
if (var == "TOTALSPIFFS") {
190+
return humanReadableSize(SPIFFS.totalBytes());
191+
}
192+
181193
return String();
182194
}
183195

0 commit comments

Comments
 (0)