mirror of
https://github.com/richonguzman/LoRa_APRS_iGate.git
synced 2026-04-30 18:42:15 +02:00
Fix OTA update due bad configuration behaviour
This commit is contained in:
@@ -25,11 +25,29 @@
|
||||
|
||||
bool shouldSleepStop = true;
|
||||
|
||||
void Configuration::setup() {
|
||||
if (!SPIFFS.begin(false)) {
|
||||
Serial.println("SPIFFS Mount Failed");
|
||||
return;
|
||||
} else {
|
||||
Serial.println("SPIFFS Mounted");
|
||||
}
|
||||
|
||||
bool exists = SPIFFS.exists("/igate_conf.json");
|
||||
if (!exists) {
|
||||
setDefaultValues();
|
||||
writeFile();
|
||||
delay(1000);
|
||||
ESP.restart();
|
||||
}
|
||||
|
||||
readFile();
|
||||
}
|
||||
|
||||
bool Configuration::writeFile() {
|
||||
Serial.println("Saving configuration...");
|
||||
|
||||
StaticJsonDocument<3584> data;
|
||||
DynamicJsonDocument data(3584);
|
||||
File configFile = SPIFFS.open("/igate_conf.json", "w");
|
||||
|
||||
if (!configFile) {
|
||||
@@ -539,22 +557,3 @@ void Configuration::setDefaultValues() {
|
||||
|
||||
Serial.println("New Data Created... All is Written!");
|
||||
}
|
||||
|
||||
Configuration::Configuration() {
|
||||
if (!SPIFFS.begin(false)) {
|
||||
Serial.println("SPIFFS Mount Failed");
|
||||
return;
|
||||
} else {
|
||||
Serial.println("SPIFFS Mounted");
|
||||
}
|
||||
|
||||
bool exists = SPIFFS.exists("/igate_conf.json");
|
||||
if (!exists) {
|
||||
setDefaultValues();
|
||||
writeFile();
|
||||
delay(1000);
|
||||
ESP.restart();
|
||||
}
|
||||
|
||||
readFile();
|
||||
}
|
||||
Reference in New Issue
Block a user