configuration test without fails
This commit is contained in:
parent
61db6c3132
commit
d8d832fde9
|
|
@ -38,7 +38,7 @@ ________________________________________________________________________________
|
|||
#include "A7670_utils.h"
|
||||
#endif
|
||||
|
||||
String versionDate = "2024.08.13";
|
||||
String versionDate = "2024.08.14";
|
||||
Configuration Config;
|
||||
WiFiClient espClient;
|
||||
|
||||
|
|
@ -63,7 +63,6 @@ void setup() {
|
|||
POWER_Utils::setup();
|
||||
BATTERY_Utils::setup();
|
||||
Utils::setupDisplay();
|
||||
Config.check();
|
||||
LoRa_Utils::setup();
|
||||
Utils::validateFreqs();
|
||||
GPS_Utils::generateBeacons();
|
||||
|
|
|
|||
|
|
@ -4,16 +4,6 @@
|
|||
#include "display.h"
|
||||
|
||||
|
||||
void Configuration::check() {
|
||||
if (reload) {
|
||||
show_display("------- UPDATE ------", "config is old", "device will update", "and then reboot", 1000);
|
||||
|
||||
writeFile();
|
||||
|
||||
ESP.restart();
|
||||
}
|
||||
}
|
||||
|
||||
void Configuration::writeFile() {
|
||||
Serial.println("Saving config..");
|
||||
|
||||
|
|
@ -76,7 +66,6 @@ void Configuration::writeFile() {
|
|||
data["battery"]["voltageDividerR1"] = battery.voltageDividerR1;
|
||||
data["battery"]["voltageDividerR2"] = battery.voltageDividerR2;
|
||||
|
||||
|
||||
data["bme"]["active"] = bme.active;
|
||||
data["bme"]["heightCorrection"] = bme.heightCorrection;
|
||||
data["bme"]["temperatureCorrection"] = bme.temperatureCorrection;
|
||||
|
|
@ -137,137 +126,84 @@ bool Configuration::readFile() {
|
|||
wifiAPs.push_back(wifiap);
|
||||
}
|
||||
|
||||
wifiAutoAP.password = data["wifi"]["autoAP"]["password"].as<String>();
|
||||
wifiAutoAP.powerOff = data["wifi"]["autoAP"]["powerOff"].as<int>();
|
||||
wifiAutoAP.password = data["wifi"]["autoAP"]["password"] | "1234567890";
|
||||
wifiAutoAP.powerOff = data["wifi"]["autoAP"]["powerOff"] | 10;
|
||||
|
||||
callsign = data["callsign"].as<String>();
|
||||
rememberStationTime = data["other"]["rememberStationTime"].as<int>();
|
||||
callsign = data["callsign"] | "NOCALL-10";
|
||||
rememberStationTime = data["other"]["rememberStationTime"] | 30;
|
||||
|
||||
battery.sendInternalVoltage = data["battery"]["sendInternalVoltage"].as<bool>();
|
||||
battery.monitorInternalVoltage = data["battery"]["monitorInternalVoltage"].as<bool>();
|
||||
battery.internalSleepVoltage = data["battery"]["internalSleepVoltage"].as<float>();
|
||||
|
||||
battery.sendExternalVoltage = data["battery"]["sendExternalVoltage"].as<bool>();
|
||||
battery.externalVoltagePin = data["battery"]["externalVoltagePin"].as<int>();
|
||||
battery.monitorExternalVoltage = data["battery"]["monitorExternalVoltage"].as<bool>();
|
||||
battery.externalSleepVoltage = data["battery"]["externalSleepVoltage"].as<float>();
|
||||
battery.voltageDividerR1 = data["battery"]["voltageDividerR1"].as<float>();
|
||||
battery.voltageDividerR2 = data["battery"]["voltageDividerR2"].as<float>();
|
||||
|
||||
aprs_is.passcode = data["aprs_is"]["passcode"].as<String>();
|
||||
aprs_is.server = data["aprs_is"]["server"].as<String>();
|
||||
aprs_is.port = data["aprs_is"]["port"].as<int>();
|
||||
|
||||
loramodule.spreadingFactor = data["lora"]["spreadingFactor"].as<int>();
|
||||
loramodule.signalBandwidth = data["lora"]["signalBandwidth"].as<long>();
|
||||
loramodule.codingRate4 = data["lora"]["codingRate4"].as<int>();
|
||||
loramodule.power = data["lora"]["power"].as<int>();
|
||||
|
||||
display.alwaysOn = data["display"]["alwaysOn"].as<bool>();
|
||||
display.timeout = data["display"]["timeout"].as<int>();
|
||||
display.turn180 = data["display"]["turn180"].as<bool>();
|
||||
|
||||
syslog.active = data["syslog"]["active"].as<bool>();
|
||||
syslog.server = data["syslog"]["server"].as<String>();
|
||||
syslog.port = data["syslog"]["port"].as<int>();
|
||||
|
||||
bme.active = data["bme"]["active"].as<bool>();
|
||||
bme.heightCorrection = data["bme"]["heightCorrection"].as<int>();
|
||||
bme.temperatureCorrection = data["bme"]["temperatureCorrection"].as<float>();
|
||||
|
||||
ota.username = data["ota"]["username"].as<String>();
|
||||
ota.password = data["ota"]["password"].as<String>();
|
||||
|
||||
tnc.enableServer = data["tnc"]["enableServer"].as<bool>();
|
||||
tnc.enableSerial = data["tnc"]["enableSerial"].as<bool>();
|
||||
tnc.acceptOwn = data["tnc"]["acceptOwn"].as<bool>();
|
||||
|
||||
lowPowerMode = data["other"]["lowPowerMode"].as<bool>();
|
||||
lowVoltageCutOff = data["other"]["lowVoltageCutOff"].as<double>();
|
||||
|
||||
backupDigiMode = data["other"]["backupDigiMode"].as<bool>();
|
||||
|
||||
rebootMode = data["other"]["rebootMode"].as<bool>();
|
||||
rebootModeTime = data["other"]["rebootModeTime"].as<int>();
|
||||
|
||||
personalNote = data["personalNote"].as<String>();
|
||||
|
||||
webadmin.active = data["webadmin"]["active"].as<bool>();
|
||||
webadmin.username = data["webadmin"]["username"].as<String>();
|
||||
webadmin.password = data["webadmin"]["password"].as<String>();
|
||||
|
||||
int stationMode = data["stationMode"].as<int>(); // deprecated but need to specify config version
|
||||
|
||||
if (stationMode == 0) {
|
||||
// Load new settings
|
||||
|
||||
beacon.latitude = data["beacon"]["latitude"].as<double>();
|
||||
beacon.longitude = data["beacon"]["longitude"].as<double>();
|
||||
beacon.comment = data["beacon"]["comment"].as<String>();
|
||||
beacon.overlay = data["beacon"]["overlay"].as<String>();
|
||||
beacon.symbol = data["beacon"]["symbol"].as<String>();
|
||||
beacon.interval = data["beacon"]["interval"].as<int>();
|
||||
beacon.sendViaAPRSIS = data["beacon"]["sendViaAPRSIS"].as<bool>();
|
||||
beacon.sendViaRF = data["beacon"]["sendViaRF"].as<bool>();
|
||||
beacon.path = data["beacon"]["path"].as<String>();
|
||||
|
||||
digi.mode = data["digi"]["mode"].as<int>();
|
||||
|
||||
aprs_is.active = data["aprs_is"]["active"].as<bool>();
|
||||
aprs_is.filter = data["aprs_is"]["filter"].as<String>();
|
||||
aprs_is.messagesToRF = data["aprs_is"]["messagesToRF"].as<bool>();
|
||||
aprs_is.objectsToRF = data["aprs_is"]["objectsToRF"].as<bool>();
|
||||
|
||||
loramodule.txFreq = data["lora"]["txFreq"].as<long>();
|
||||
loramodule.rxFreq = data["lora"]["rxFreq"].as<long>();
|
||||
loramodule.txActive = data["lora"]["txActive"].as<bool>();
|
||||
loramodule.rxActive = data["lora"]["rxActive"].as<bool>();
|
||||
} else {
|
||||
// Load old settings and put into new variables not actual config
|
||||
|
||||
String iGateComment = data["iGateComment"].as<String>();
|
||||
int beaconInterval = data["other"]["beaconInterval"].as<int>();
|
||||
|
||||
long iGateFreq = data["lora"]["iGateFreq"].as<long>();
|
||||
long digirepeaterTxFreq = data["lora"]["digirepeaterTxFreq"].as<long>();
|
||||
long digirepeaterRxFreq = data["lora"]["digirepeaterRxFreq"].as<long>();
|
||||
beacon.latitude = data["beacon"]["latitude"] | 0.0;
|
||||
beacon.longitude = data["beacon"]["longitude"] | 0.0;
|
||||
beacon.comment = data["beacon"]["comment"] | "LoRa APRS";
|
||||
beacon.interval = data["beacon"]["interval"] | 15;
|
||||
beacon.overlay = data["beacon"]["overlay"] | "L";
|
||||
beacon.symbol = data["beacon"]["symbol"] | "a";
|
||||
beacon.path = data["beacon"]["path"] | "WIDE1-1";
|
||||
beacon.sendViaAPRSIS = data["beacon"]["sendViaAPRSIS"] | false;
|
||||
beacon.sendViaRF = data["beacon"]["sendViaRF"] | false;
|
||||
|
||||
String digiComment = data["digi"]["comment"].as<String>();
|
||||
double digiLatitude = data["digi"]["latitude"].as<double>();
|
||||
double digiLongitude = data["digi"]["longitude"].as<double>();
|
||||
aprs_is.active = data["aprs_is"]["active"] | false;
|
||||
aprs_is.passcode = data["aprs_is"]["passcode"] | "XYZWV";
|
||||
aprs_is.server = data["aprs_is"]["server"] | "rotate.aprs2.net";
|
||||
aprs_is.port = data["aprs_is"]["port"] | 14580;
|
||||
aprs_is.filter = data["aprs_is"]["filter"] | "m/10";
|
||||
aprs_is.messagesToRF = data["aprs_is"]["messagesToRF"] | false;
|
||||
aprs_is.objectsToRF = data["aprs_is"]["objectsToRF"] | false;
|
||||
|
||||
digi.mode = data["digi"]["mode"].as<int>();
|
||||
|
||||
beacon.latitude = digiLatitude;
|
||||
beacon.longitude = digiLongitude;
|
||||
beacon.interval = beaconInterval;
|
||||
loramodule.txFreq = data["lora"]["txFreq"] | 433775000;
|
||||
loramodule.rxFreq = data["lora"]["rxFreq"] | 433775000;
|
||||
loramodule.spreadingFactor = data["lora"]["spreadingFactor"] | 12;
|
||||
loramodule.signalBandwidth = data["lora"]["signalBandwidth"] | 125000;
|
||||
loramodule.codingRate4 = data["lora"]["codingRate4"] | 5;
|
||||
loramodule.power = data["lora"]["power"] | 20;
|
||||
loramodule.txActive = data["lora"]["txActive"] | false;
|
||||
loramodule.rxActive = data["lora"]["rxActive"] | false;
|
||||
|
||||
loramodule.txFreq = digirepeaterTxFreq;
|
||||
loramodule.rxFreq = digirepeaterRxFreq;
|
||||
loramodule.rxActive = true;
|
||||
beacon.sendViaAPRSIS = true;
|
||||
beacon.sendViaRF = false;
|
||||
display.alwaysOn = data["display"]["alwaysOn"] | true;
|
||||
display.timeout = data["display"]["timeout"] | 4;
|
||||
display.turn180 = data["display"]["turn180"] | false;
|
||||
|
||||
switch (stationMode) {
|
||||
case 1: // IGate only
|
||||
// aprs_is.active = true; // better don't do that automatically
|
||||
beacon.comment = iGateComment;
|
||||
loramodule.rxFreq = iGateFreq;
|
||||
break;
|
||||
case 5: // Digi + IGate
|
||||
case 2: // Digi + IGate
|
||||
// aprs_is.active = true; // better don't do that automatically
|
||||
// digi.mode = 2; // better don't do that automatically
|
||||
beacon.comment = digiComment;
|
||||
loramodule.rxFreq = iGateFreq;
|
||||
break;
|
||||
case 3: // Digi
|
||||
case 4: // Digi
|
||||
// digi.mode = 2; // better don't do that automatically
|
||||
beacon.comment = digiComment;
|
||||
break;
|
||||
}
|
||||
battery.sendInternalVoltage = data["battery"]["sendInternalVoltage"] | false;
|
||||
battery.monitorInternalVoltage = data["battery"]["monitorInternalVoltage"] | false;
|
||||
battery.internalSleepVoltage = data["battery"]["internalSleepVoltage"] | 3.0;
|
||||
|
||||
reload = true;
|
||||
}
|
||||
battery.sendExternalVoltage = data["battery"]["sendExternalVoltage"] | false;
|
||||
battery.externalVoltagePin = data["battery"]["externalVoltagePin"] | 34;
|
||||
battery.monitorExternalVoltage = data["battery"]["monitorExternalVoltage"] | false;
|
||||
battery.externalSleepVoltage = data["battery"]["externalSleepVoltage"] | false;
|
||||
battery.voltageDividerR1 = data["battery"]["voltageDividerR1"] | 100.0;
|
||||
battery.voltageDividerR2 = data["battery"]["voltageDividerR2"] | 27.0;
|
||||
|
||||
bme.active = data["bme"]["active"] | false;
|
||||
bme.heightCorrection = data["bme"]["heightCorrection"] | 0;
|
||||
bme.temperatureCorrection = data["bme"]["temperatureCorrection"] | 0.0;
|
||||
|
||||
syslog.active = data["syslog"]["active"] | false;
|
||||
syslog.server = data["syslog"]["server"] | "192.168.0.100";
|
||||
syslog.port = data["syslog"]["port"] | 514;
|
||||
|
||||
tnc.enableServer = data["tnc"]["enableServer"] | false;
|
||||
tnc.enableSerial = data["tnc"]["enableSerial"] | false;
|
||||
tnc.acceptOwn = data["tnc"]["acceptOwn"] | false;
|
||||
|
||||
ota.username = data["ota"]["username"] | "";
|
||||
ota.password = data["ota"]["password"] | "";
|
||||
|
||||
webadmin.active = data["webadmin"]["active"] | false;
|
||||
webadmin.username = data["webadmin"]["username"] | "admin";
|
||||
webadmin.password = data["webadmin"]["password"] | "";
|
||||
|
||||
lowPowerMode = data["other"]["lowPowerMode"] | false;
|
||||
lowVoltageCutOff = data["other"]["lowVoltageCutOff"] | 0;
|
||||
|
||||
backupDigiMode = data["other"]["backupDigiMode"] | false;
|
||||
|
||||
rebootMode = data["other"]["rebootMode"] | false;
|
||||
rebootModeTime = data["other"]["rebootModeTime"] | 6;
|
||||
|
||||
personalNote = data["personalNote"] | "personal note here...";
|
||||
|
||||
if (wifiAPs.size() == 0) { // If we don't have any WiFi's from config we need to add "empty" SSID for AUTO AP
|
||||
WiFi_AP wifiap;
|
||||
|
|
@ -286,7 +222,6 @@ bool Configuration::readFile() {
|
|||
}
|
||||
|
||||
void Configuration::init() {
|
||||
reload = false;
|
||||
|
||||
WiFi_AP wifiap;
|
||||
wifiap.ssid = "";
|
||||
|
|
@ -297,17 +232,17 @@ void Configuration::init() {
|
|||
wifiAutoAP.password = "1234567890";
|
||||
wifiAutoAP.powerOff = 15;
|
||||
|
||||
callsign = "N0CALL";
|
||||
callsign = "N0CALL-10";
|
||||
|
||||
beacon.comment = "LoRa APRS"; // new
|
||||
beacon.latitude = 0.0; // new
|
||||
beacon.longitude = 0.0; // new
|
||||
beacon.interval = 15; // new
|
||||
beacon.overlay = "L"; // new
|
||||
beacon.symbol = "#"; // new
|
||||
beacon.sendViaAPRSIS = true; // new
|
||||
beacon.sendViaRF = false; // new
|
||||
beacon.path = "WIDE1-1"; // new
|
||||
beacon.comment = "LoRa APRS";
|
||||
beacon.latitude = 0.0;
|
||||
beacon.longitude = 0.0;
|
||||
beacon.interval = 15;
|
||||
beacon.overlay = "L";
|
||||
beacon.symbol = "a";
|
||||
beacon.sendViaAPRSIS = true;
|
||||
beacon.sendViaRF = false;
|
||||
beacon.path = "WIDE1-1";
|
||||
|
||||
digi.mode = 0;
|
||||
|
||||
|
|
@ -315,22 +250,22 @@ void Configuration::init() {
|
|||
tnc.enableSerial = false;
|
||||
tnc.acceptOwn = false;
|
||||
|
||||
aprs_is.active = false; // new
|
||||
aprs_is.active = false;
|
||||
aprs_is.passcode = "XYZVW";
|
||||
aprs_is.server = "rotate.aprs2.net";
|
||||
aprs_is.port = 14580;
|
||||
aprs_is.filter = "m/10"; // new
|
||||
aprs_is.filter = "m/10";
|
||||
aprs_is.messagesToRF = false;
|
||||
aprs_is.objectsToRF = false;
|
||||
|
||||
loramodule.txFreq = 433775000; // new
|
||||
loramodule.rxFreq = 433775000; // new
|
||||
loramodule.txFreq = 433775000;
|
||||
loramodule.rxFreq = 433775000;
|
||||
loramodule.spreadingFactor = 12;
|
||||
loramodule.signalBandwidth = 125000;
|
||||
loramodule.codingRate4 = 5;
|
||||
loramodule.power = 20;
|
||||
loramodule.txActive = false; // new
|
||||
loramodule.rxActive = true; // new
|
||||
loramodule.txActive = false;
|
||||
loramodule.rxActive = true;
|
||||
|
||||
display.alwaysOn = true;
|
||||
display.timeout = 4;
|
||||
|
|
@ -356,9 +291,9 @@ void Configuration::init() {
|
|||
battery.sendExternalVoltage = false;
|
||||
battery.externalVoltagePin = 34;
|
||||
battery.monitorExternalVoltage = false;
|
||||
battery.externalSleepVoltage = 3.0;
|
||||
battery.voltageDividerR1 = 100.0;
|
||||
battery.voltageDividerR2 = 27.0;
|
||||
battery.externalSleepVoltage = 10.9;
|
||||
battery.voltageDividerR1 = 100.0;
|
||||
battery.voltageDividerR2 = 27.0;
|
||||
|
||||
lowPowerMode = false;
|
||||
lowVoltageCutOff = 0;
|
||||
|
|
|
|||
|
|
@ -115,7 +115,6 @@ public:
|
|||
|
||||
class Configuration {
|
||||
public:
|
||||
bool reload; // ?
|
||||
String callsign;
|
||||
int rememberStationTime;
|
||||
bool lowPowerMode;
|
||||
|
|
@ -140,7 +139,6 @@ public:
|
|||
|
||||
void init();
|
||||
void writeFile();
|
||||
void check();
|
||||
Configuration();
|
||||
|
||||
private:
|
||||
|
|
|
|||
Loading…
Reference in New Issue