diff --git a/data/igate_conf.json b/data/igate_conf.json index b56deb68..16089949 100644 --- a/data/igate_conf.json +++ b/data/igate_conf.json @@ -72,6 +72,8 @@ "externalVoltagePin": 34, "lowPowerMode": false, "lowVoltageCutOff": 0, - "backupDigiMode": false + "backupDigiMode": false, + "rebootMode": false, + "rebootModeTime": 0 } } \ No newline at end of file diff --git a/data_embed/index.html b/data_embed/index.html index c803df63..31bb8e24 100644 --- a/data_embed/index.html +++ b/data_embed/index.html @@ -617,6 +617,70 @@

+
+
+
+ + + + Reboot Time +
+
+
+
+
+
+ + +
+
+
+
+
+ +
+ + hours +
+
+
+
+
+
+
@@ -1399,6 +1463,9 @@
step="0.01" class="form-control" /> + Volts
MCU will deep sleep when below provided battery voltage to save power. Set to 0 if you don't want this option. Please calibrate your voltage reading first!
diff --git a/data_embed/script.js b/data_embed/script.js index 900fd211..d3a285a4 100644 --- a/data_embed/script.js +++ b/data_embed/script.js @@ -167,10 +167,8 @@ function loadSettings(settings) { document.getElementById("other.sendBatteryVoltage").checked = settings.other.sendBatteryVoltage; document.getElementById("other.externalVoltageMeasurement").checked = settings.other.externalVoltageMeasurement; document.getElementById("other.externalVoltagePin").value = settings.other.externalVoltagePin; - // document.getElementById("beacon.igateSendsLoRaBeacon").value = - // settings.beacon.igateSendsLoRaBeacon; - // document.getElementById("beacon.igateRepeatLoRaPackets").value = - // settings.beacon.igateRepeatLoRaPackets; + // document.getElementById("beacon.igateSendsLoRaBeacon").value = settings.beacon.igateSendsLoRaBeacon; + // document.getElementById("beacon.igateRepeatLoRaPackets").value = settings.beacon.igateRepeatLoRaPackets; document.getElementById("beacon.path").value = settings.beacon.path; document.getElementById("beacon.latitude").value = settings.beacon.latitude; document.getElementById("beacon.longitude").value = settings.beacon.longitude; @@ -188,11 +186,9 @@ function loadSettings(settings) { } // LoRa - // document.getElementById("lora.digirepeaterTxFreq").value = - // settings.lora.digirepeaterTxFreq; + // document.getElementById("lora.digirepeaterTxFreq").value = settings.lora.digirepeaterTxFreq; // document.getElementById("lora.iGateFreq").value = settings.lora.iGateFreq; - // document.getElementById("lora.digirepeaterRxFreq").value = - // settings.lora.digirepeaterRxFreq; + // document.getElementById("lora.digirepeaterRxFreq").value = settings.lora.digirepeaterRxFreq; document.getElementById("lora.txFreq").value = settings.lora.txFreq; document.getElementById("lora.rxFreq").value = settings.lora.rxFreq; document.getElementById("lora.txActive").checked = settings.lora.txActive; @@ -202,6 +198,10 @@ function loadSettings(settings) { document.getElementById("lora.codingRate4").value = settings.lora.codingRate4; document.getElementById("lora.power").value = settings.lora.power; + // Reboot + document.getElementById("other.rebootMode").checked = settings.other.rebootMode; + document.getElementById("other.rebootModeTime").value = settings.other.rebootModeTime; + // Experimental document.getElementById("other.backupDigiMode").checked = settings.other.backupDigiMode; diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index 78b429f5..c5e514e9 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -119,6 +119,7 @@ void setup() { #ifdef ESP32_DIY_LoRa_A7670 A7670_Utils::setup(); #endif + Utils::checkRebootMode(); } void loop() { @@ -181,4 +182,5 @@ void loop() { STATION_Utils::clean25SegBuffer(); show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0); + Utils::checkRebootTime(); } \ No newline at end of file diff --git a/src/configuration.cpp b/src/configuration.cpp index 45c23b7d..d6c9da1f 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -29,83 +29,86 @@ void Configuration::writeFile() { } } - data["wifi"]["autoAP"]["password"] = wifiAutoAP.password; - data["wifi"]["autoAP"]["powerOff"] = wifiAutoAP.powerOff; + data["wifi"]["autoAP"]["password"] = wifiAutoAP.password; + data["wifi"]["autoAP"]["powerOff"] = wifiAutoAP.powerOff; - data["callsign"] = callsign; + data["callsign"] = callsign; // data["stationMode"] = stationMode; // only check for config version // data["iGateComment"] = iGateComment; // data["other"]["beaconInterval"] = beaconInterval; // data["other"]["igateSendsLoRaBeacons"] = igateSendsLoRaBeacons; // data["other"]["igateRepeatsLoRaPackets"] = igateRepeatsLoRaPackets; - data["other"]["rememberStationTime"] = rememberStationTime; - data["other"]["sendBatteryVoltage"] = sendBatteryVoltage; + data["other"]["rememberStationTime"] = rememberStationTime; + data["other"]["sendBatteryVoltage"] = sendBatteryVoltage; data["other"]["externalVoltageMeasurement"] = externalVoltageMeasurement; - data["other"]["externalVoltagePin"] = externalVoltagePin; + data["other"]["externalVoltagePin"] = externalVoltagePin; - data["digi"]["mode"] = digi.mode; + data["digi"]["mode"] = digi.mode; // data["digi"]["comment"] = digi.comment; // data["digi"]["latitude"] = digi.latitude; // data["digi"]["longitude"] = digi.longitude; - data["tnc"]["enableServer"] = tnc.enableServer; - data["tnc"]["enableSerial"] = tnc.enableSerial; - data["tnc"]["acceptOwn"] = tnc.acceptOwn; + data["tnc"]["enableServer"] = tnc.enableServer; + data["tnc"]["enableSerial"] = tnc.enableSerial; + data["tnc"]["acceptOwn"] = tnc.acceptOwn; - data["aprs_is"]["active"] = aprs_is.active; - data["aprs_is"]["passcode"] = aprs_is.passcode; - data["aprs_is"]["server"] = aprs_is.server; - data["aprs_is"]["port"] = aprs_is.port; - data["aprs_is"]["filter"] = aprs_is.filter; + data["aprs_is"]["active"] = aprs_is.active; + data["aprs_is"]["passcode"] = aprs_is.passcode; + data["aprs_is"]["server"] = aprs_is.server; + data["aprs_is"]["port"] = aprs_is.port; + data["aprs_is"]["filter"] = aprs_is.filter; //data["aprs_is"]["toRF"] = aprs_is.toRF; - data["aprs_is"]["messagesToRF"] = aprs_is.messagesToRF; - data["aprs_is"]["objectsToRF"] = aprs_is.objectsToRF; + data["aprs_is"]["messagesToRF"] = aprs_is.messagesToRF; + data["aprs_is"]["objectsToRF"] = aprs_is.objectsToRF; - data["beacon"]["comment"] = beacon.comment; + data["beacon"]["comment"] = beacon.comment; // data["beacon"]["igateRepeatsLoRaPackets"] = beacon.igateRepeatsLoRaPackets; // data["beacon"]["igateSendsLoRaBeacons"] = beacon.igateSendsLoRaBeacons; - data["beacon"]["interval"] = beacon.interval; - data["beacon"]["latitude"] = beacon.latitude; - data["beacon"]["longitude"] = beacon.longitude; - data["beacon"]["overlay"] = beacon.overlay; - data["beacon"]["symbol"] = beacon.symbol; - data["beacon"]["sendViaAPRSIS"] = beacon.sendViaAPRSIS; - data["beacon"]["sendViaRF"] = beacon.sendViaRF; - data["beacon"]["path"] = beacon.path; + data["beacon"]["interval"] = beacon.interval; + data["beacon"]["latitude"] = beacon.latitude; + data["beacon"]["longitude"] = beacon.longitude; + data["beacon"]["overlay"] = beacon.overlay; + data["beacon"]["symbol"] = beacon.symbol; + data["beacon"]["sendViaAPRSIS"] = beacon.sendViaAPRSIS; + data["beacon"]["sendViaRF"] = beacon.sendViaRF; + data["beacon"]["path"] = beacon.path; // data["lora"]["iGateFreq"] = loramodule.iGateFreq; // data["lora"]["digirepeaterTxFreq"] = loramodule.digirepeaterTxFreq; // data["lora"]["digirepeaterRxFreq"] = loramodule.digirepeaterRxFreq; - data["lora"]["rxFreq"] = loramodule.rxFreq; - data["lora"]["txFreq"] = loramodule.txFreq; - data["lora"]["spreadingFactor"] = loramodule.spreadingFactor; - data["lora"]["signalBandwidth"] = loramodule.signalBandwidth; - data["lora"]["codingRate4"] = loramodule.codingRate4; - data["lora"]["power"] = loramodule.power; - data["lora"]["txActive"] = loramodule.txActive; - data["lora"]["rxActive"] = loramodule.rxActive; + data["lora"]["rxFreq"] = loramodule.rxFreq; + data["lora"]["txFreq"] = loramodule.txFreq; + data["lora"]["spreadingFactor"] = loramodule.spreadingFactor; + data["lora"]["signalBandwidth"] = loramodule.signalBandwidth; + data["lora"]["codingRate4"] = loramodule.codingRate4; + data["lora"]["power"] = loramodule.power; + data["lora"]["txActive"] = loramodule.txActive; + data["lora"]["rxActive"] = loramodule.rxActive; - data["display"]["alwaysOn"] = display.alwaysOn; - data["display"]["timeout"] = display.timeout; - data["display"]["turn180"] = display.turn180; + data["display"]["alwaysOn"] = display.alwaysOn; + data["display"]["timeout"] = display.timeout; + data["display"]["turn180"] = display.turn180; - data["syslog"]["active"] = syslog.active; - data["syslog"]["server"] = syslog.server; - data["syslog"]["port"] = syslog.port; + data["syslog"]["active"] = syslog.active; + data["syslog"]["server"] = syslog.server; + data["syslog"]["port"] = syslog.port; - data["bme"]["active"] = bme.active; - data["bme"]["heightCorrection"] = bme.heightCorrection; - data["bme"]["temperatureCorrection"] = bme.temperatureCorrection; + data["bme"]["active"] = bme.active; + data["bme"]["heightCorrection"] = bme.heightCorrection; + data["bme"]["temperatureCorrection"] = bme.temperatureCorrection; - data["ota"]["username"] = ota.username; - data["ota"]["password"] = ota.password; + data["ota"]["username"] = ota.username; + data["ota"]["password"] = ota.password; - data["other"]["lowPowerMode"] = lowPowerMode; - data["other"]["lowVoltageCutOff"] = lowVoltageCutOff; + data["other"]["lowPowerMode"] = lowPowerMode; + data["other"]["lowVoltageCutOff"] = lowVoltageCutOff; - data["other"]["backupDigiMode"] = backupDigiMode; + data["other"]["backupDigiMode"] = backupDigiMode; + + data["other"]["rebootMode"] = rebootMode; + data["other"]["rebootModeTime"] = rebootModeTime; serializeJson(data, configFile); @@ -178,7 +181,10 @@ bool Configuration::readFile() { backupDigiMode = data["other"]["backupDigiMode"].as(); - int stationMode = data["stationMode"].as(); // deprecated but need to specify config version + rebootMode = data["other"]["rebootMode"].as(); + rebootModeTime = data["other"]["rebootModeTime"].as(); + + int stationMode = data["stationMode"].as(); // deprecated but need to specify config version if (stationMode == 0) { // Load new settings @@ -360,6 +366,9 @@ void Configuration::init() { backupDigiMode = false; + rebootMode = false; + rebootModeTime = 0; + Serial.println("All is Written!"); } diff --git a/src/configuration.h b/src/configuration.h index 991e9e4d..0dd47175 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -121,6 +121,8 @@ class Configuration { bool lowPowerMode; double lowVoltageCutOff; bool backupDigiMode; + bool rebootMode; + int rebootModeTime; std::vector wifiAPs; WiFi_Auto_AP wifiAutoAP; Beacon beacon; // new diff --git a/src/utils.cpp b/src/utils.cpp index 4e643f3b..d3b17bd9 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -262,4 +262,19 @@ namespace Utils { } } + void checkRebootMode() { + if (Config.rebootMode && Config.rebootModeTime > 0) { + Serial.println("(Reboot Time Set to " + String(Config.rebootModeTime) + " hours)"); + } + } + + void checkRebootTime() { + if (Config.rebootMode && Config.rebootModeTime > 0) { + if (millis() > Config.rebootModeTime * 60 * 60 * 1000) { + Serial.println("\n*** Automatic Reboot Time Restart! ****\n"); + ESP.restart(); + } + } + } + } \ No newline at end of file diff --git a/src/utils.h b/src/utils.h index f19270d7..599cd68a 100644 --- a/src/utils.h +++ b/src/utils.h @@ -24,6 +24,8 @@ namespace Utils { void typeOfPacket(const String& packet, uint8_t packetType); void print(const String& text); void println(const String& text); + void checkRebootMode(); + void checkRebootTime(); } diff --git a/src/web_utils.cpp b/src/web_utils.cpp index b42651b6..75657a66 100644 --- a/src/web_utils.cpp +++ b/src/web_utils.cpp @@ -179,6 +179,9 @@ namespace WEB_Utils { Config.externalVoltagePin = request->getParam("other.externalVoltagePin", true)->value().toInt(); } + Config.rebootMode = request->hasParam("other.rebootMode", true); + Config.rebootModeTime = request->getParam("other.rebootModeTime", true)->value().toInt(); + Config.lowPowerMode = request->hasParam("other.lowPowerMode", true); Config.lowVoltageCutOff = request->getParam("other.lowVoltageCutOff", true)->value().toDouble();