From ad5a5ccf1853e88dbb282ac2d9c1f66d6d974c08 Mon Sep 17 00:00:00 2001 From: richonguzman Date: Tue, 31 Dec 2024 17:40:16 -0300 Subject: [PATCH] digiEcoMode fix --- src/LoRa_APRS_iGate.cpp | 2 +- src/query_utils.cpp | 15 +++++++++++---- src/station_utils.cpp | 9 ++++----- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index 1db8b55..617c2c2 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -48,7 +48,7 @@ ___________________________________________________________________*/ #include "A7670_utils.h" #endif -String versionDate = "2024.12.30"; +String versionDate = "2024.12.31"; Configuration Config; WiFiClient espClient; #ifdef HAS_GPS diff --git a/src/query_utils.cpp b/src/query_utils.cpp index 6f032af..e12d88e 100644 --- a/src/query_utils.cpp +++ b/src/query_utils.cpp @@ -1,4 +1,5 @@ #include "configuration.h" +#include "battery_utils.h" #include "station_utils.h" #include "query_utils.h" #include "lora_utils.h" @@ -10,6 +11,8 @@ extern String versionDate; extern int rssi; extern float snr; extern int freqError; +extern bool shouldSleepLowVoltage; +extern bool saveNewDigiEcoModeConfig; namespace QUERY_Utils { @@ -53,12 +56,16 @@ namespace QUERY_Utils { answer.concat("?WHERE on development 73!"); } else if (queryQuestion.indexOf("?APRSEEM") == 0 && Config.digi.ecoMode == true) { // Exit Digipeater EcoMode answer = "DigiEcoMode:Stop"; - Config.digi.ecoMode = false; - Config.display.alwaysOn = true; - Config.display.timeout = 10; + Config.digi.ecoMode = false; + Config.display.alwaysOn = true; + Config.display.timeout = 10; + shouldSleepLowVoltage = true; // to make sure all packets in outputPacketBuffer are sended before restart. + saveNewDigiEcoModeConfig = true; } else if (queryQuestion.indexOf("?APRSSEM") == 0 && Config.digi.ecoMode == false) { // Start Digipeater EcoMode answer = "DigiEcoMode:Start"; - Config.digi.ecoMode = true; + Config.digi.ecoMode = true; + shouldSleepLowVoltage = true; // to make sure all packets in outputPacketBuffer are sended before restart. + saveNewDigiEcoModeConfig = true; } else if (queryQuestion.indexOf("?APRSEMS") == 0) { // Digipeater EcoMode Status answer = (Config.digi.ecoMode) ? "DigiEcoMode:ON" : "DigiEcoMode:OFF"; } diff --git a/src/station_utils.cpp b/src/station_utils.cpp index 270fa61..1bae7a5 100644 --- a/src/station_utils.cpp +++ b/src/station_utils.cpp @@ -17,6 +17,8 @@ std::vector lastHeardStations; std::vector outputPacketBuffer; std::vector packet25SegBuffer; +bool saveNewDigiEcoModeConfig = false; + namespace STATION_Utils { @@ -92,13 +94,8 @@ namespace STATION_Utils { int timeToWait = 3 * 1000; // 3 segs between packet Tx and also Rx ??? uint32_t lastRx = millis() - lastRxTime; uint32_t lastTx = millis() - lastTxTime; - bool saveNewDigiEcoModeConfig = false; if (outputPacketBuffer.size() > 0 && lastTx > timeToWait && lastRx > timeToWait) { LoRa_Utils::sendNewPacket(outputPacketBuffer[0]); - if (outputPacketBuffer[0].indexOf("DigiEcoMode:Start") != -1 || outputPacketBuffer[0].indexOf("DigiEcoMode:Stop") != -1) { - saveNewDigiEcoModeConfig = true; - shouldSleepLowVoltage = true; // to make sure all packets in outputPacketBuffer are sended before restart. - } outputPacketBuffer.erase(outputPacketBuffer.begin()); lastTxTime = millis(); } @@ -110,7 +107,9 @@ namespace STATION_Utils { } } if (saveNewDigiEcoModeConfig) { + setCpuFrequencyMhz(80); Config.writeFile(); + delay(1000); displayToggle(false); ESP.restart(); }