diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index 05b8ec3..6415d68 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -17,12 +17,11 @@ #include #include */ -#define VERSION "2023.06.08" - Configuration Config; WiFiClient espClient; //AsyncWebServer server(80); +String versionDate = "2023.06.08"; int myWiFiAPIndex = 0; int myWiFiAPSize = Config.wifiAPs.size(); WiFi_AP *currentWiFi = &Config.wifiAPs[myWiFiAPIndex]; @@ -43,13 +42,10 @@ void setup() { Serial.begin(115200); delay(1000); utils::setupDiplay(); - Serial.println("\nStarting iGate: " + Config.callsign + " Version: " + String(VERSION)); - show_display(" LoRa APRS iGate", " Richonguzman", " -- CD2RXU --", " " VERSION, 4000); WIFI_Utils::setup(); LoRa_Utils::setup(); utils::validateDigiFreqs(); iGateBeaconPacket = GPS_Utils::generateBeacon(); - /*server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) { request->send(200, "text/plain", "Hi! I am ESP32."); }); @@ -65,14 +61,6 @@ void loop() { show_display(firstLine, secondLine, thirdLine, fourthLine, 0); DIGI_Utils::processPacket(LoRa_Utils::receivePacket()); } else if (stationMode==1 || stationMode==2 ) { // iGate (1 Only Rx / 2 Rx+Tx) - /*unsigned long currentWiFiMillis = millis(); - if ((WiFi.status() != WL_CONNECTED) && (millis() - previousWiFiMillis >= 30*1000)) { - Serial.print(millis()); - Serial.println("Reconnecting to WiFi..."); - WiFi.disconnect(); - WiFi.reconnect(); - previousWiFiMillis = millis(); - }*/ WIFI_Utils::checkWiFi(); if (!espClient.connected()) { APRS_IS_Utils::connect(); @@ -85,61 +73,9 @@ void loop() { utils::checkBeaconInterval(); APRS_IS_Utils::processLoRaPacket(LoRa_Utils::receivePacket()); if (espClient.available()) { - String aprsisPacket;//aprsisData, ;//, Sender, AddresseeAndMessage, Addressee, receivedMessage; - /*bool validHeardStation = false; - aprsisData = espClient.readStringUntil('\r'); // or '\n' - aprsisPacket.concat(aprsisData);*/ + String aprsisPacket; aprsisPacket.concat(espClient.readStringUntil('\r')); APRS_IS_Utils::processAPRSISPacket(aprsisPacket); - /*if (!aprsisPacket.startsWith("#")){ - if (aprsisPacket.indexOf("::")>0) { - Sender = aprsisPacket.substring(0,aprsisPacket.indexOf(">")); - AddresseeAndMessage = aprsisPacket.substring(aprsisPacket.indexOf("::")+2); - Addressee = AddresseeAndMessage.substring(0, AddresseeAndMessage.indexOf(":")); - Addressee.trim(); - if (Addressee == Config.callsign) { // its for me! - if (AddresseeAndMessage.indexOf("{")>0) { // ack? - String ackMessage = "ack" + AddresseeAndMessage.substring(AddresseeAndMessage.indexOf("{")+1); - ackMessage.trim(); - delay(4000); - Serial.println(ackMessage); - for(int i = Sender.length(); i < 9; i++) { - Sender += ' '; - } - String ackPacket = Config.callsign + ">APLRG1,TCPIP,qAC::" + Sender + ":" + ackMessage + "\n"; - espClient.write(ackPacket.c_str()); - receivedMessage = AddresseeAndMessage.substring(AddresseeAndMessage.indexOf(":")+1, AddresseeAndMessage.indexOf("{")); - } else { - receivedMessage = AddresseeAndMessage.substring(AddresseeAndMessage.indexOf(":")+1); - } - if (receivedMessage.indexOf("?") == 0) { - Serial.println("Received Query APRS-IS : " + aprsisPacket); - String queryAnswer = QUERY_Utils::process(receivedMessage, Sender, "APRSIS"); - Serial.println("---> QUERY Answer : " + queryAnswer.substring(0,queryAnswer.indexOf("\n"))); - if (!Config.display.alwaysOn) { - display_toggle(true); - } - lastScreenOn = millis(); - delay(500); - espClient.write(queryAnswer.c_str()); - show_display(firstLine, secondLine, "Callsign = " + Sender, "TYPE --> QUERY", 1000); - } - } else { - Serial.print("Received from APRS-IS : " + aprsisPacket); - if (stationMode == 1) { - Serial.println(" ---> Cant Tx without Ham Lincence"); - } else if (stationMode > 1) { - if (STATION_Utils::wasHeard(Addressee)) { - LoRa_Utils::sendNewPacket("APRS", LoRa_Utils::generatePacket(aprsisPacket)); - display_toggle(true); - lastScreenOn = millis(); - receivedMessage = AddresseeAndMessage.substring(AddresseeAndMessage.indexOf(":")+1); - show_display(firstLine, secondLine, Sender + " -> " + Addressee, receivedMessage, 1000); - } - } - } - } - }*/ } } } diff --git a/src/aprs_is_utils.cpp b/src/aprs_is_utils.cpp index cfcc02c..46d0ea0 100644 --- a/src/aprs_is_utils.cpp +++ b/src/aprs_is_utils.cpp @@ -126,16 +126,6 @@ void processLoRaPacket(String packet) { STATION_Utils::updateLastHeard(Sender); utils::typeOfPacket(aprsPacket); show_display(firstLine, secondLine, thirdLine, fourthLine, 0); - /*if (aprsPacket.indexOf("::") >= 10) { - show_display(firstLine, secondLine, "Callsign = " + Sender, "TYPE ----> MESSAGE", 1000); - } else if (aprsPacket.indexOf(":>") >= 10) { - show_display(firstLine, secondLine, "Callsign = " + Sender, "TYPE ----> NEW STATUS", 1000); - } else if (aprsPacket.indexOf(":!") >= 10 || aprsPacket.indexOf(":=") >= 10) { - show_display(firstLine, secondLine, "Callsign = " + Sender, "TYPE ----> GPS BEACON", 1000); - } else { - show_display(firstLine, secondLine, "Callsign = " + Sender, "TYPE ----> ??????????", 1000); - }*/ - } } } else { diff --git a/src/digi_utils.cpp b/src/digi_utils.cpp index fde2f6b..49c6443 100644 --- a/src/digi_utils.cpp +++ b/src/digi_utils.cpp @@ -5,30 +5,11 @@ #include "utils.h" extern Configuration Config; -//extern String thirdLine; -//extern String fourthLine; extern int stationMode; extern uint32_t lastScreenOn; namespace DIGI_Utils { -/*void typeOfPacket(String packet) { - String Sender = packet.substring(3,packet.indexOf(">")); - if (packet.indexOf("::") >= 10) { - thirdLine = "Callsign = " + Sender; - fourthLine = "TYPE ----> MESSAGE"; - } else if (packet.indexOf(":>") >= 10) { - thirdLine = "Callsign = " + Sender; - fourthLine = "TYPE ----> NEW STATUS"; - } else if (packet.indexOf(":!") >= 10 || packet.indexOf(":=") >= 10) { - thirdLine = "Callsign = " + Sender; - fourthLine = "TYPE ----> GPS BEACON"; - } else { - thirdLine = "Callsign = " + Sender; - fourthLine = "TYPE ----> ??????????"; - } -}*/ - void processPacket(String packet) { String firstPart, lastPart, loraPacket; if (packet != "") { @@ -44,13 +25,13 @@ void processPacket(String packet) { LoRa_Utils::sendNewPacket("APRS", loraPacket); display_toggle(true); lastScreenOn = millis(); - } else { // stationMode = 4 + } else { utils::typeOfPacket(packet); firstPart = packet.substring(3,packet.indexOf(",")+1); lastPart = packet.substring(packet.indexOf(",")+1); loraPacket = firstPart + Config.callsign + lastPart; // se agrega "*"" ??? delay(500); - if (stationMode == 4) { // Digirepeating with Freq Rx != Tx + if (stationMode == 4) { LoRa_Utils::changeFreqTx(); } LoRa_Utils::sendNewPacket("APRS", loraPacket); diff --git a/src/digi_utils.h b/src/digi_utils.h index 794852d..a3b78f5 100644 --- a/src/digi_utils.h +++ b/src/digi_utils.h @@ -5,7 +5,6 @@ namespace DIGI_Utils { -//void typeOfPacket(String packet); void processPacket(String packet); } diff --git a/src/lora_utils.cpp b/src/lora_utils.cpp index 5674a42..b1a3556 100644 --- a/src/lora_utils.cpp +++ b/src/lora_utils.cpp @@ -56,7 +56,7 @@ String generatePacket(String aprsisPacket) { String receivePacket() { String loraPacket = ""; - int packetSize = LoRa.parsePacket(); // Listening for LoRa Packets + int packetSize = LoRa.parsePacket(); if (packetSize) { while (LoRa.available()) { int inChar = LoRa.read(); diff --git a/src/query_utils.cpp b/src/query_utils.cpp index 2f44d35..d55d0e9 100644 --- a/src/query_utils.cpp +++ b/src/query_utils.cpp @@ -5,6 +5,7 @@ extern Configuration Config; extern WiFi_AP *currentWiFi; extern std::vector lastHeardStation; extern std::vector lastHeardStation_temp; +extern String versionDate; namespace QUERY_Utils { @@ -13,14 +14,18 @@ String process(String query, String station, String queryOrigin) { if (query=="?APRS?" || query=="?aprs?" || query=="?Aprs?" || query=="H" || query=="h" || query=="Help" || query=="help" || query=="?") { answer = "?APRSV ?APRSP ?APRSL ?APRSH ?WHERE callsign"; } else if (query=="?APRSV" || query=="?aprsv" || query=="?Aprsv") { - answer = "CD2RXU_LoRa_iGate 1.2"; + answer = "CD2RXU_LoRa_iGate 1.2 v" + versionDate; } else if (query=="?APRSP" || query=="?aprsp" || query=="?Aprsp") { answer = "iGate QTH: " + String(currentWiFi->latitude,2) + " " + String(currentWiFi->longitude,2); } else if (query=="?APRSL" || query=="?aprsl" || query=="?Aprsl") { - for (int i=0; i")); + if (stationMode==1 || stationMode==2) { + thirdLine = "Callsign = " + packet.substring(0,packet.indexOf(">")); + } else { + thirdLine = "Callsign = " + packet.substring(3,packet.indexOf(">")); + } if (packet.indexOf("::") >= 10) { fourthLine = "TYPE ----> MESSAGE"; } else if (packet.indexOf(":>") >= 10) {