File tree Expand file tree Collapse file tree 5 files changed +84
-16
lines changed Expand file tree Collapse file tree 5 files changed +84
-16
lines changed Original file line number Diff line number Diff line change @@ -4,21 +4,11 @@ using namespace HomieInternals;
4
4
5
5
Config::Config ()
6
6
: _configStruct()
7
- , _spiffsBegan(false )
8
7
, _valid(false ) {
9
8
}
10
9
11
10
bool Config::_spiffsBegin () {
12
- if (!_spiffsBegan) {
13
- #ifdef ESP32
14
- _spiffsBegan = SPIFFS.begin (true );
15
- #elif defined(ESP8266)
16
- _spiffsBegan = SPIFFS.begin ();
17
- #endif
18
- if (!_spiffsBegan) Interface::get ().getLogger () << F (" ✖ Cannot mount filesystem" ) << endl;
19
- }
20
-
21
- return _spiffsBegan;
11
+ return _fs._fsBegin ();
22
12
}
23
13
24
14
bool Config::load () {
Original file line number Diff line number Diff line change 3
3
#include " Arduino.h"
4
4
5
5
#include < ArduinoJson.h>
6
- #ifdef ESP32
7
- #include < SPIFFS.h>
8
- #endif // ESP32
9
- #include " FS.h"
6
+ #include " FS.hpp"
10
7
#include " Datatypes/Interface.hpp"
11
8
#include " Datatypes/ConfigStruct.hpp"
12
9
#include " Utils/DeviceId.hpp"
@@ -34,7 +31,7 @@ class Config {
34
31
35
32
private:
36
33
ConfigStruct _configStruct;
37
- bool _spiffsBegan ;
34
+ FS _fs ;
38
35
bool _valid;
39
36
40
37
bool _spiffsBegin ();
Original file line number Diff line number Diff line change 10
10
#define HOMIE_CONFIG 1
11
11
#endif
12
12
13
+ // config mode requires SPIFFS as ESP Async Webserver only works with SPIFFS
14
+ #if HOMIE_CONFIG
15
+ #define HOMIE_SPIFFS
16
+ #endif
17
+
18
+ // default should be SPIFFS, except using LittleFS is explicitely defined
19
+ #ifndef HOMIE_LITTLEFS
20
+ #ifndef HOMIE_SPIFFS
21
+ #define HOMIE_SPIFFS
22
+ #endif
23
+ #endif
24
+
25
+ // fail if none or both are defined
26
+ #if defined(HOMIE_SPIFFS) && defined(HOMIE_LITTLEFS)
27
+ #error "Only one of HOMIE_SPIFFS and HOMIE_LITTLEFS must be defined. HOMIE_CONFIG requires HOMIE_SPIFFS."
28
+ #endif
29
+ #if !(defined(HOMIE_SPIFFS) || defined(HOMIE_LITTLEFS))
30
+ #error "At least one of HOMIE_SPIFFS or HOMIE_LITTLEFS needs to be defined."
31
+ #endif
32
+
13
33
namespace HomieInternals {
14
34
const char HOMIE_VERSION[] = " 3.0.1" ;
15
35
const char HOMIE_ESP8266_VERSION[] = " 3.0.0" ;
Original file line number Diff line number Diff line change
1
+ #include " FS.hpp"
2
+ #include " Datatypes/Interface.hpp"
3
+
4
+ HomieInternals::FS::FS ()
5
+ : _fsBegan(false ) {
6
+ }
7
+
8
+ bool HomieInternals::FS::_fsBegin () {
9
+ if (!_fsBegan) {
10
+ #ifdef ESP32
11
+ #ifdef HOMIE_SPIFFS
12
+ _fsBegan = SPIFFS.begin (true );
13
+ #elif defined(HOMIE_LITTLEFS)
14
+ _fsBegan = LittleFS.begin ();
15
+ #endif
16
+ #elif defined(ESP8266)
17
+ #ifdef HOMIE_SPIFFS
18
+ _fsBegan = SPIFFS.begin ();
19
+ #elif defined(HOMIE_LITTLEFS)
20
+ _fsBegan = LittleFS.begin ();
21
+ #endif
22
+ #endif
23
+ if (!_fsBegan) Interface::get ().getLogger () << F (" ✖ Cannot mount filesystem" ) << endl;
24
+ }
25
+
26
+ return _fsBegan;
27
+ }
28
+
29
+ void HomieInternals::FS::doSomething () {
30
+ bool lala = false ;
31
+ }
Original file line number Diff line number Diff line change
1
+ #pragma once
2
+
3
+ #include " Constants.hpp"
4
+
5
+ #ifdef ESP32
6
+ #ifdef HOMIE_SPIFFS
7
+ #include < SPIFFS.h>
8
+ #endif
9
+ #ifdef HOMIE_LITTLEFS
10
+ #include < LITTLEFS.h>
11
+ #endif
12
+ #elif defined(ESP8266)
13
+ #ifdef HOMIE_SPIFFS
14
+ #include " FS.h"
15
+ #elif defined(HOMIE_LITTLEFS)
16
+ #include " LittleFS.h"
17
+ #endif
18
+ #endif // ESP32
19
+
20
+ namespace HomieInternals {
21
+ class FS {
22
+ public:
23
+ FS ();
24
+ bool _fsBegin ();
25
+ static void doSomething ();
26
+
27
+ private:
28
+ bool _fsBegan;
29
+ };
30
+ } // namespace HomieInternals
You can’t perform that action at this time.
0 commit comments