From a786d83b9e145300397ab8e71f099d2314dfe44b Mon Sep 17 00:00:00 2001 From: richonguzman Date: Tue, 8 Oct 2024 12:19:22 -0300 Subject: [PATCH] Queries for DigiEcoMode --- src/aprs_is_utils.cpp | 3 ++- src/query_utils.cpp | 11 +++++++++++ src/station_utils.cpp | 17 ++++++++++++++--- src/utils.cpp | 1 + 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/aprs_is_utils.cpp b/src/aprs_is_utils.cpp index e5ce1ee2..5a525075 100644 --- a/src/aprs_is_utils.cpp +++ b/src/aprs_is_utils.cpp @@ -138,7 +138,8 @@ namespace APRS_IS_Utils { //Serial.println(ackMessage); String addToBuffer = Config.callsign; - addToBuffer += ">APLRG1,RFONLY"; + addToBuffer += ">APLRG1"; + if (!thirdParty) addToBuffer += ",RFONLY"; if (Config.beacon.path != "") { addToBuffer += ","; addToBuffer += Config.beacon.path; diff --git a/src/query_utils.cpp b/src/query_utils.cpp index 8471455c..6ba02ca4 100644 --- a/src/query_utils.cpp +++ b/src/query_utils.cpp @@ -3,6 +3,7 @@ #include "query_utils.h" #include "lora_utils.h" + extern Configuration Config; extern std::vector lastHeardStations; extern String versionDate; @@ -50,6 +51,16 @@ namespace QUERY_Utils { // agregar callsign para completar donde esta X callsign --> posicion Serial.println("estaciones escuchadas directo (ultimos 30 min)"); answer.concat("?WHERE on development 73!"); + } else if (queryQuestion.indexOf("?APRSEEM") == 0) { // Exit DigiRepeater EcoMode + answer = "DigiEcoMode:Stop"; + Config.digi.ecoMode = false; + Config.display.alwaysOn = true; + Config.display.timeout = 10; + } else if (queryQuestion.indexOf("?APRSSEM") == 0) { // Start DigiRepeater EcoMode + answer = "DigiEcoMode:Start"; + Config.digi.ecoMode = true; + } else if (queryQuestion.indexOf("?APRSEMS") == 0) { // DigiRepeater EcoMode Status + answer = (Config.digi.ecoMode) ? "DigiEcoMode:ON" : "DigiEcoMode:OFF"; } String queryAnswer = Config.callsign; diff --git a/src/station_utils.cpp b/src/station_utils.cpp index 4e2f5454..3eebc287 100644 --- a/src/station_utils.cpp +++ b/src/station_utils.cpp @@ -3,6 +3,7 @@ #include "aprs_is_utils.h" #include "configuration.h" #include "lora_utils.h" +#include "display.h" #include "utils.h" #include @@ -100,11 +101,16 @@ namespace STATION_Utils { } void processOutputPacketBuffer() { - int timeToWait = 3 * 1000; // 3 segs between packet Tx and also Rx ??? - uint32_t lastRx = millis() - lastRxTime; - uint32_t lastTx = millis() - lastTxTime; + 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(); } @@ -115,6 +121,11 @@ namespace STATION_Utils { delay(4000); } } + if (saveNewDigiEcoModeConfig) { + Config.writeFile(); + displayToggle(false); + ESP.restart(); + } } void addToOutputPacketBuffer(const String& packet) { diff --git a/src/utils.cpp b/src/utils.cpp index 8c396659..bfc6953a 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -87,6 +87,7 @@ namespace Utils { digitalWrite(INTERNAL_LED_PIN,HIGH); #endif Serial.println("\nStarting Station: " + Config.callsign + " Version: " + versionDate); + Serial.println((Config.digi.ecoMode) ? "(DigiEcoMode: ON)" : "(DigiEcoMode: OFF)"); displayShow(" LoRa APRS", "", "", " ( iGATE & DIGI )", "", "" , " CA2RXU " + versionDate, 4000); #ifdef INTERNAL_LED_PIN digitalWrite(INTERNAL_LED_PIN,LOW);