From 5f5d7d7868c85bf28b946611a64bbe2a34b437a9 Mon Sep 17 00:00:00 2001 From: richonguzman Date: Tue, 18 Mar 2025 14:02:09 -0300 Subject: [PATCH] ready for test --- src/LoRa_APRS_iGate.cpp | 2 +- src/aprs_is_utils.cpp | 3 +- src/query_utils.cpp | 88 ++++++++++++++++++++++++++--------------- 3 files changed, 60 insertions(+), 33 deletions(-) diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index 5948d54..ec76c3b 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -47,7 +47,7 @@ ___________________________________________________________________*/ #endif -String versionDate = "2025.03.10"; +String versionDate = "2025.03.18"; Configuration Config; WiFiClient espClient; #ifdef HAS_GPS diff --git a/src/aprs_is_utils.cpp b/src/aprs_is_utils.cpp index 17292c8..c8f53cf 100644 --- a/src/aprs_is_utils.cpp +++ b/src/aprs_is_utils.cpp @@ -59,7 +59,7 @@ namespace APRS_IS_Utils { aprsAuth += Config.callsign; aprsAuth += " pass "; aprsAuth += Config.aprs_is.passcode; - aprsAuth += " vers CA2RXU_LoRa_iGate 2.0 filter "; + aprsAuth += " vers CA2RXU_iGate 2.3 filter "; aprsAuth += Config.aprs_is.filter; upload(aprsAuth); } @@ -298,6 +298,7 @@ namespace APRS_IS_Utils { } if (receivedMessage.indexOf("?") == 0) { Utils::println("Rx Query (APRS-IS) : " + packet); + Sender.trim(); String queryAnswer = QUERY_Utils::process(receivedMessage, Sender, true, false); //Serial.println("---> QUERY Answer : " + queryAnswer.substring(0,queryAnswer.indexOf("\n"))); if (!Config.display.alwaysOn && Config.display.timeout != 0) { diff --git a/src/query_utils.cpp b/src/query_utils.cpp index 0d9aeab..52b89ca 100644 --- a/src/query_utils.cpp +++ b/src/query_utils.cpp @@ -22,9 +22,9 @@ namespace QUERY_Utils { String queryQuestion = query; queryQuestion.toUpperCase(); if (queryQuestion == "?APRS?" || queryQuestion == "H" || queryQuestion == "HELP" || queryQuestion=="?") { - answer.concat("?APRSV ?APRSP ?APRSL ?APRSH ?WHERE callsign"); + answer.concat("?APRSV ?APRSP ?APRSL ?APRSSSR ?EM=? ?TX=? "); // ?APRSH ?WHERE callsign } else if (queryQuestion == "?APRSV") { - answer.concat("CA2RXU_LoRa_iGate 2.0 v"); + answer.concat("CA2RXU_LoRa_iGate 2.3 v"); answer.concat(versionDate); } else if (queryQuestion == "?APRSP") { answer.concat("iGate QTH: "); @@ -46,48 +46,69 @@ namespace QUERY_Utils { char signalData[35]; snprintf(signalData, sizeof(signalData), " %ddBm / %.2fdB / %dHz", rssi, snr, freqError); answer.concat(signalData); - } else if (queryQuestion.indexOf("?APRSH") == 0) { + } /*else if (queryQuestion.indexOf("?APRSH") == 0) { // sacar callsign despues de ?APRSH Serial.println("escuchaste a X estacion? en las ultimas 24 o 8 horas?"); answer.concat("?APRSH on development 73!"); - } else if (queryQuestion.indexOf("?WHERE") == 0) { + } *//*else if (queryQuestion.indexOf("?WHERE") == 0) { // 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 && Config.digi.ecoMode == true) { // Exit Digipeater EcoMode - answer = "DigiEcoMode:Stop"; - 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; - 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"; - } else if (STATION_Utils::isManager(station) && (!queryFromAPRSIS || !Config.remoteManagement.rfOnly)) { - if (queryQuestion.indexOf("?TX=ON") == 0) { - Config.loramodule.txActive = true; - // - Serial.println("TX=ON"); - answer = "TX=ON"; - // change status? + } */ + else if (STATION_Utils::isManager(station) && (!queryFromAPRSIS || !Config.remoteManagement.rfOnly)) { + if (queryQuestion.indexOf("?EM=OFF") == 0) { + if ((Config.digi.mode == 2 || Config.digi.mode == 3) && Config.loramodule.txActive && Config.loramodule.rxActive) { + if (Config.digi.ecoMode) { // Exit Digipeater EcoMode + answer = "DigiEcoMode:OFF"; + 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 { + answer = "DigiEcoMode was OFF"; + } + } else { + answer = "DigiEcoMode control not possible"; + } + } else if (queryQuestion.indexOf("?EM=ON") == 0) { + if ((Config.digi.mode == 2 || Config.digi.mode == 3) && Config.loramodule.txActive && Config.loramodule.rxActive) { + if (!Config.digi.ecoMode) { // Start Digipeater EcoMode + answer = "DigiEcoMode:ON"; + Config.digi.ecoMode = true; + shouldSleepLowVoltage = true; // to make sure all packets in outputPacketBuffer are sended before restart. + saveNewDigiEcoModeConfig = true; + } else { + answer = "DigiEcoMode was ON"; + } + } else { + answer = "DigiEcoMode control not possible"; + } + } else if (queryQuestion.indexOf("?EM=?") == 0) { // Digipeater EcoMode Status + answer = (Config.digi.ecoMode) ? "DigiEcoMode:ON" : "DigiEcoMode:OFF"; + } else if (queryQuestion.indexOf("?TX=ON") == 0) { + if (Config.loramodule.txActive) { + answer = "TX was ON"; + } else { + Config.loramodule.txActive = true; + answer = "TX=ON"; + } } else if (queryQuestion.indexOf("?TX=OFF") == 0) { - Config.loramodule.txActive = false; - // - Serial.println("TX=OFF"); - answer = "TX=OFF"; - // change status? + if (!Config.loramodule.txActive) { + answer = "TX was OFF"; + } else { + Config.loramodule.txActive = false; + answer = "TX=OFF"; + } } else if (queryQuestion.indexOf("?TX=?") == 0) { answer = (Config.loramodule.txActive) ? "TX=ON" : "TX=OFF"; - } else if (queryQuestion.indexOf("?COMMIT") == 0) { // when, after changing state???? + } else if (queryQuestion.indexOf("?COMMIT") == 0) { // saving for next reboot answer = "New Config Saved"; Config.writeFile(); } } + + if (answer == "") return ""; String queryAnswer = Config.callsign; queryAnswer += ">APLRG1"; @@ -109,6 +130,11 @@ namespace QUERY_Utils { queryAnswer += processedStation; queryAnswer += ":"; queryAnswer += answer; + + queryAnswer += " *"; + queryAnswer += char(random(97, 123)); + queryAnswer += char(random(97, 123)); + queryAnswer += "*"; return queryAnswer; }