use littlefs since spiffs is deprecated

pull/45/head
theFeiter 2 years ago
parent d67e831e64
commit cb47f6c02e

@ -30,6 +30,9 @@
#include <SPI.h> #include <SPI.h>
#include <SD.h> #include <SD.h>
#endif #endif
#ifdef USE_FS_LOG
#include <LittleFS.h>
#endif
#include "fdrs_functions.h" #include "fdrs_functions.h"
void setup() { void setup() {
@ -69,7 +72,7 @@ void setup() {
#ifdef USE_SD_LOG #ifdef USE_SD_LOG
begin_SD(); begin_SD();
#endif #endif
#ifdef USE_SPIFFS_LOG #ifdef USE_FS_LOG
begin_FS(); begin_FS();
#endif #endif

@ -19,7 +19,7 @@
//#define USE_LORA //#define USE_LORA
//#define USE_WIFI //Used only for MQTT gateway //#define USE_WIFI //Used only for MQTT gateway
//#define USE_SD_LOG //Used only for SD-card logging //#define USE_SD_LOG //Used only for SD-card logging
//#define USE_SPIFFS_LOG //Used only for SPIFFS logging (esp internal filesystem) //#define USE_FS_LOG //Used only for SPIFFS logging (esp internal filesystem)
// Peer addresses // Peer addresses
#define ESPNOW1_PEER 0x0E // ESPNOW1 Address #define ESPNOW1_PEER 0x0E // ESPNOW1 Address
@ -86,5 +86,5 @@
#define SD_SS 0 //SD card Chipselect pin (Use a different pins for LoRa and SD) #define SD_SS 0 //SD card Chipselect pin (Use a different pins for LoRa and SD)
#define SD_FILENAME "fdrs_log.csv" // length max. 32 #define SD_FILENAME "fdrs_log.csv" // length max. 32
// SPIFFS logging config -- Needed only for SPIFFS logging // Internal flash logging config -- Needed only for internal flash logging
#define SPIFFS_FILENAME "fdrs_log.csv" // length max. 32 #define FS_FILENAME "fdrs_log.csv" // length max. 32

@ -196,9 +196,9 @@ void send_SD(char filename[32]) {
#endif #endif
} }
void send_FS(char filename[32]) { void send_FS(char filename[32]) {
#ifdef USE_SPIFFS_LOG #ifdef USE_FS_LOG
DBG("Logging to internal flash."); DBG("Logging to internal flash.");
File logfile = SPIFFS.open(filename, "a"); File logfile = LittleFS.open(filename, "a");
for (int i = 0; i < ln; i++) { for (int i = 0; i < ln; i++) {
#ifdef USE_WIFI #ifdef USE_WIFI
logfile.print(timeClient.getEpochTime()); logfile.print(timeClient.getEpochTime());
@ -213,7 +213,6 @@ void send_FS(char filename[32]) {
logfile.println(theData[i].d); logfile.println(theData[i].d);
} }
logfile.close(); logfile.close();
}
#endif #endif
} }
void reconnect(int attempts, bool silent) { void reconnect(int attempts, bool silent) {
@ -277,7 +276,7 @@ void mqtt_publish(const char* payload){
if(!client.publish(TOPIC_DATA, payload)){ if(!client.publish(TOPIC_DATA, payload)){
DBG(" Error on sending MQTT"); DBG(" Error on sending MQTT");
send_SD(SD_FILENAME); send_SD(SD_FILENAME);
send_FS(SPIFFS_FILENAME); send_FS(FS_FILENAME);
} }
#endif #endif
} }
@ -669,17 +668,17 @@ void begin_SD(){
#endif #endif
} }
void begin_FS(){ void begin_FS(){
#ifdef USE_SPIFFS_LOG #ifdef USE_FS_LOG
DBG("Initializing SPIFFS..."); DBG("Initializing LittleFS...");
if(!SPIFFS.begin()) if(!LittleFS.begin())
{ {
Serial.println(" initialization failed"); Serial.println(" initialization failed");
while (1); while (1);
} }
else else
{ {
Serial.println(" SPIFFS initialized"); Serial.println(" LittleFS initialized");
} }
#endif #endif
} }

Loading…
Cancel
Save