async server introduction

This commit is contained in:
cjkas 2026-03-21 19:21:03 +01:00
parent c94819e928
commit 9ccc2d4ff5
4 changed files with 58 additions and 9 deletions

View file

@ -24,11 +24,41 @@ GitUpdater git;
uint32_t oldheap = 0;
void listDir(const char *dirname, uint8_t levels) {
Serial.printf("Listing: %s\n", dirname);
File root = LittleFS.open(dirname);
if (!root || !root.isDirectory()) {
Serial.println("Failed to open directory");
return;
}
File file = root.openNextFile();
while (file) {
if (file.isDirectory()) {
Serial.printf(" DIR : %s\n", file.name());
if (levels) listDir(file.path(), levels - 1);
} else {
Serial.printf(" FILE: %-30s %d bytes\n", file.name(), file.size());
}
file = root.openNextFile();
}
}
void setup() {
Serial.begin(115200);
Serial.println();
log_i("Startup/Boot....");
log_i("Mounting File System...");
Serial.println("Startup/Boot....");
Serial.println("Mounting File System...");
if (LittleFS.begin()) {
Serial.printf("\nTotal: %d bytes\n", LittleFS.totalBytes());
Serial.printf("Used: %d bytes\n", LittleFS.usedBytes());
Serial.printf("Free: %d bytes\n", LittleFS.totalBytes() - LittleFS.usedBytes());
Serial.println();
listDir("/", 3);
} else {
Serial.println("LittleFS mount failed!");
}
if(LittleFS.begin()) Serial.println("File system mounted successfully");
else Serial.println("Error mounting file system");