diff --git a/README.md b/README.md index 1873237..424dc31 100644 --- a/README.md +++ b/README.md @@ -79,23 +79,24 @@ LoRa APRS iGATE/Digirepeater working on this boards: - HELTEC_WIFI_LORA_32_V2 (check "pins_config.h" and "display.cpp" for aditional configuration). __________________________________________ Versions: -- 2023.02.10 First Beta (receiving LoRa Beacon/Packets and uploading to APRS-IS). -- 2023.02.17 Receiving Feed from APRS-IS. -- 2023.03.01 Tx Packet from APRS-IS to nearby LoRa Stations. -- 2023.05.12 Tx Packet from APRS-IS to LoRa-RF Correction. -- 2023.05.19 Saving Last-Heard Stations for validating Tx Responses. -- 2023.05.23 Processing Query's from RF/LoRa or APRS-IS (Send "Help" Message to test). -- 2023.06.06 Full repack of Code and adding _enableTx_ only for Ham Ops. -- 2023.06.08 Adding Digirepeater Functions. -- 2023.06.10 OTA update support for Firmware and Filesystem. -- 2023.06.12 Syslog added. -- 2023.06.17 Support for BME280 Module (Temperature, Humidity, Pressure) added. -- 2023.06.18 Info on Oled Screen mayor update, added RSSI and Distance to Listened Station. -- 2023.07.05 Adding monitor info of Battery connected. -- 2023.07.16 Small OTA, BME module update. -- 2023.07.31 StationMode5 added: iGate when WiFi and APRS available, DigiRepeater when not. -- 2023.08.05 Ground Height Correction for Pressure readings added +- 2023.10.08 Added Serial Comunication with PinPoint APRS app (https://www.pinpointaprs.com) - 2023.08.20 Added External Voltage Measurement (Max 15V!) +- 2023.08.05 Ground Height Correction for Pressure readings added +- 2023.07.31 StationMode5 added: iGate when WiFi and APRS available, DigiRepeater when not. +- 2023.07.16 Small OTA, BME module update. +- 2023.07.05 Adding monitor info of Battery connected. +- 2023.06.18 Info on Oled Screen mayor update, added RSSI and Distance to Listened Station. +- 2023.06.17 Support for BME280 Module (Temperature, Humidity, Pressure) added. +- 2023.06.12 Syslog added. +- 2023.06.10 OTA update support for Firmware and Filesystem. +- 2023.06.08 Adding Digirepeater Functions. +- 2023.06.06 Full repack of Code and adding _enableTx_ only for Ham Ops. +- 2023.05.23 Processing Query's from RF/LoRa or APRS-IS (Send "Help" Message to test). +- 2023.05.19 Saving Last-Heard Stations for validating Tx Responses. +- 2023.05.12 Tx Packet from APRS-IS to LoRa-RF Correction. +- 2023.03.01 Tx Packet from APRS-IS to nearby LoRa Stations. +- 2023.02.17 Receiving Feed from APRS-IS. +- 2023.02.10 First Beta (receiving LoRa Beacon/Packets and uploading to APRS-IS). __________________________________________ diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index f2ed8a1..39d6310 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -20,7 +20,7 @@ Configuration Config; WiFiClient espClient; -String versionDate = "2023.09.21"; +String versionDate = "2023.10.08"; int myWiFiAPIndex = 0; int myWiFiAPSize = Config.wifiAPs.size(); WiFi_AP *currentWiFi = &Config.wifiAPs[myWiFiAPIndex]; diff --git a/src/aprs_is_utils.cpp b/src/aprs_is_utils.cpp index 0eaa4c7..a9c8326 100644 --- a/src/aprs_is_utils.cpp +++ b/src/aprs_is_utils.cpp @@ -23,190 +23,203 @@ extern String seventhLine; namespace APRS_IS_Utils { -void connect(){ - int count = 0; - String aprsauth; - Serial.print("Connecting to APRS-IS ... "); - while (!espClient.connect(Config.aprs_is.server.c_str(), Config.aprs_is.port) && count < 20) { - Serial.println("Didn't connect with server..."); - delay(1000); - espClient.stop(); - espClient.flush(); - Serial.println("Run client.stop"); - Serial.println("Trying to connect with Server: " + String(Config.aprs_is.server) + " AprsServerPort: " + String(Config.aprs_is.port)); - count++; - Serial.println("Try: " + String(count)); - } - if (count == 20) { - Serial.println("Tried: " + String(count) + " FAILED!"); - } else { - Serial.println("Connected!\n(Server: " + String(Config.aprs_is.server) + " / Port: " + String(Config.aprs_is.port) +")"); - aprsauth = "user " + Config.callsign + " pass " + Config.aprs_is.passcode + " vers CD2RXU_LoRa_iGate 1.2 filter t/m/" + Config.callsign + "/" + (String)Config.aprs_is.reportingDistance + "\n\r"; - espClient.write(aprsauth.c_str()); - delay(200); - } -} - -void checkStatus() { - String wifiState, aprsisState; - if (WiFi.status() == WL_CONNECTED) { - wifiState = "OK"; - } else { - wifiState = "--"; - if (!Config.display.alwaysOn) { - display_toggle(true); + void connect(){ + int count = 0; + String aprsauth; + Serial.print("Connecting to APRS-IS ... "); + while (!espClient.connect(Config.aprs_is.server.c_str(), Config.aprs_is.port) && count < 20) { + Serial.println("Didn't connect with server..."); + delay(1000); + espClient.stop(); + espClient.flush(); + Serial.println("Run client.stop"); + Serial.println("Trying to connect with Server: " + String(Config.aprs_is.server) + " AprsServerPort: " + String(Config.aprs_is.port)); + count++; + Serial.println("Try: " + String(count)); } - lastScreenOn = millis(); - } - if (espClient.connected()) { - aprsisState = "OK"; - } else { - aprsisState = "--"; - if (!Config.display.alwaysOn) { - display_toggle(true); + if (count == 20) { + Serial.println("Tried: " + String(count) + " FAILED!"); + } else { + Serial.println("Connected!\n(Server: " + String(Config.aprs_is.server) + " / Port: " + String(Config.aprs_is.port) +")"); + aprsauth = "user " + Config.callsign + " pass " + Config.aprs_is.passcode + " vers CD2RXU_LoRa_iGate 1.2 filter t/m/" + Config.callsign + "/" + (String)Config.aprs_is.reportingDistance + "\n\r"; + espClient.write(aprsauth.c_str()); + delay(200); } - lastScreenOn = millis(); } - secondLine = "WiFi: " + wifiState + "/ APRS-IS: " + aprsisState; -} -String createPacket(String packet) { - if (stationMode > 1) { - return packet.substring(3, packet.indexOf(':')) + ",qAR," + Config.callsign + packet.substring(packet.indexOf(':')) + "\n"; - } else { - return packet.substring(3, packet.indexOf(':')) + ",qAO," + Config.callsign + packet.substring(packet.indexOf(':')) + "\n"; + void checkStatus() { + String wifiState, aprsisState; + if (WiFi.status() == WL_CONNECTED) { + wifiState = "OK"; + } else { + wifiState = "--"; + if (!Config.display.alwaysOn) { + display_toggle(true); + } + lastScreenOn = millis(); + } + if (espClient.connected()) { + aprsisState = "OK"; + } else { + aprsisState = "--"; + if (!Config.display.alwaysOn) { + display_toggle(true); + } + lastScreenOn = millis(); + } + secondLine = "WiFi: " + wifiState + "/ APRS-IS: " + aprsisState; } -} -void processLoRaPacket(String packet) { - bool queryMessage = false; - String aprsPacket, Sender, AddresseeAndMessage, Addressee, ackMessage, receivedMessage; - if (packet != "") { - //Serial.print("Received Lora Packet : " + String(packet)); - Serial.println(packet.substring(3)); - 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 == 2 || stationMode == 5) { - 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 += ' '; + String createPacket(String packet) { + if (stationMode > 1) { + return packet.substring(3, packet.indexOf(':')) + ",qAR," + Config.callsign + packet.substring(packet.indexOf(':')) + "\n"; + } else { + return packet.substring(3, packet.indexOf(':')) + ",qAO," + Config.callsign + packet.substring(packet.indexOf(':')) + "\n"; + } + } + + void processLoRaPacket(String packet) { + bool queryMessage = false; + String aprsPacket, Sender, AddresseeAndMessage, Addressee, ackMessage, receivedMessage; + if (packet != "") { + #ifdef PinPointApp + Serial.println(packet.substring(3)); + #else + Serial.print("Received Lora Packet : " + String(packet)); + #endif + if ((packet.substring(0, 3) == "\x3c\xff\x01") && (packet.indexOf("TCPIP") == -1) && (packet.indexOf("NOGATE") == -1) && (packet.indexOf("RFONLY") == -1)) { + #ifndef PinPointApp + Serial.print(" ---> APRS LoRa Packet!"); + #endif + Sender = packet.substring(3,packet.indexOf(">")); + if (Sender != Config.callsign) { // avoid listening yourself by digirepeating + if (stationMode == 2 || stationMode == 5) { + 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")); + lastScreenOn = millis(); + show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, "Callsign = " + Sender, "TYPE --> QUERY", 0); } - LoRa_Utils::sendNewPacket("APRS", QUERY_Utils::process(receivedMessage, Sender, "LoRa")); - lastScreenOn = millis(); - show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, "Callsign = " + Sender, "TYPE --> QUERY", 0); } } } - } - if (!queryMessage) { - aprsPacket = createPacket(packet); - if (!Config.display.alwaysOn) { - display_toggle(true); + if (!queryMessage) { + aprsPacket = createPacket(packet); + if (!Config.display.alwaysOn) { + display_toggle(true); + } + lastScreenOn = millis(); + espClient.write(aprsPacket.c_str()); + #ifndef PinPointApp + Serial.println(" ---> Uploaded to APRS-IS"); + #endif + STATION_Utils::updateLastHeard(Sender); + Utils::typeOfPacket(aprsPacket, "LoRa-APRS"); + show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0); } - lastScreenOn = millis(); - espClient.write(aprsPacket.c_str()); - //Serial.println(" ---> Uploaded to APRS-IS"); - STATION_Utils::updateLastHeard(Sender); - Utils::typeOfPacket(aprsPacket, "LoRa-APRS"); - show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0); - } - } - } else { - //Serial.println(" ---> LoRa Packet Ignored (first 3 bytes or TCPIP/NOGATE/RFONLY)\n"); - } - } -} - -void processAPRSISPacket(String packet) { - String Sender, AddresseeAndMessage, Addressee, receivedMessage; - if (!packet.startsWith("#")){ - if (packet.indexOf("::")>0) { - Sender = packet.substring(0,packet.indexOf(">")); - 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? - 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 : " + packet); - 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()); - fifthLine = "APRS-IS ----> APRS-IS"; - sixthLine = Config.callsign; - for (int j=sixthLine.length();j<9;j++) { - sixthLine += " "; - } - sixthLine += "> " + Sender; - seventhLine = "QUERY = " + receivedMessage; - } + } } else { - //Serial.print("Received from APRS-IS : " + packet); - if ((stationMode==2 || stationMode==5) && STATION_Utils::wasHeard(Addressee)) { - LoRa_Utils::sendNewPacket("APRS", LoRa_Utils::generatePacket(packet)); - display_toggle(true); - lastScreenOn = millis(); - Utils::typeOfPacket(packet, "APRS-LoRa"); - } + #ifndef PinPointApp + Serial.println(" ---> LoRa Packet Ignored (first 3 bytes or TCPIP/NOGATE/RFONLY)\n"); + #endif + } + } + } + + void processAPRSISPacket(String packet) { + String Sender, AddresseeAndMessage, Addressee, receivedMessage; + if (!packet.startsWith("#")){ + if (packet.indexOf("::")>0) { + Sender = packet.substring(0,packet.indexOf(">")); + 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? + 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) { + #ifndef PinPointApp + Serial.println("Received Query APRS-IS : " + packet); + #endif + 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()); + fifthLine = "APRS-IS ----> APRS-IS"; + sixthLine = Config.callsign; + for (int j=sixthLine.length();j<9;j++) { + sixthLine += " "; + } + sixthLine += "> " + Sender; + seventhLine = "QUERY = " + receivedMessage; + } + } else { + #ifndef PinPointApp + Serial.print("Received from APRS-IS : " + packet); + #endif + if ((stationMode==2 || stationMode==5) && STATION_Utils::wasHeard(Addressee)) { + LoRa_Utils::sendNewPacket("APRS", LoRa_Utils::generatePacket(packet)); + display_toggle(true); + lastScreenOn = millis(); + Utils::typeOfPacket(packet, "APRS-LoRa"); + } + } + show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0); + } + } + } + + void loop() { + checkStatus(); + show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0); + while (espClient.connected()) { + Utils::checkDisplayInterval(); + Utils::checkBeaconInterval(); + processLoRaPacket(LoRa_Utils::receivePacket()); + if (espClient.available()) { + String aprsisPacket; + aprsisPacket.concat(espClient.readStringUntil('\r')); + processAPRSISPacket(aprsisPacket); } - show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0); - } - } -} - -void loop() { - checkStatus(); - show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0); - while (espClient.connected()) { - Utils::checkDisplayInterval(); - Utils::checkBeaconInterval(); - processLoRaPacket(LoRa_Utils::receivePacket()); - if (espClient.available()) { - String aprsisPacket; - aprsisPacket.concat(espClient.readStringUntil('\r')); - processAPRSISPacket(aprsisPacket); } } -} } \ No newline at end of file diff --git a/src/aprs_is_utils.h b/src/aprs_is_utils.h index 8a41938..e219b50 100644 --- a/src/aprs_is_utils.h +++ b/src/aprs_is_utils.h @@ -3,6 +3,8 @@ #include +//#define PinPointApp //uncomment this line when using PinPoint App ( https://www.pinpointaprs.com ) + namespace APRS_IS_Utils { void connect(); diff --git a/src/lora_utils.cpp b/src/lora_utils.cpp index 9f32f9d..cbc110b 100644 --- a/src/lora_utils.cpp +++ b/src/lora_utils.cpp @@ -1,7 +1,8 @@ #include #include "configuration.h" -#include "pins_config.h" +#include "aprs_is_utils.h" #include "syslog_utils.h" +#include "pins_config.h" #include "display.h" extern Configuration Config; @@ -12,83 +13,85 @@ float snr; namespace LoRa_Utils { -void setup() { - SPI.begin(LORA_SCK, LORA_MISO, LORA_MOSI, LORA_CS); - LoRa.setPins(LORA_CS, LORA_RST, LORA_IRQ); - long freq; - if (stationMode == 1 || stationMode == 2) { - freq = Config.loramodule.iGateFreq; - } else { - freq = Config.loramodule.digirepeaterTxFreq; - } - if (!LoRa.begin(freq)) { - Serial.println("Starting LoRa failed!"); - show_display("ERROR", "Starting LoRa failed!"); - while (true) { - delay(1000); + void setup() { + SPI.begin(LORA_SCK, LORA_MISO, LORA_MOSI, LORA_CS); + LoRa.setPins(LORA_CS, LORA_RST, LORA_IRQ); + long freq; + if (stationMode == 1 || stationMode == 2) { + freq = Config.loramodule.iGateFreq; + } else { + freq = Config.loramodule.digirepeaterTxFreq; } - } - LoRa.setSpreadingFactor(Config.loramodule.spreadingFactor); - LoRa.setSignalBandwidth(Config.loramodule.signalBandwidth); - LoRa.setCodingRate4(Config.loramodule.codingRate4); - LoRa.enableCrc(); - LoRa.setTxPower(Config.loramodule.power); - Serial.print("init : LoRa Module ... done!"); -} - -void sendNewPacket(const String &typeOfMessage, const String &newPacket) { - digitalWrite(greenLed,HIGH); - LoRa.beginPacket(); - LoRa.write('<'); - if (typeOfMessage == "APRS") { - LoRa.write(0xFF); - } else if (typeOfMessage == "LoRa") { - LoRa.write(0xF8); - } - LoRa.write(0x01); - LoRa.write((const uint8_t *)newPacket.c_str(), newPacket.length()); - LoRa.endPacket(); - digitalWrite(greenLed,LOW); - SYSLOG_Utils::log("LoRa Tx", newPacket,0,0,0); - Serial.print("---> LoRa Packet Tx : "); - Serial.println(newPacket); -} - -String generatePacket(String aprsisPacket) { - String firstPart, messagePart; - aprsisPacket.trim(); - firstPart = aprsisPacket.substring(0, aprsisPacket.indexOf(",")); - messagePart = aprsisPacket.substring(aprsisPacket.indexOf("::")+2); - return firstPart + ",TCPIP," + Config.callsign + "::" + messagePart; -} - -String receivePacket() { - String loraPacket = ""; - int packetSize = LoRa.parsePacket(); - if (packetSize) { - while (LoRa.available()) { - int inChar = LoRa.read(); - loraPacket += (char)inChar; - } - rssi = LoRa.packetRssi(); - snr = LoRa.packetSnr(); - freqError = LoRa.packetFrequencyError(); - //Serial.println("(RSSI:" +String(rssi) + " / SNR:" + String(snr) + " / FreqErr:" + String(freqError) + ")"); - if (Config.syslog.active && (stationMode==1 || stationMode==2)) { - SYSLOG_Utils::log("LoRa Rx", loraPacket, rssi, snr, freqError); + if (!LoRa.begin(freq)) { + Serial.println("Starting LoRa failed!"); + show_display("ERROR", "Starting LoRa failed!"); + while (true) { + delay(1000); + } } + LoRa.setSpreadingFactor(Config.loramodule.spreadingFactor); + LoRa.setSignalBandwidth(Config.loramodule.signalBandwidth); + LoRa.setCodingRate4(Config.loramodule.codingRate4); + LoRa.enableCrc(); + LoRa.setTxPower(Config.loramodule.power); + Serial.print("init : LoRa Module ... done!"); } - return loraPacket; -} -void changeFreqTx() { - delay(500); - LoRa.setFrequency(Config.loramodule.digirepeaterTxFreq); -} + void sendNewPacket(const String &typeOfMessage, const String &newPacket) { + digitalWrite(greenLed,HIGH); + LoRa.beginPacket(); + LoRa.write('<'); + if (typeOfMessage == "APRS") { + LoRa.write(0xFF); + } else if (typeOfMessage == "LoRa") { + LoRa.write(0xF8); + } + LoRa.write(0x01); + LoRa.write((const uint8_t *)newPacket.c_str(), newPacket.length()); + LoRa.endPacket(); + digitalWrite(greenLed,LOW); + SYSLOG_Utils::log("LoRa Tx", newPacket,0,0,0); + Serial.print("---> LoRa Packet Tx : "); + Serial.println(newPacket); + } -void changeFreqRx() { - delay(500); - LoRa.setFrequency(Config.loramodule.digirepeaterRxFreq); -} + String generatePacket(String aprsisPacket) { + String firstPart, messagePart; + aprsisPacket.trim(); + firstPart = aprsisPacket.substring(0, aprsisPacket.indexOf(",")); + messagePart = aprsisPacket.substring(aprsisPacket.indexOf("::")+2); + return firstPart + ",TCPIP," + Config.callsign + "::" + messagePart; + } + + String receivePacket() { + String loraPacket = ""; + int packetSize = LoRa.parsePacket(); + if (packetSize) { + while (LoRa.available()) { + int inChar = LoRa.read(); + loraPacket += (char)inChar; + } + rssi = LoRa.packetRssi(); + snr = LoRa.packetSnr(); + freqError = LoRa.packetFrequencyError(); + #ifndef PinPointApp + Serial.println("(RSSI:" +String(rssi) + " / SNR:" + String(snr) + " / FreqErr:" + String(freqError) + ")"); + #endif + if (Config.syslog.active && (stationMode==1 || stationMode==2)) { + SYSLOG_Utils::log("LoRa Rx", loraPacket, rssi, snr, freqError); + } + } + return loraPacket; + } + + void changeFreqTx() { + delay(500); + LoRa.setFrequency(Config.loramodule.digirepeaterTxFreq); + } + + void changeFreqRx() { + delay(500); + LoRa.setFrequency(Config.loramodule.digirepeaterRxFreq); + } } \ No newline at end of file diff --git a/src/station_utils.cpp b/src/station_utils.cpp index edfad8a..ef9deff 100644 --- a/src/station_utils.cpp +++ b/src/station_utils.cpp @@ -1,4 +1,5 @@ #include "station_utils.h" +#include "aprs_is_utils.h" #include "configuration.h" #include @@ -45,12 +46,13 @@ void updateLastHeard(String station) { } fourthLine += String(lastHeardStation.size()); - ////// - Serial.print("Stations Near (last 30 minutes): "); + #ifndef PinPointApp ////// This is just for debugging + Serial.print("Stations Near (last " + String(Config.rememberStationTime) + " minutes): "); for (int k=0; k