ESP32: Dateisystem-Initialisierungscode-Beispiel (LittleFS)
English
Deutsch
Dieser Beispielcode kümmert sich um das Mounten des Dateisystems bzw. um das Erstellen eines Dateisystems, falls keines vorhanden ist.
littlefs_init.cpp
#pragma once
#include <stddef.h>
// InitFilesystem() setzt dies auf true, wenn das Dateisystem verfügbar ist.
extern volatile bool filesystemOK;
void InitFilesystem();littlefs_init_impl.cpp
#include "FS.h"
#include "LittleFS.h"
volatile bool filesystemOK = false;
void InitFilesystem() {
// LittleFS initialisieren
if (!LittleFS.begin(false /* false: Nicht formatieren, falls Mount fehlgeschlagen */)) {
Serial.println("LittleFS konnte nicht gemountet werden");
if (!LittleFS.begin(true /* true: formatieren */)) {
Serial.println("LittleFS konnte nicht formatiert werden");
} else {
Serial.println("LittleFS erfolgreich formatiert");
filesystemOK = true;
}
} else { // Erstmaliges Mounten erfolgreich
filesystemOK = true;
}
}Check out similar posts by category:
C/C++, ESP8266/ESP32
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow