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 * @file AutoConnectDefs.h
* @author hieromon@gmail.com * @author hieromon@gmail.com
* @version 1.2.0 * @version 1.2.0
* @date 2020-04-23 * @date 2020-05-29
* @copyright MIT license. * @copyright MIT license.
*/ */
@ -18,11 +18,11 @@
#define AC_DEBUG_PORT Serial #define AC_DEBUG_PORT Serial
#endif // !AC_DEBUG_PORT #endif // !AC_DEBUG_PORT
#ifdef AC_DEBUG #ifdef AC_DEBUG
#define AC_DBG_DUMB(fmt, ...) do {AC_DEBUG_PORT.printf(PSTR(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(PSTR("[AC] " 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 #else
#define AC_DBG(...) do {} while(0) #define AC_DBG(...) do {(void)0;} while(0)
#define AC_DBG_DUMB(...) do {} while(0) #define AC_DBG_DUMB(...) do {(void)0;} while(0)
#endif // !AC_DEBUG #endif // !AC_DEBUG
// Indicator to specify that AutoConnectAux handles elements with JSON. // Indicator to specify that AutoConnectAux handles elements with JSON.
@ -34,6 +34,19 @@
#define AUTOCONNECT_USE_UPDATE #define AUTOCONNECT_USE_UPDATE
#endif #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 // Predefined parameters
// SSID that Captive portal started. // SSID that Captive portal started.
#ifndef AUTOCONNECT_APID #ifndef AUTOCONNECT_APID

@ -2,8 +2,8 @@
* Implementation of AutoConnectElementBasis classes. * Implementation of AutoConnectElementBasis classes.
* @file AutoConnectElementBasisImpl.h * @file AutoConnectElementBasisImpl.h
* @author hieromon@gmail.com * @author hieromon@gmail.com
* @version 0.9.11 * @version 1.2.0
* @date 2019-06-25 * @date 2029-05-29
* @copyright MIT license. * @copyright MIT license.
*/ */
@ -19,6 +19,14 @@
#endif #endif
#include "AutoConnectElementBasis.h" #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. * Append post-tag accoring by the post attribute.
* @param s An original string * @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 // Classify a handler type and create the corresponding handler
switch (store) { switch (store) {
case AC_File_FS: case AC_File_FS:
handlerFS = new AutoConnectUploadFS(SPIFFS); handlerFS = new AutoConnectUploadFS(AutoConnectFS::FLASHFS);
_upload.reset(reinterpret_cast<AutoConnectUploadHandler*>(handlerFS)); _upload.reset(reinterpret_cast<AutoConnectUploadHandler*>(handlerFS));
break; break;
case AC_File_SD: case AC_File_SD:

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

Loading…
Cancel
Save