Skip to content

Commit 18c0633

Browse files
committed
fs callback embedded
1 parent 4b8081d commit 18c0633

File tree

19 files changed

+82
-280
lines changed

19 files changed

+82
-280
lines changed

examples/binaryWebSocket/binaryWebSocket.ino

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -209,14 +209,6 @@ void setup() {
209209
// Enable ACE FS file web editor and add FS info callback function
210210
server.enableFsCodeEditor();
211211

212-
#ifdef ESP32
213-
server.setFsInfoCallback([](fsInfo_t* fsInfo) {
214-
fsInfo->fsName = "LittleFS";
215-
fsInfo->totalBytes = LittleFS.totalBytes();
216-
fsInfo->usedBytes = LittleFS.usedBytes();
217-
});
218-
#endif
219-
220212
// Init with custom WebSocket event handler and start server
221213
server.init(onWsEvent);
222214

examples/csvLogger/csvLogger.ino

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,7 @@ void setup() {
9595

9696
// Enable ACE FS file web editor and add FS info callback fucntion
9797
server.enableFsCodeEditor();
98-
#ifdef ESP32
99-
server.setFsInfoCallback([](fsInfo_t* fsInfo) {
100-
fsInfo->totalBytes = LittleFS.totalBytes();
101-
fsInfo->usedBytes = LittleFS.usedBytes();
102-
fsInfo->fsName = "LittleFS";
103-
});
104-
#endif
105-
98+
10699
// Start server
107100
server.init();
108101
Serial.print(F("Async ESP Web Server started on IP Address: "));

examples/csvLoggerSD/csvLoggerSD.ino

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,6 @@ void setup() {
117117

118118
// Enable ACE FS file web editor and add FS info callback fucntion
119119
server.enableFsCodeEditor();
120-
#ifdef ESP32
121-
server.setFsInfoCallback([](fsInfo_t* fsInfo) {
122-
fsInfo->totalBytes = SD.totalBytes();
123-
fsInfo->usedBytes = SD.usedBytes();
124-
fsInfo->fsName = "SD";
125-
});
126-
#endif
127120

128121
// Start server
129122
server.init();

examples/customHTML/customHTML.ino

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,6 @@ bool startFilesystem() {
7878
return false;
7979
}
8080

81-
/*
82-
* Getting FS info (total and free bytes) is strictly related to
83-
* filesystem library used (LittleFS, FFat, SPIFFS etc etc) and ESP framework
84-
*/
85-
#ifdef ESP32
86-
void getFsInfo(fsInfo_t* fsInfo) {
87-
fsInfo->fsName = "LittleFS";
88-
fsInfo->totalBytes = LittleFS.totalBytes();
89-
fsInfo->usedBytes = LittleFS.usedBytes();
90-
}
91-
#endif
92-
9381

9482
//////////////////// Load application options from filesystem ////////////////////
9583
bool loadOptions() {
@@ -196,11 +184,7 @@ void setup() {
196184
server.setLogoBase64(base64_logo, "128", "128", /*overwrite file*/ false);
197185

198186
// Enable ACE FS file web editor and add FS info callback function
199-
#ifdef ESP32
200-
server.enableFsCodeEditor(getFsInfo);
201-
#else
202187
server.enableFsCodeEditor();
203-
#endif
204188

205189
// Inform user when config.json is saved via /edit or /upload
206190
server.setConfigSavedCallback(onConfigSaved);

examples/customOptions/customOptions.ino

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -163,16 +163,7 @@ void setup() {
163163
server.addJavascript(reload_btn_script, "js", /*overwrite*/ false);
164164

165165
// Enable ACE FS file web editor and add FS info callback function
166-
#ifdef ESP32
167-
server.enableFsCodeEditor([](fsInfo_t* fsInfo) {
168-
fsInfo->fsName = "LittleFS";
169-
fsInfo->totalBytes = LittleFS.totalBytes();
170-
fsInfo->usedBytes = LittleFS.usedBytes();
171-
});
172-
#else
173-
// ESP8266 core support LittleFS by default
174166
server.enableFsCodeEditor();
175-
#endif
176167

177168
// set /setup and /edit page authentication
178169
server.setAuthentication("admin", "admin");

examples/esp32-cam/esp32-cam.ino

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,6 @@ void setup() {
7878

7979
// Enable ACE FS file web editor and add FS info callback function
8080
server.enableFsCodeEditor();
81-
server.setFsInfoCallback([](fsInfo_t* fsInfo) {
82-
fsInfo->totalBytes = SD_MMC.totalBytes();
83-
fsInfo->usedBytes = SD_MMC.usedBytes();
84-
});
8581

8682
// Add custom handlers to webserver
8783
server.on("/getPicture", getPicture);

examples/gpio_list/gpio_list.ino

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,7 @@ void updateGpioList(AsyncWebServerRequest *request) {
121121
bool first = true;
122122
for (gpio_type &gpio : gpios) {
123123
if (!first) json += ",";
124-
first = false;
125-
124+
first = false;
126125
json += "{\"type\":\"";
127126
json += gpio.type;
128127
json += "\",\"pin\":";
@@ -178,18 +177,6 @@ void setup() {
178177
// Enable ACE FS file web editor and add FS info callback function
179178
server.enableFsCodeEditor();
180179

181-
/*
182-
* Getting FS info (total and free bytes) is strictly related to
183-
* filesystem library used (LittleFS, FFat, SPIFFS etc etc) and ESP framework
184-
*/
185-
#ifdef ESP32
186-
server.setFsInfoCallback([](fsInfo_t* fsInfo) {
187-
fsInfo->fsName = "LittleFS";
188-
fsInfo->totalBytes = LittleFS.totalBytes();
189-
fsInfo->usedBytes = LittleFS.usedBytes();
190-
});
191-
#endif
192-
193180
// Add custom page handlers
194181
server.on("/getGpioList", HTTP_GET, updateGpioList);
195182

examples/handleFormData/handleFormData.ino

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -102,19 +102,7 @@ void setup(){
102102

103103
// Enable ACE FS file web editor and add FS info callback function
104104
server.enableFsCodeEditor();
105-
/*
106-
* Getting FS info (total and free bytes) is strictly related to
107-
* filesystem library used (LittleFS, FFat, SPIFFS etc etc) and ESP framework
108-
* (On ESP8266 will be used "built-in" fsInfo data type)
109-
*/
110-
#ifdef ESP32
111-
server.setFsInfoCallback( [](fsInfo_t* fsInfo) {
112-
fsInfo->fsName = "LittleFS";
113-
fsInfo->totalBytes = LittleFS.totalBytes();
114-
fsInfo->usedBytes = LittleFS.usedBytes();
115-
});
116-
#endif
117-
105+
118106
// Start server
119107
server.init();
120108
Serial.print(F("ESP Web Server started on IP Address: "));

examples/highcharts/highcharts.ino

Lines changed: 3 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
#if defined(ESP8266)
2-
#include <ESP8266mDNS.h>
3-
#elif defined(ESP32)
4-
#include <ESPmDNS.h>
5-
#endif
1+
#include <Arduino.h>
62
#include <FS.h>
73
#include <LittleFS.h>
84
#include <AsyncFsWebServer.h> // https://github.com/cotestatnt/async-esp-fs-webserver/
@@ -56,37 +52,9 @@ void getUpdatedtime(const uint32_t timeout)
5652

5753

5854
//////////////////////////////// Filesystem /////////////////////////////////////////
59-
void listDir(fs::FS &fs, const char * dirname, uint8_t levels){
60-
Serial.printf("\nListing directory: %s\n", dirname);
61-
File root = fs.open(dirname, "r");
62-
if (!root) {
63-
Serial.println("- failed to open directory");
64-
return;
65-
}
66-
if (!root.isDirectory()) {
67-
Serial.println(" - not a directory");
68-
return;
69-
}
70-
File file = root.openNextFile();
71-
while (file) {
72-
if (file.isDirectory()) {
73-
if (levels) {
74-
#ifdef ESP32
75-
listDir(fs, file.path(), levels - 1);
76-
#elif defined(ESP8266)
77-
listDir(fs, file.fullName(), levels - 1);
78-
#endif
79-
}
80-
} else {
81-
Serial.printf("|__ FILE: %s (%d bytes)\n",file.name(), file.size());
82-
}
83-
file = root.openNextFile();
84-
}
85-
}
86-
8755
bool startFilesystem() {
8856
if (FILESYSTEM.begin()){
89-
listDir(FILESYSTEM, "/", 1);
57+
server.printFileList(FILESYSTEM, "/", 2), Serial;
9058
return true;
9159
}
9260
else {
@@ -115,18 +83,6 @@ void setup() {
11583
// Enable ACE FS file web editor and add FS info callback function
11684
server.enableFsCodeEditor();
11785

118-
/*
119-
* Getting FS info (total and free bytes) is strictly related to
120-
* filesystem library used (LittleFS, FFat, SPIFFS etc etc) and ESP framework
121-
*/
122-
#ifdef ESP32
123-
server.setFsInfoCallback([](fsInfo_t* fsInfo) {
124-
fsInfo->fsName = "LittleFS";
125-
fsInfo->totalBytes = LittleFS.totalBytes();
126-
fsInfo->usedBytes = LittleFS.usedBytes();
127-
});
128-
#endif
129-
13086
// Start server with custom websocket event handler
13187
server.init(onWsEvent);
13288
Serial.print(F("ESP Web Server started on IP Address: "));
@@ -137,32 +93,10 @@ void setup() {
13793
"Open /edit page to view, edit or upload example or your custom webserver source files."
13894
));
13995

140-
// Start MDNS responder
141-
if (WiFi.status() == WL_CONNECTED) {
142-
// Set hostname
143-
#ifdef ESP8266
144-
WiFi.hostname(hostname);
145-
#elif defined(ESP32)
146-
WiFi.setHostname(hostname);
147-
#endif
148-
if (MDNS.begin(hostname)) {
149-
Serial.println(F("MDNS responder started."));
150-
Serial.printf("You should be able to connect with address\t http://%s.local/\n", hostname);
151-
// Add service to MDNS-SD
152-
MDNS.addService("http", "tcp", 80);
153-
}
154-
}
15596
}
15697

15798

158-
void loop() {
159-
160-
if (WiFi.status() == WL_CONNECTED) {
161-
#ifdef ESP8266
162-
MDNS.update();
163-
#endif
164-
}
165-
99+
void loop() {
166100
// Send ESP system time (epoch) and heap stats to WS client
167101
static uint32_t sendToClientTime;
168102
if (millis() - sendToClientTime > 1000 ) {

examples/localRFID/webserver.hpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -228,13 +228,6 @@ bool startWebServer(bool clear = false) {
228228

229229
// Enable ACE FS file web editor and add FS info callback function
230230
myWebServer.enableFsCodeEditor();
231-
#if defined(ESP32)
232-
myWebServer.setFsInfoCallback([](fsInfo_t* fsInfo) {
233-
fsInfo->fsName = "LittleFS";
234-
fsInfo->totalBytes = LittleFS.totalBytes();
235-
fsInfo->usedBytes = LittleFS.usedBytes();
236-
});
237-
#endif
238231

239232
// Start the webserver
240233
myWebServer.init();

0 commit comments

Comments
 (0)