28
28
WipperSnapper_LittleFS::WipperSnapper_LittleFS () {
29
29
// Attempt to initialize filesystem
30
30
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);
33
33
}
34
34
}
35
35
@@ -42,26 +42,25 @@ WipperSnapper_LittleFS::~WipperSnapper_LittleFS() { LittleFS.end(); }
42
42
@brief Locates, opens and parses the WipperSnapper secrets file
43
43
on the LittleFS filesystem.
44
44
*/
45
- void WipperSnapper_LittleFS::parseSecrets () {
45
+ void WipperSnapper_LittleFS::ParseFileSecrets () {
46
46
// Check if `secrets.json` file exists on FS
47
47
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?" );
51
50
}
52
51
53
52
// Attempt to open secrets.json file for reading
54
53
File secretsFile = LittleFS.open (" /secrets.json" , " r" );
55
54
if (!secretsFile) {
56
- HaltFilesystem (" ERROR: Could not open secrets.json file for reading!" );
55
+ fsHalt (" ERROR: Could not open secrets.json file for reading!" );
57
56
}
58
57
59
58
// Attempt to deserialize the file's JSON document
60
59
JsonDocument doc;
61
60
DeserializationError error = deserializeJson (doc, secretsFile);
62
61
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 ());
65
64
}
66
65
if (doc.containsKey (" network_type_wifi" )) {
67
66
// set default network config
@@ -81,9 +80,8 @@ void WipperSnapper_LittleFS::parseSecrets() {
81
80
WS_DEBUG_PRINT (" Network count: " );
82
81
WS_DEBUG_PRINTLN (altNetworkCount);
83
82
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!" );
87
85
}
88
86
// check if over 3, warn user and take first three
89
87
for (int i = 0 ; i < altNetworkCount; i++) {
@@ -101,11 +99,11 @@ void WipperSnapper_LittleFS::parseSecrets() {
101
99
}
102
100
WsV2._isWiFiMultiV2 = true ;
103
101
} 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!" );
106
104
}
107
105
} 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!" );
109
107
}
110
108
111
109
// Extract a config struct from the JSON document
@@ -114,17 +112,16 @@ void WipperSnapper_LittleFS::parseSecrets() {
114
112
// Validate the config struct is not filled with default values
115
113
if (strcmp (WsV2._configV2 .aio_user , " YOUR_IO_USERNAME_HERE" ) == 0 ||
116
114
strcmp (WsV2._configV2 .aio_key , " YOUR_IO_KEY_HERE" ) == 0 ) {
117
- HaltFilesystem (
115
+ fsHalt (
118
116
" ERROR: Invalid IO credentials in secrets.json! TO FIX: Please change "
119
117
" io_username and io_key to match your Adafruit IO credentials!\n " );
120
118
}
121
119
122
120
if (strcmp (WsV2._configV2 .network .ssid , " YOUR_WIFI_SSID_HERE" ) == 0 ||
123
121
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 " );
128
125
}
129
126
130
127
// Close the file
@@ -153,7 +150,7 @@ void WipperSnapper_LittleFS::fsHalt(String msg, ws_led_status_t status_state) {
153
150
@brief Attempts to obtain the hardware's CS pin from the
154
151
config.json file.
155
152
*/
156
- void WipperSnapper_LittleFS::GetSDCSPin () {
153
+ void WipperSnapper_LittleFS::GetPinSDCS () {
157
154
// Attempt to open and deserialize the config.json file
158
155
#if defined(ARDUINO_ESP8266_ADAFRUIT_HUZZAH)
159
156
File file_cfg = LittleFS.open (" /config.json" , " r" );
0 commit comments