Support LittleFS

enhance/v120
Hieromon Ikasamo 5 years ago
parent 73b60487f9
commit 31dcc2485b
  1. 23
      src/AutoConnectDefs.h
  2. 14
      src/AutoConnectElementBasisImpl.h
  3. 8
      src/AutoConnectUploadImpl.h

@ -3,7 +3,7 @@
* @file AutoConnectDefs.h
* @author hieromon@gmail.com
* @version 1.2.0
* @date 2020-04-23
* @date 2020-05-29
* @copyright MIT license.
*/
@ -18,11 +18,11 @@
#define AC_DEBUG_PORT Serial
#endif // !AC_DEBUG_PORT
#ifdef AC_DEBUG
#define AC_DBG_DUMB(fmt, ...) do {AC_DEBUG_PORT.printf(PSTR(fmt), ## __VA_ARGS__ );} while (0)
#define AC_DBG(fmt, ...) do {AC_DEBUG_PORT.printf(PSTR("[AC] " fmt), ## __VA_ARGS__ );} while (0)
#define AC_DBG_DUMB(fmt, ...) do {AC_DEBUG_PORT.printf_P((PGM_P)PSTR(fmt), ## __VA_ARGS__ );} while (0)
#define AC_DBG(fmt, ...) do {AC_DEBUG_PORT.printf_P((PGM_P)PSTR("[AC] " fmt), ## __VA_ARGS__ );} while (0)
#else
#define AC_DBG(...) do {} while(0)
#define AC_DBG_DUMB(...) do {} while(0)
#define AC_DBG(...) do {(void)0;} while(0)
#define AC_DBG_DUMB(...) do {(void)0;} while(0)
#endif // !AC_DEBUG
// Indicator to specify that AutoConnectAux handles elements with JSON.
@ -34,6 +34,19 @@
#define AUTOCONNECT_USE_UPDATE
#endif
// SPIFFS has deprecated on EP8266 core. This flag indicates that
// the migration to LittleFS has not completed.
//#define AC_USE_SPIFFS
// Deploys SPIFFS usage flag to the global.
#if defined(ARDUINO_ARCH_ESP8266)
#ifdef AC_USE_SPIFFS
#define AUTOCONNECT_USE_SPIFFS
#endif
#elif defined(ARDUINO_ARCH_ESP32)
#define AUTOCONNECT_USE_SPIFFS
#endif
// Predefined parameters
// SSID that Captive portal started.
#ifndef AUTOCONNECT_APID

@ -2,8 +2,8 @@
* Implementation of AutoConnectElementBasis classes.
* @file AutoConnectElementBasisImpl.h
* @author hieromon@gmail.com
* @version 0.9.11
* @date 2019-06-25
* @version 1.2.0
* @date 2029-05-29
* @copyright MIT license.
*/
@ -19,6 +19,14 @@
#endif
#include "AutoConnectElementBasis.h"
// Preserve a valid global Filesystem instance.
// It allows the interface to the actual filesystem for migration to LittleFS.
#ifdef AUTOCONNECT_USE_SPIFFS
namespace AutoConnectFS { SPIFFST& FLASHFS = SPIFFS; };
#else
namespace AutoConnectFS { SPIFFST& FLASHFS = LittleFS; };
#endif
/**
* Append post-tag accoring by the post attribute.
* @param s An original string
@ -111,7 +119,7 @@ bool AutoConnectFileBasis::attach(const ACFile_t store) {
// Classify a handler type and create the corresponding handler
switch (store) {
case AC_File_FS:
handlerFS = new AutoConnectUploadFS(SPIFFS);
handlerFS = new AutoConnectUploadFS(AutoConnectFS::FLASHFS);
_upload.reset(reinterpret_cast<AutoConnectUploadHandler*>(handlerFS));
break;
case AC_File_SD:

@ -2,8 +2,8 @@
* The default upload handler implementation.
* @file AutoConnectUploadImpl.h
* @author hieromon@gmail.com
* @version 0.9.9
* @date 2019-05-25
* @version 1.2.0
* @date 2020-05-29
* @copyright MIT license.
*/
@ -20,7 +20,11 @@
#include <SPI.h>
#include <SD.h>
#define FS_NO_GLOBALS
#ifdef AUTOCONNECT_USE_SPIFFS
#include <FS.h>
#else
#include <LittleFS.h>
#endif
// Types branching to be code commonly for the file system classes with
// ESP8266 and ESP32.

Loading…
Cancel
Save