Skip to content

Commit 253a2c0

Browse files
committed
[SD] Support for LittleFS based provisioning
1 parent 126f430 commit 253a2c0

File tree

7 files changed

+15
-17
lines changed

7 files changed

+15
-17
lines changed

src/Wippersnapper_V2.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ void Wippersnapper_V2::provisionV2() {
101101
#ifdef USE_TINYUSB
102102
_fileSystemV2 = new Wippersnapper_FS_V2();
103103
#elif defined(USE_LITTLEFS)
104-
_littleFSV2 = new WipperSnapper_LittleFS();
104+
_littleFSV2 = new WipperSnapper_LittleFS_V2();
105105
#endif
106106

107107
// Determine if app is in SDLogger mode

src/Wippersnapper_V2.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
#include "provisioning/tinyusb/Wippersnapper_FS_V2.h"
8181
#endif
8282
#if defined(USE_LITTLEFS)
83-
#include "provisioning/littlefs/WipperSnapper_LittleFS.h"
83+
#include "provisioning/littlefs/WipperSnapper_LittleFS_V2.h"
8484
#endif
8585

8686
#define WS_VERSION \
@@ -95,7 +95,7 @@
9595
// Forward declarations (API v1)
9696
class Wippersnapper_AnalogIO;
9797
class Wippersnapper_FS_V2;
98-
class WipperSnapper_LittleFS;
98+
class WipperSnapper_LittleFS_V2;
9999
class ws_sdcard;
100100
#ifdef USE_DISPLAY
101101
class ws_display_driver;
@@ -207,7 +207,7 @@ class Wippersnapper_V2 {
207207
// to free up space on the heap
208208
Wippersnapper_AnalogIO *_analogIOV2; ///< Instance of analog io class
209209
Wippersnapper_FS_V2 *_fileSystemV2; ///< Instance of Filesystem (native USB)
210-
WipperSnapper_LittleFS
210+
WipperSnapper_LittleFS_V2
211211
*_littleFSV2; ///< Instance of LittleFS Filesystem (non-native USB)
212212
ws_sdcard *_sdCardV2; ///< Instance of SD card class
213213
#ifdef USE_DISPLAY

src/provisioning/littlefs/WipperSnapper_LittleFS_V2.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,9 @@ void WipperSnapper_LittleFS_V2::fsHalt(String msg) {
162162
*/
163163
/**************************************************************************/
164164
void WipperSnapper_LittleFS_V2::GetSDCSPin() {
165-
File32 file_cfg;
166165
DeserializationError error;
167166
// Attempt to open and deserialize the config.json file
168-
file_cfg = LittleFS.open("/config.json");
167+
File file_cfg = LittleFS.open("/config.json");
169168
if (!file_cfg)
170169
WsV2.pin_sd_cs = 255;
171170
error = deserializeJson(WsV2._config_doc, file_cfg);

src/provisioning/littlefs/WipperSnapper_LittleFS_V2.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#define WIPPERSNAPPER_LITTLEFS_V2_H
1717

1818
#include "Wippersnapper_V2.h"
19-
2019
#include <FS.h>
2120
#include <LittleFS.h>
2221

src/provisioning/sdcard/ws_sdcard.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ bool ws_sdcard::CreateNewLogFile() {
466466
_log_filename = log_filename_buffer;
467467

468468
// Attempt to create the new log file
469-
if (!file.open(_log_filename, FILE_WRITE))
469+
if (!file.open(_log_filename, O_RDWR | O_CREAT | O_AT_END))
470470
return false;
471471
WS_DEBUG_PRINT("[SD] Created new log file on SD card: ");
472472
WS_DEBUG_PRINTLN(_log_filename);
@@ -802,7 +802,7 @@ bool ws_sdcard::LogJSONDoc(JsonDocument &doc) {
802802
// Serialize the JSON document
803803
#ifndef OFFLINE_MODE_DEBUG
804804
File32 file;
805-
file = _sd.open(_log_filename, FILE_WRITE);
805+
file = _sd.open(_log_filename, O_RDWR | O_CREAT | O_AT_END);
806806
if (!file) {
807807
WS_DEBUG_PRINTLN(
808808
"[SD] FATAL Error - Unable to open the log file for writing!");

src/ws_manager.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ void Wippersnapper_Manager::checkAPIVersion(int pinNum) {
6969
// NOTE: For debugging right now, we are forcing the API version
7070
readButton = true;
7171
if (readButton) { // API version 2 if D12 is high
72-
ws_instance_v2 = new ws_adapter_offline_v2();
72+
ws_instance_v2 = new ws_adapter_wifi_v2();
7373
_api_version = 2;
7474
} else { // API version 1 if D12 is low
75-
ws_instance = new ws_adapter_offline();
75+
ws_instance = new ws_adapter_wifi();
7676
_api_version = 1;
7777
}
7878
}

src/ws_manager.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#ifndef WIPPERSNAPPER_MANAGER_H
22
#define WIPPERSNAPPER_MANAGER_H
33

4-
#include "adapters/offline/ws_offline_pico.h"
5-
typedef ws_offline_pico ws_adapter_offline;
6-
#include "adapters/offline/ws_offline_pico_v2.h"
7-
typedef ws_offline_pico_v2 ws_adapter_offline_v2;
4+
#include "adapters/wifi/ws_wifi_esp32.h"
5+
typedef ws_wifi_esp32 ws_adapter_wifi;
6+
#include "adapters/wifi/ws_wifi_esp32_v2.h"
7+
typedef ws_wifi_esp32_v2 ws_adapter_wifi_v2;
88

99
/****************************************************************************/
1010
/*!
@@ -27,8 +27,8 @@ class Wippersnapper_Manager {
2727
void run();
2828

2929
protected:
30-
ws_adapter_offline *ws_instance; ///< Instance of Wippersnapper API v1
31-
ws_adapter_offline_v2 *ws_instance_v2; ///< Instance of Wippersnapper API v2
30+
ws_adapter_wifi *ws_instance; ///< Instance of Wippersnapper API v1
31+
ws_adapter_wifi_v2 *ws_instance_v2; ///< Instance of Wippersnapper API v2
3232
private:
3333
int _api_version;
3434
};

0 commit comments

Comments
 (0)