Skip to content

Commit

Permalink
build: update config files name
Browse files Browse the repository at this point in the history
  • Loading branch information
DriftKingTW committed Mar 19, 2023
1 parent 606025a commit 18b65b4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
3 changes: 2 additions & 1 deletion data/config.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"currentActiveDeviceAddress": ""
"ssid": "SSID",
"password": "PASSWORD"
}
3 changes: 3 additions & 0 deletions data/system.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"currentActiveDeviceAddress": ""
}
4 changes: 0 additions & 4 deletions data/wifi.json

This file was deleted.

18 changes: 9 additions & 9 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ void generalTask(void *pvParameters) {
currentActiveDeviceAddress = String(addresses[i].c_str());
StaticJsonDocument<128> doc;
if (SPIFFS.begin()) {
File config = SPIFFS.open("/config.json", "w");
File config = SPIFFS.open("/system.json", "w");
doc["currentActiveDeviceAddress"] =
currentActiveDeviceAddress;
serializeJson(doc, config);
Expand Down Expand Up @@ -939,7 +939,7 @@ void switchDevice() {
Serial.println("Address: " + (String)currentActiveDeviceAddress);
if (SPIFFS.begin()) {
StaticJsonDocument<128> doc;
File config = SPIFFS.open("/config.json", "w");
File config = SPIFFS.open("/system.json", "w");
doc["currentActiveDeviceAddress"] = currentActiveDeviceAddress;
serializeJson(doc, config);
config.close();
Expand Down Expand Up @@ -1199,14 +1199,14 @@ void resetIdle() { sleepPreviousMillis = currentMillis; }
*
*/
void initWebServer() {
Serial.println("Loading \"wifi.json\" from SPIFFS...");
File file = SPIFFS.open("/wifi.json");
Serial.println("Loading \"config.json\" from SPIFFS...");
File file = SPIFFS.open("/config.json");
if (!file) {
Serial.println("Failed to open file for reading");
return;
}

Serial.println("Reading WIFI configuration from \"wifi.json\"...");
Serial.println("Reading WIFI configuration from \"config.json\"...");
String wifiConfigJSON = "";
while (file.available()) {
wifiConfigJSON += (char)file.read();
Expand Down Expand Up @@ -1427,14 +1427,14 @@ void initWebServer() {
String buffer;
DynamicJsonDocument doc(512);

Serial.println("Loading \"wifi.json\" from SPIFFS...");
File file = SPIFFS.open("/wifi.json");
Serial.println("Loading \"config.json\" from SPIFFS...");
File file = SPIFFS.open("/config.json");
if (!file) {
Serial.println("Failed to open file for reading");
return;
}

Serial.println("Reading WIFI configuration from \"wifi.json\"...");
Serial.println("Reading WIFI configuration from \"config.json\"...");
String wifiConfigJSON = "";
while (file.available()) {
wifiConfigJSON += (char)file.read();
Expand Down Expand Up @@ -1475,7 +1475,7 @@ void initWebServer() {
return;
}

const String filename = "wifi.json";
const String filename = "config.json";

File config = SPIFFS.open("/" + filename, "w");
if (!config) {
Expand Down

0 comments on commit 18b65b4

Please sign in to comment.