diff --git a/data/igate_conf.json b/data/igate_conf.json index bf8a16b..af97955 100644 --- a/data/igate_conf.json +++ b/data/igate_conf.json @@ -1,6 +1,6 @@ { "callsign": "CD2RXU-10", - "stationMode": 4, + "stationMode": 2, "iGateComment": "LoRa_APRS_iGate", "digirepeaterComment": "LoRa_APRS_Digirepeater" , "wifi": { diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index 0937b88..4c0ec47 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -44,65 +44,67 @@ String firstLine, secondLine, thirdLine, fourthLine, iGateBeaconPacket; void checkReceivedPacket(String packet) { bool queryMessage = false; String aprsPacket, Sender, AddresseeAndMessage, Addressee, ackMessage, receivedMessage; - Serial.print("Received Lora Packet : " + String(packet)); - if ((packet.substring(0, 3) == "\x3c\xff\x01") && (packet.indexOf("TCPIP") == -1) && (packet.indexOf("NOGATE") == -1) && (packet.indexOf("RFONLY") == -1)) { - Serial.print(" ---> APRS LoRa Packet!"); - Sender = packet.substring(3,packet.indexOf(">")); - if (Sender != Config.callsign) { // avoid listening yourself by digirepeating - if (stationMode > 1) { // only answer when stationMode > 1 (with Ham Licence) - if (packet.indexOf("::") > 10) { // its a Message! - AddresseeAndMessage = packet.substring(packet.indexOf("::")+2); - Addressee = AddresseeAndMessage.substring(0,AddresseeAndMessage.indexOf(":")); - Addressee.trim(); - if (Addressee == Config.callsign) { // its for me! - if (AddresseeAndMessage.indexOf("{")>0) { // ack? - ackMessage = "ack" + AddresseeAndMessage.substring(AddresseeAndMessage.indexOf("{")+1); - ackMessage.trim(); - delay(4000); - Serial.println(ackMessage); - for(int i = Sender.length(); i < 9; i++) { - Sender += ' '; + if (packet != "") { + Serial.print("Received Lora Packet : " + String(packet)); + if ((packet.substring(0, 3) == "\x3c\xff\x01") && (packet.indexOf("TCPIP") == -1) && (packet.indexOf("NOGATE") == -1) && (packet.indexOf("RFONLY") == -1)) { + Serial.print(" ---> APRS LoRa Packet!"); + Sender = packet.substring(3,packet.indexOf(">")); + if (Sender != Config.callsign) { // avoid listening yourself by digirepeating + if (stationMode > 1) { // only answer when stationMode > 1 (with Ham Licence) + if (packet.indexOf("::") > 10) { // its a Message! + AddresseeAndMessage = packet.substring(packet.indexOf("::")+2); + Addressee = AddresseeAndMessage.substring(0,AddresseeAndMessage.indexOf(":")); + Addressee.trim(); + if (Addressee == Config.callsign) { // its for me! + if (AddresseeAndMessage.indexOf("{")>0) { // ack? + ackMessage = "ack" + AddresseeAndMessage.substring(AddresseeAndMessage.indexOf("{")+1); + ackMessage.trim(); + delay(4000); + Serial.println(ackMessage); + for(int i = Sender.length(); i < 9; i++) { + Sender += ' '; + } + LoRa_Utils::sendNewPacket("APRS", Config.callsign + ">APLRG1,RFONLY::" + Sender + ":" + ackMessage); + receivedMessage = AddresseeAndMessage.substring(AddresseeAndMessage.indexOf(":")+1, AddresseeAndMessage.indexOf("{")); + } else { + receivedMessage = AddresseeAndMessage.substring(AddresseeAndMessage.indexOf(":")+1); } - LoRa_Utils::sendNewPacket("APRS", Config.callsign + ">APLRG1,RFONLY::" + Sender + ":" + ackMessage); - receivedMessage = AddresseeAndMessage.substring(AddresseeAndMessage.indexOf(":")+1, AddresseeAndMessage.indexOf("{")); - } else { - receivedMessage = AddresseeAndMessage.substring(AddresseeAndMessage.indexOf(":")+1); - } - if (receivedMessage.indexOf("?") == 0) { - queryMessage = true; - delay(2000); - if (!Config.display.alwaysOn) { - display_toggle(true); + if (receivedMessage.indexOf("?") == 0) { + queryMessage = true; + delay(2000); + if (!Config.display.alwaysOn) { + display_toggle(true); + } + LoRa_Utils::sendNewPacket("APRS", QUERY_Utils::process(receivedMessage, Sender, "LoRa")); + lastRxTxTime = millis(); + show_display(firstLine, secondLine, "Callsign = " + Sender, "TYPE --> QUERY", 1000); } - LoRa_Utils::sendNewPacket("APRS", QUERY_Utils::process(receivedMessage, Sender, "LoRa")); - lastRxTxTime = millis(); - show_display(firstLine, secondLine, "Callsign = " + Sender, "TYPE --> QUERY", 1000); } } } - } - if (!queryMessage) { - aprsPacket = APRS_IS_Utils::createPacket(packet); - if (!Config.display.alwaysOn) { - display_toggle(true); + if (!queryMessage) { + aprsPacket = APRS_IS_Utils::createPacket(packet); + if (!Config.display.alwaysOn) { + display_toggle(true); + } + lastRxTxTime = millis(); + espClient.write(aprsPacket.c_str()); + Serial.println(" ---> Uploaded to APRS-IS"); + STATION_Utils::updateLastHeard(Sender); + 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); + } } - lastRxTxTime = millis(); - espClient.write(aprsPacket.c_str()); - Serial.println(" ---> Uploaded to APRS-IS"); - STATION_Utils::updateLastHeard(Sender); - 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 { - Serial.println(" ---> LoRa Packet Ignored (first 3 bytes or TCPIP/NOGATE/RFONLY)\n"); + } + } else { + Serial.println(" ---> LoRa Packet Ignored (first 3 bytes or TCPIP/NOGATE/RFONLY)\n"); + } } } @@ -148,7 +150,7 @@ void loop() { beacon_update = false; } show_display(firstLine, secondLine, thirdLine, fourthLine, 0); - DIGI_Utils::process(LoRa_Utils::receivePacket()); + 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) && (currentWiFiMillis - previousWiFiMillis >= currentWiFi->checkInterval*1000)) { @@ -193,7 +195,7 @@ void loop() { beacon_update = false; } - String loraPacket = ""; + /*String loraPacket = ""; int packetSize = LoRa.parsePacket(); if (packetSize) { while (LoRa.available()) { @@ -201,7 +203,9 @@ void loop() { loraPacket += (char)inChar; } checkReceivedPacket(loraPacket); - } + }*/ + checkReceivedPacket(LoRa_Utils::receivePacket()); + // if (espClient.available()) { String aprsisData, aprsisPacket, Sender, AddresseeAndMessage, Addressee, receivedMessage; diff --git a/src/aprs_is_utils.cpp b/src/aprs_is_utils.cpp index 7e856b7..950a36e 100644 --- a/src/aprs_is_utils.cpp +++ b/src/aprs_is_utils.cpp @@ -64,6 +64,14 @@ String createPacket(String packet) { } else { return packet.substring(3, packet.indexOf(':')) + ",qAO," + Config.callsign + packet.substring(packet.indexOf(':')) + "\n"; } +} + +void processLoRaPacket(String packet) { + + + + + } /*void processSplitedMessage(String addressee, String message1, String message2) { diff --git a/src/aprs_is_utils.h b/src/aprs_is_utils.h index 28305a0..a4e8984 100644 --- a/src/aprs_is_utils.h +++ b/src/aprs_is_utils.h @@ -8,6 +8,7 @@ namespace APRS_IS_Utils { void connect(); String checkStatus(); String createPacket(String unprocessedPacket); +void processLoRaPacket(String packet); //void processSplitedMessage(String addressee, String message1, String message2); } diff --git a/src/digi_utils.cpp b/src/digi_utils.cpp index d7941d0..cc26b43 100644 --- a/src/digi_utils.cpp +++ b/src/digi_utils.cpp @@ -27,7 +27,7 @@ void typeOfPacket(String packet) { } } -void process(String packet) { +void processPacket(String packet) { String firstPart, lastPart; if (packet != "") { Serial.print("Received Lora Packet : " + String(packet)); diff --git a/src/digi_utils.h b/src/digi_utils.h index b1eba1e..66b83b6 100644 --- a/src/digi_utils.h +++ b/src/digi_utils.h @@ -6,7 +6,7 @@ namespace DIGI_Utils { void typeOfPacket(String packet); -void process(String packet); +void processPacket(String packet); }