Skip to content

Commit 390a72f

Browse files
committed
Fix esp32dev platform
1 parent adb423f commit 390a72f

File tree

2 files changed

+20
-24
lines changed

2 files changed

+20
-24
lines changed

src/provisioning/littlefs/WipperSnapper_LittleFS.cpp

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
WipperSnapper_LittleFS::WipperSnapper_LittleFS() {
2929
// Attempt to initialize filesystem
3030
if (!LittleFS.begin()) {
31-
HaltFilesystem("ERROR: Failure initializing LittleFS!",
32-
WS_LED_STATUS_WAITING_FOR_REG_MSG);
31+
fsHalt("ERROR: Failure initializing LittleFS!",
32+
WS_LED_STATUS_WAITING_FOR_REG_MSG);
3333
}
3434
}
3535

@@ -42,26 +42,25 @@ WipperSnapper_LittleFS::~WipperSnapper_LittleFS() { LittleFS.end(); }
4242
@brief Locates, opens and parses the WipperSnapper secrets file
4343
on the LittleFS filesystem.
4444
*/
45-
void WipperSnapper_LittleFS::parseSecrets() {
45+
void WipperSnapper_LittleFS::ParseFileSecrets() {
4646
// Check if `secrets.json` file exists on FS
4747
if (!LittleFS.exists("/secrets.json")) {
48-
HaltFilesystem(
49-
"ERROR: No secrets.json found on filesystem - did you upload "
50-
"credentials?");
48+
fsHalt("ERROR: No secrets.json found on filesystem - did you upload "
49+
"credentials?");
5150
}
5251

5352
// Attempt to open secrets.json file for reading
5453
File secretsFile = LittleFS.open("/secrets.json", "r");
5554
if (!secretsFile) {
56-
HaltFilesystem("ERROR: Could not open secrets.json file for reading!");
55+
fsHalt("ERROR: Could not open secrets.json file for reading!");
5756
}
5857

5958
// Attempt to deserialize the file's JSON document
6059
JsonDocument doc;
6160
DeserializationError error = deserializeJson(doc, secretsFile);
6261
if (error) {
63-
HaltFilesystem(String("ERROR: deserializeJson() failed with code ") +
64-
error.c_str());
62+
fsHalt(String("ERROR: deserializeJson() failed with code ") +
63+
error.c_str());
6564
}
6665
if (doc.containsKey("network_type_wifi")) {
6766
// set default network config
@@ -81,9 +80,8 @@ void WipperSnapper_LittleFS::parseSecrets() {
8180
WS_DEBUG_PRINT("Network count: ");
8281
WS_DEBUG_PRINTLN(altNetworkCount);
8382
if (altNetworkCount == 0) {
84-
HaltFilesystem(
85-
"ERROR: No alternative network entries found under "
86-
"network_type_wifi.alternative_networks in secrets.json!");
83+
fsHalt("ERROR: No alternative network entries found under "
84+
"network_type_wifi.alternative_networks in secrets.json!");
8785
}
8886
// check if over 3, warn user and take first three
8987
for (int i = 0; i < altNetworkCount; i++) {
@@ -101,11 +99,11 @@ void WipperSnapper_LittleFS::parseSecrets() {
10199
}
102100
WsV2._isWiFiMultiV2 = true;
103101
} else {
104-
HaltFilesystem("ERROR: Unrecognised value type for "
105-
"network_type_wifi.alternative_networks in secrets.json!");
102+
fsHalt("ERROR: Unrecognised value type for "
103+
"network_type_wifi.alternative_networks in secrets.json!");
106104
}
107105
} else {
108-
HaltFilesystem("ERROR: Could not find network_type_wifi in secrets.json!");
106+
fsHalt("ERROR: Could not find network_type_wifi in secrets.json!");
109107
}
110108

111109
// Extract a config struct from the JSON document
@@ -114,17 +112,16 @@ void WipperSnapper_LittleFS::parseSecrets() {
114112
// Validate the config struct is not filled with default values
115113
if (strcmp(WsV2._configV2.aio_user, "YOUR_IO_USERNAME_HERE") == 0 ||
116114
strcmp(WsV2._configV2.aio_key, "YOUR_IO_KEY_HERE") == 0) {
117-
HaltFilesystem(
115+
fsHalt(
118116
"ERROR: Invalid IO credentials in secrets.json! TO FIX: Please change "
119117
"io_username and io_key to match your Adafruit IO credentials!\n");
120118
}
121119

122120
if (strcmp(WsV2._configV2.network.ssid, "YOUR_WIFI_SSID_HERE") == 0 ||
123121
strcmp(WsV2._configV2.network.pass, "YOUR_WIFI_PASS_HERE") == 0) {
124-
HaltFilesystem(
125-
"ERROR: Invalid network credentials in secrets.json! TO FIX: Please "
126-
"change network_ssid and network_password to match your Adafruit IO "
127-
"credentials!\n");
122+
fsHalt("ERROR: Invalid network credentials in secrets.json! TO FIX: Please "
123+
"change network_ssid and network_password to match your Adafruit IO "
124+
"credentials!\n");
128125
}
129126

130127
// Close the file
@@ -153,7 +150,7 @@ void WipperSnapper_LittleFS::fsHalt(String msg, ws_led_status_t status_state) {
153150
@brief Attempts to obtain the hardware's CS pin from the
154151
config.json file.
155152
*/
156-
void WipperSnapper_LittleFS::GetSDCSPin() {
153+
void WipperSnapper_LittleFS::GetPinSDCS() {
157154
// Attempt to open and deserialize the config.json file
158155
#if defined(ARDUINO_ESP8266_ADAFRUIT_HUZZAH)
159156
File file_cfg = LittleFS.open("/config.json", "r");

src/provisioning/littlefs/WipperSnapper_LittleFS.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,8 @@ class WipperSnapper_LittleFS {
2929
WipperSnapper_LittleFS();
3030
~WipperSnapper_LittleFS();
3131
void ParseFileSecrets();
32-
void
33-
HaltFilesystem(String msg,
34-
ws_led_status_t status_state = WS_LED_STATUS_ERROR_RUNTIME);
32+
void fsHalt(String msg,
33+
ws_led_status_t status_state = WS_LED_STATUS_ERROR_RUNTIME);
3534
void GetPinSDCS();
3635
};
3736
extern Wippersnapper_V2 WsV2;

0 commit comments

Comments
 (0)