From 1365ae67a14a0df98a36d790c69825800fae0d70 Mon Sep 17 00:00:00 2001 From: richonguzman Date: Wed, 27 Mar 2024 11:26:02 -0300 Subject: [PATCH] update in APRS listening --- src/LoRa_APRS_iGate.cpp | 6 +++- src/aprs_is_utils.cpp | 66 +++++++++++++++++++---------------------- src/aprs_is_utils.h | 2 +- 3 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index 13f97e77..dcd8cc1f 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -124,7 +124,7 @@ void loop() { if (packet != "") { if (Config.aprs_is.active) { // If APRSIS enabled - APRS_IS_Utils::loop(packet); // Send received packet to APRSIS + APRS_IS_Utils::processLoRaPacket(packet); // Send received packet to APRSIS } if (Config.digi.mode == 2) { // If Digi enabled @@ -140,5 +140,9 @@ void loop() { } } + if (Config.aprs_is.active) { // If APRSIS enabled + APRS_IS_Utils::listenAPRSIS(); // listen received packet from APRSIS + } + show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0); } \ No newline at end of file diff --git a/src/aprs_is_utils.cpp b/src/aprs_is_utils.cpp index 51e33831..0e1360a4 100644 --- a/src/aprs_is_utils.cpp +++ b/src/aprs_is_utils.cpp @@ -131,33 +131,35 @@ namespace APRS_IS_Utils { } void processLoRaPacket(String packet) { - bool queryMessage = false; - String aprsPacket, Sender, AddresseeAndMessage, Addressee; - if (packet != "") { - if ((packet.substring(0, 3) == "\x3c\xff\x01") && (packet.indexOf("TCPIP") == -1) && (packet.indexOf("NOGATE") == -1) && (packet.indexOf("RFONLY") == -1)) { - Sender = packet.substring(3, packet.indexOf(">")); - STATION_Utils::updateLastHeard(Sender); - //STATION_Utils::updatePacketBuffer(packet); - Utils::typeOfPacket(aprsPacket, "LoRa-APRS"); - if (Sender != Config.callsign) { // avoid listening yourself by digirepeating - AddresseeAndMessage = packet.substring(packet.indexOf("::") + 2); - Addressee = AddresseeAndMessage.substring(0, AddresseeAndMessage.indexOf(":")); - Addressee.trim(); - - if (packet.indexOf("::") > 10 && Addressee == Config.callsign) { // its a message for me! - queryMessage = processReceivedLoRaMessage(Sender, AddresseeAndMessage); - } - if (!queryMessage) { - aprsPacket = createPacket(packet); - if (!Config.display.alwaysOn) { - display_toggle(true); + if (espClient.connected()) { + bool queryMessage = false; + String aprsPacket, Sender, AddresseeAndMessage, Addressee; + if (packet != "") { + if ((packet.substring(0, 3) == "\x3c\xff\x01") && (packet.indexOf("TCPIP") == -1) && (packet.indexOf("NOGATE") == -1) && (packet.indexOf("RFONLY") == -1)) { + Sender = packet.substring(3, packet.indexOf(">")); + STATION_Utils::updateLastHeard(Sender); + //STATION_Utils::updatePacketBuffer(packet); + Utils::typeOfPacket(aprsPacket, "LoRa-APRS"); + if (Sender != Config.callsign) { // avoid listening yourself by digirepeating + AddresseeAndMessage = packet.substring(packet.indexOf("::") + 2); + Addressee = AddresseeAndMessage.substring(0, AddresseeAndMessage.indexOf(":")); + Addressee.trim(); + + if (packet.indexOf("::") > 10 && Addressee == Config.callsign) { // its a message for me! + queryMessage = processReceivedLoRaMessage(Sender, AddresseeAndMessage); + } + if (!queryMessage) { + aprsPacket = createPacket(packet); + if (!Config.display.alwaysOn) { + display_toggle(true); + } + lastScreenOn = millis(); + upload(aprsPacket); + Utils::println("---> Uploaded to APRS-IS"); + STATION_Utils::updateLastHeard(Sender); + Utils::typeOfPacket(aprsPacket, "LoRa-APRS"); + show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0); } - lastScreenOn = millis(); - upload(aprsPacket); - Utils::println("---> Uploaded to APRS-IS"); - STATION_Utils::updateLastHeard(Sender); - Utils::typeOfPacket(aprsPacket, "LoRa-APRS"); - show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0); } } } @@ -183,8 +185,7 @@ namespace APRS_IS_Utils { String ackPacket = Config.callsign + ">APLRG1,TCPIP,qAC::" + Sender + ":" + ackMessage;// + "\n"; upload(ackPacket); receivedMessage = AddresseeAndMessage.substring(AddresseeAndMessage.indexOf(":") + 1, AddresseeAndMessage.indexOf("{")); - } - else { + } else { receivedMessage = AddresseeAndMessage.substring(AddresseeAndMessage.indexOf(":") + 1); } if (receivedMessage.indexOf("?") == 0) { @@ -206,8 +207,7 @@ namespace APRS_IS_Utils { sixthLine += "> " + Sender; seventhLine = "QUERY = " + receivedMessage; } - } - else { + } else { Utils::print("Received from APRS-IS : " + packet); if (Config.aprs_is.toRF && STATION_Utils::wasHeard(Addressee)) { @@ -222,15 +222,11 @@ namespace APRS_IS_Utils { } } - void loop(String packet) { + void listenAPRSIS() { if (espClient.connected()) { - processLoRaPacket(packet); - if (espClient.available()) { String aprsisPacket = espClient.readStringUntil('\r'); - // Serial.println(aprsisPacket); - processAPRSISPacket(aprsisPacket); } } diff --git a/src/aprs_is_utils.h b/src/aprs_is_utils.h index c21f19b6..64701e67 100644 --- a/src/aprs_is_utils.h +++ b/src/aprs_is_utils.h @@ -13,7 +13,7 @@ namespace APRS_IS_Utils { bool processReceivedLoRaMessage(String sender, String packet); void processLoRaPacket(String packet); void processAPRSISPacket(String packet); - void loop(String packet); + void listenAPRSIS(); }