mirror of
https://github.com/richonguzman/LoRa_APRS_iGate.git
synced 2026-08-07 09:22:57 +02:00
const String 2
This commit is contained in:
+21
-20
@@ -30,7 +30,7 @@ uint32_t lastRxTime = millis();
|
||||
|
||||
namespace APRS_IS_Utils {
|
||||
|
||||
void upload(String line) {
|
||||
void upload(const String& line) {
|
||||
espClient.print(line + "\r\n");
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace APRS_IS_Utils {
|
||||
secondLine = "WiFi: " + wifiState + " APRS-IS: " + aprsisState;
|
||||
}
|
||||
|
||||
String buildPacketToUpload(String packet) {
|
||||
String buildPacketToUpload(const String& packet) {
|
||||
if (!(Config.aprs_is.active && Config.digi.mode == 0)) { // Check if NOT only IGate
|
||||
return packet.substring(3, packet.indexOf(":")) + ",qAR," + Config.callsign + packet.substring(packet.indexOf(":"));
|
||||
}
|
||||
@@ -107,27 +107,28 @@ namespace APRS_IS_Utils {
|
||||
}
|
||||
}
|
||||
|
||||
String buildPacketToTx(String aprsisPacket) {
|
||||
String firstPart, messagePart;
|
||||
aprsisPacket.trim();
|
||||
firstPart = aprsisPacket.substring(0, aprsisPacket.indexOf(","));
|
||||
messagePart = aprsisPacket.substring(aprsisPacket.indexOf("::") + 2);
|
||||
String buildPacketToTx(const String& aprsisPacket) {
|
||||
String packet = aprsisPacket;
|
||||
packet.trim();
|
||||
String firstPart = packet.substring(0, packet.indexOf(","));
|
||||
String messagePart = packet.substring(packet.indexOf("::") + 2);
|
||||
return firstPart + ",TCPIP,WIDE1-1," + Config.callsign + "::" + messagePart;
|
||||
}
|
||||
|
||||
bool processReceivedLoRaMessage(String sender, String packet) {
|
||||
String ackMessage, receivedMessage;
|
||||
bool processReceivedLoRaMessage(const String& sender, const String& packet) {
|
||||
String receivedMessage;
|
||||
if (packet.indexOf("{") > 0) { // ack?
|
||||
ackMessage = "ack" + packet.substring(packet.indexOf("{") + 1);
|
||||
String ackMessage = "ack" + packet.substring(packet.indexOf("{") + 1);
|
||||
ackMessage.trim();
|
||||
//Serial.println(ackMessage);
|
||||
String processedSender = sender;
|
||||
for (int i = sender.length(); i < 9; i++) {
|
||||
sender += ' ';
|
||||
processedSender += ' ';
|
||||
}
|
||||
if (Config.beacon.path == "") {
|
||||
STATION_Utils::addToOutputPacketBuffer(Config.callsign + ">APLRG1,RFONLY::" + sender + ":" + ackMessage);
|
||||
STATION_Utils::addToOutputPacketBuffer(Config.callsign + ">APLRG1,RFONLY::" + processedSender + ":" + ackMessage);
|
||||
} else {
|
||||
STATION_Utils::addToOutputPacketBuffer(Config.callsign + ">APLRG1,RFONLY," + Config.beacon.path + "::" + sender + ":" + ackMessage);
|
||||
STATION_Utils::addToOutputPacketBuffer(Config.callsign + ">APLRG1,RFONLY," + Config.beacon.path + "::" + processedSender + ":" + ackMessage);
|
||||
}
|
||||
|
||||
receivedMessage = packet.substring(packet.indexOf(":") + 1, packet.indexOf("{"));
|
||||
@@ -139,7 +140,7 @@ namespace APRS_IS_Utils {
|
||||
if (!Config.display.alwaysOn && Config.display.timeout != 0) {
|
||||
display_toggle(true);
|
||||
}
|
||||
STATION_Utils::addToOutputPacketBuffer(QUERY_Utils::process(receivedMessage, sender, "LoRa"));
|
||||
STATION_Utils::addToOutputPacketBuffer(QUERY_Utils::process(receivedMessage, sender, 0)); // LoRa
|
||||
lastScreenOn = millis();
|
||||
show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, "Callsign = " + sender, "TYPE --> QUERY", 0);
|
||||
return true;
|
||||
@@ -149,7 +150,7 @@ namespace APRS_IS_Utils {
|
||||
}
|
||||
}
|
||||
|
||||
void processLoRaPacket(String packet) {
|
||||
void processLoRaPacket(const String& packet) {
|
||||
if (espClient.connected() || modemLoggedToAPRSIS) {
|
||||
bool queryMessage = false;
|
||||
String aprsPacket, Sender, AddresseeAndMessage, Addressee;
|
||||
@@ -159,7 +160,7 @@ namespace APRS_IS_Utils {
|
||||
if (Sender != Config.callsign) { // avoid listening yourself by digirepeating
|
||||
if (STATION_Utils::check25SegBuffer(Sender, packet.substring(packet.indexOf(":")+2))) {
|
||||
STATION_Utils::updateLastHeard(Sender);
|
||||
Utils::typeOfPacket(packet.substring(3), "LoRa-APRS");
|
||||
Utils::typeOfPacket(packet.substring(3), 0); // LoRa-APRS
|
||||
AddresseeAndMessage = packet.substring(packet.indexOf("::") + 2);
|
||||
Addressee = AddresseeAndMessage.substring(0, AddresseeAndMessage.indexOf(":"));
|
||||
Addressee.trim();
|
||||
@@ -189,7 +190,7 @@ namespace APRS_IS_Utils {
|
||||
}
|
||||
}
|
||||
|
||||
void processAPRSISPacket(String packet) {
|
||||
void processAPRSISPacket(const String& packet) {
|
||||
String Sender, AddresseeAndMessage, Addressee, receivedMessage;
|
||||
if (!packet.startsWith("#")) {
|
||||
if (packet.indexOf("::") > 0) {
|
||||
@@ -217,7 +218,7 @@ namespace APRS_IS_Utils {
|
||||
}
|
||||
if (receivedMessage.indexOf("?") == 0) {
|
||||
Utils::println("Received Query APRS-IS : " + packet);
|
||||
String queryAnswer = QUERY_Utils::process(receivedMessage, Sender, "APRSIS");
|
||||
String queryAnswer = QUERY_Utils::process(receivedMessage, Sender, 1); // APRSIS
|
||||
//Serial.println("---> QUERY Answer : " + queryAnswer.substring(0,queryAnswer.indexOf("\n")));
|
||||
if (!Config.display.alwaysOn && Config.display.timeout != 0) {
|
||||
display_toggle(true);
|
||||
@@ -229,7 +230,7 @@ namespace APRS_IS_Utils {
|
||||
#else
|
||||
upload(queryAnswer);
|
||||
#endif
|
||||
SYSLOG_Utils::log("APRSIS Tx", queryAnswer, 0, 0, 0);
|
||||
SYSLOG_Utils::log(2, queryAnswer, 0, 0, 0); // APRSIS TX
|
||||
fifthLine = "APRS-IS ----> APRS-IS";
|
||||
sixthLine = Config.callsign;
|
||||
for (int j = sixthLine.length();j < 9;j++) {
|
||||
@@ -245,7 +246,7 @@ namespace APRS_IS_Utils {
|
||||
STATION_Utils::addToOutputPacketBuffer(buildPacketToTx(packet));
|
||||
display_toggle(true);
|
||||
lastScreenOn = millis();
|
||||
Utils::typeOfPacket(packet, "APRS-LoRa");
|
||||
Utils::typeOfPacket(packet, 1); // APRS-LoRa
|
||||
}
|
||||
}
|
||||
show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0);
|
||||
|
||||
+6
-6
@@ -6,14 +6,14 @@
|
||||
|
||||
namespace APRS_IS_Utils {
|
||||
|
||||
void upload(String line);
|
||||
void upload(const String& line);
|
||||
void connect();
|
||||
void checkStatus();
|
||||
String buildPacketToUpload(String unprocessedPacket);
|
||||
String buildPacketToTx(String aprsisPacket);
|
||||
bool processReceivedLoRaMessage(String sender, String packet);
|
||||
void processLoRaPacket(String packet);
|
||||
void processAPRSISPacket(String packet);
|
||||
String buildPacketToUpload(const String& packet);
|
||||
String buildPacketToTx(const String& aprsisPacket);
|
||||
bool processReceivedLoRaMessage(const String& sender, const String& packet);
|
||||
void processLoRaPacket(const String& packet);
|
||||
void processAPRSISPacket(const String& packet);
|
||||
void listenAPRSIS();
|
||||
|
||||
}
|
||||
|
||||
+3
-3
@@ -23,7 +23,7 @@ extern String seventhLine;
|
||||
|
||||
namespace DIGI_Utils {
|
||||
|
||||
String generateDigiRepeatedPacket(String packet){
|
||||
String generateDigiRepeatedPacket(const String& packet){
|
||||
String sender, temp0, tocall, path;
|
||||
sender = packet.substring(0, packet.indexOf(">"));
|
||||
temp0 = packet.substring(packet.indexOf(">") + 1, packet.indexOf(":"));
|
||||
@@ -55,7 +55,7 @@ namespace DIGI_Utils {
|
||||
}
|
||||
}
|
||||
|
||||
void processLoRaPacket(String packet) {
|
||||
void processLoRaPacket(const String& packet) {
|
||||
bool queryMessage = false;
|
||||
String loraPacket, Sender, AddresseeAndMessage, Addressee;
|
||||
if (packet != "") {
|
||||
@@ -64,7 +64,7 @@ namespace DIGI_Utils {
|
||||
if (Sender != Config.callsign) {
|
||||
if (STATION_Utils::check25SegBuffer(Sender, packet.substring(packet.indexOf(":")+2))) {
|
||||
STATION_Utils::updateLastHeard(Sender);
|
||||
Utils::typeOfPacket(packet.substring(3), "Digi");
|
||||
Utils::typeOfPacket(packet.substring(3), 2); // Digi
|
||||
AddresseeAndMessage = packet.substring(packet.indexOf("::") + 2);
|
||||
Addressee = AddresseeAndMessage.substring(0, AddresseeAndMessage.indexOf(":"));
|
||||
Addressee.trim();
|
||||
|
||||
+2
-2
@@ -6,8 +6,8 @@
|
||||
|
||||
namespace DIGI_Utils {
|
||||
|
||||
String generateDigiRepeatedPacket(String packet);
|
||||
void processLoRaPacket(String packet);
|
||||
String generateDigiRepeatedPacket(const String& packet);
|
||||
void processLoRaPacket(const String& packet);
|
||||
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -94,7 +94,7 @@ void display_toggle(bool toggle) {
|
||||
#endif
|
||||
}
|
||||
|
||||
bool shouldCleanTFT(String header, String line1, String line2, String line3) {
|
||||
bool shouldCleanTFT(const String& header, const String& line1, const String& line2, const String& line3) {
|
||||
if (oldHeader != header || oldFirstLine != line1 || oldSecondLine != line2 || oldThirdLine != line3) {
|
||||
oldHeader = header;
|
||||
oldFirstLine = line1;
|
||||
@@ -106,7 +106,7 @@ bool shouldCleanTFT(String header, String line1, String line2, String line3) {
|
||||
}
|
||||
}
|
||||
|
||||
bool shouldCleanTFT(String header, String line1, String line2, String line3, String line4, String line5, String line6) {
|
||||
bool shouldCleanTFT(const String& header, const String& line1, const String& line2, const String& line3, const String& line4, const String& line5, const String& line6) {
|
||||
if (oldHeader != header || oldFirstLine != line1 || oldSecondLine != line2 || oldThirdLine != line3 || oldFourthLine != line4 || oldFifthLine != line5 || oldSixthLine != line6) {
|
||||
oldHeader = header;
|
||||
oldFirstLine = line1;
|
||||
@@ -121,7 +121,7 @@ bool shouldCleanTFT(String header, String line1, String line2, String line3, Str
|
||||
}
|
||||
}
|
||||
|
||||
void show_display(String header, String line1, String line2, String line3, int wait) {
|
||||
void show_display(const String& header, const String& line1, const String& line2, const String& line3, int wait) {
|
||||
#ifdef HAS_DISPLAY
|
||||
#ifdef HAS_TFT
|
||||
if (shouldCleanTFT(header, line1, line2, line3)) {
|
||||
@@ -158,7 +158,7 @@ void show_display(String header, String line1, String line2, String line3, int w
|
||||
#endif
|
||||
}
|
||||
|
||||
void show_display(String header, String line1, String line2, String line3, String line4, String line5, String line6, int wait) {
|
||||
void show_display(const String& header, const String& line1, const String& line2, const String& line3, const String& line4, const String& line5, const String& line6, int wait) {
|
||||
#ifdef HAS_DISPLAY
|
||||
#ifdef HAS_TFT
|
||||
if (shouldCleanTFT(header, line1, line2, line3, line4, line5, line6)) {
|
||||
|
||||
+4
-4
@@ -9,10 +9,10 @@ void cleanTFT();
|
||||
void setup_display();
|
||||
void display_toggle(bool toggle);
|
||||
|
||||
bool shouldCleanTFT(String header, String line1, String line2, String line3);
|
||||
bool shouldCleanTFT(String header, String line1, String line2, String line3, String line4, String line5, String line6);
|
||||
bool shouldCleanTFT(const String& header, const String& line1, const String& line2, const String& line3);
|
||||
bool shouldCleanTFT(const String& header, const String& line1, const String& line2, const String& line3, const String& line4, const String& line5, const String& line6);
|
||||
|
||||
void show_display(String header, String line1, String line2, String line3, int wait = 0);
|
||||
void show_display(String header, String line1, String line2, String line3, String line4, String line5, String line6, int wait = 0);
|
||||
void show_display(const String& header, const String& line1, const String& line2, const String& line3, int wait = 0);
|
||||
void show_display(const String& header, const String& line1, const String& line2, const String& line3, const String& line4, const String& line5, const String& line6, int wait = 0);
|
||||
|
||||
#endif
|
||||
+4
-4
@@ -22,7 +22,7 @@ namespace GPS_Utils {
|
||||
return(s);
|
||||
}
|
||||
|
||||
String encodeGPS(float latitude, float longitude, String overlay, String symbol) {
|
||||
String encodeGPS(float latitude, float longitude, const String& overlay, const String& symbol) {
|
||||
String encodedData = overlay;
|
||||
uint32_t aprs_lat, aprs_lon;
|
||||
aprs_lat = 900000000 - latitude * 10000000;
|
||||
@@ -65,7 +65,7 @@ namespace GPS_Utils {
|
||||
return TinyGPSPlus::distanceBetween(Config.beacon.latitude,Config.beacon.longitude, latitude, longitude) / 1000.0;
|
||||
}
|
||||
|
||||
String decodeEncodedGPS(String packet) {
|
||||
String decodeEncodedGPS(const String& packet) {
|
||||
String GPSPacket = packet.substring(packet.indexOf(":!")+3);
|
||||
String encodedLatitude = GPSPacket.substring(0,4);
|
||||
String encodedLongtitude = GPSPacket.substring(4,8);
|
||||
@@ -85,7 +85,7 @@ namespace GPS_Utils {
|
||||
return String(decodedLatitude,5) + "N / " + String(decodedLongitude,5) + "E / " + distance + "km";
|
||||
}
|
||||
|
||||
String getReceivedGPS(String packet) {
|
||||
String getReceivedGPS(const String& packet) {
|
||||
String infoGPS;
|
||||
if (packet.indexOf(":!") > 10) {
|
||||
infoGPS = packet.substring(packet.indexOf(":!")+2);
|
||||
@@ -117,7 +117,7 @@ namespace GPS_Utils {
|
||||
return String(convertedLatitude,5) + "N / " + String(convertedLongitude,5) + "E / " + distance + "km";
|
||||
}
|
||||
|
||||
String getDistance(String packet) {
|
||||
String getDistance(const String& packet) {
|
||||
uint8_t encodedBytePosition = 0;
|
||||
if (packet.indexOf(":!") > 10) {
|
||||
encodedBytePosition = packet.indexOf(":!") + 14;
|
||||
|
||||
+4
-4
@@ -8,12 +8,12 @@ namespace GPS_Utils {
|
||||
|
||||
String getiGateLoRaBeaconPacket();
|
||||
char *ax25_base91enc(char *s, uint8_t n, uint32_t v);
|
||||
String encodeGPS(float latitude, float longitude, String overlay, String symbol);
|
||||
String encodeGPS(float latitude, float longitude, const String& overlay, const String& symbol);
|
||||
void generateBeacons();
|
||||
double calculateDistanceCourse(double latitude, double longitude);
|
||||
String decodeEncodedGPS(String packet);
|
||||
String getReceivedGPS(String packet);
|
||||
String getDistance(String packet);
|
||||
String decodeEncodedGPS(const String& packet);
|
||||
String getReceivedGPS(const String& packet);
|
||||
String getDistance(const String& packet);
|
||||
|
||||
}
|
||||
|
||||
|
||||
+9
-8
@@ -114,7 +114,7 @@ namespace LoRa_Utils {
|
||||
transmissionFlag = true;
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
if (Config.syslog.active && WiFi.status() == WL_CONNECTED) {
|
||||
SYSLOG_Utils::log("Tx", newPacket, 0, 0, 0);
|
||||
SYSLOG_Utils::log(3, newPacket, 0, 0, 0); // TX
|
||||
}
|
||||
Utils::print("---> LoRa Packet Tx : ");
|
||||
Utils::println(newPacket);
|
||||
@@ -131,17 +131,18 @@ namespace LoRa_Utils {
|
||||
//ignorePacket = true;
|
||||
}
|
||||
|
||||
String packetSanitization(String packet) {
|
||||
String packetSanitization(const String& packet) {
|
||||
String sanitizedPacket = packet;
|
||||
if (packet.indexOf("\0") > 0) {
|
||||
packet.replace("\0", "");
|
||||
sanitizedPacket.replace("\0", "");
|
||||
}
|
||||
if (packet.indexOf("\r") > 0) {
|
||||
packet.replace("\r", "");
|
||||
sanitizedPacket.replace("\r", "");
|
||||
}
|
||||
if (packet.indexOf("\n") > 0) {
|
||||
packet.replace("\n", "");
|
||||
sanitizedPacket.replace("\n", "");
|
||||
}
|
||||
return packet;
|
||||
return sanitizedPacket;
|
||||
}
|
||||
|
||||
void startReceive() {
|
||||
@@ -183,7 +184,7 @@ namespace LoRa_Utils {
|
||||
}
|
||||
|
||||
if (Config.syslog.active && WiFi.status() == WL_CONNECTED) {
|
||||
SYSLOG_Utils::log("Rx", loraPacket, rssi, snr, freqError);
|
||||
SYSLOG_Utils::log(1, loraPacket, rssi, snr, freqError); // RX
|
||||
}
|
||||
lastRxTime = millis();
|
||||
return loraPacket;
|
||||
@@ -194,7 +195,7 @@ namespace LoRa_Utils {
|
||||
freqError = radio.getFrequencyError();
|
||||
Utils::println(F("CRC error!"));
|
||||
if (Config.syslog.active && WiFi.status() == WL_CONNECTED) {
|
||||
SYSLOG_Utils::log("CRC", loraPacket, rssi, snr, freqError);
|
||||
SYSLOG_Utils::log(0, loraPacket, rssi, snr, freqError); // CRC
|
||||
}
|
||||
loraPacket = "";
|
||||
} else {
|
||||
|
||||
+2
-2
@@ -7,8 +7,8 @@
|
||||
namespace LoRa_Utils {
|
||||
|
||||
void setup();
|
||||
void sendNewPacket(const String &newPacket);
|
||||
String packetSanitization(String packet);
|
||||
void sendNewPacket(const String& newPacket);
|
||||
String packetSanitization(const String& packet);
|
||||
String receivePacket();
|
||||
void changeFreqTx();
|
||||
void changeFreqRx();
|
||||
|
||||
+8
-7
@@ -8,7 +8,7 @@ extern String versionDate;
|
||||
|
||||
namespace QUERY_Utils {
|
||||
|
||||
String process(String query, String station, String queryOrigin) {
|
||||
String process(const String& query, const String& station, uint8_t queryOrigin) {
|
||||
String answer;
|
||||
if (query=="?APRS?" || query=="?aprs?" || query=="?Aprs?" || query=="H" || query=="h" || query=="HELP" || query=="Help" || query=="help" || query=="?") {
|
||||
answer = "?APRSV ?APRSP ?APRSL ?APRSH ?WHERE callsign";
|
||||
@@ -34,16 +34,17 @@ namespace QUERY_Utils {
|
||||
Serial.println("estaciones escuchadas directo (ultimos 30 min)");
|
||||
answer = "?WHERE on development 73!";
|
||||
}
|
||||
String processedStation = station;
|
||||
for(int i = station.length(); i < 9; i++) {
|
||||
station += ' ';
|
||||
processedStation += ' ';
|
||||
}
|
||||
if (queryOrigin == "APRSIS") {
|
||||
return Config.callsign + ">APLRG1,TCPIP,qAC::" + station + ":" + answer;// + "\n";
|
||||
} else { //} if (queryOrigin == "LoRa") {
|
||||
if (queryOrigin == 1) { // from APRS-IS
|
||||
return Config.callsign + ">APLRG1,TCPIP,qAC::" + processedStation + ":" + answer;
|
||||
} else { // else == 0 , from LoRa
|
||||
if (Config.beacon.path == "") {
|
||||
return Config.callsign + ">APLRG1,RFONLY::" + station + ":" + answer;
|
||||
return Config.callsign + ">APLRG1,RFONLY::" + processedStation + ":" + answer;
|
||||
} else {
|
||||
return Config.callsign + ">APLRG1,RFONLY," + Config.beacon.path + "::" + station + ":" + answer;
|
||||
return Config.callsign + ">APLRG1,RFONLY," + Config.beacon.path + "::" + processedStation + ":" + answer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
|
||||
namespace QUERY_Utils {
|
||||
|
||||
String process(String query, String station, String queryOrigin);
|
||||
String process(const String& query, const String& station, uint8_t queryOrigin);
|
||||
|
||||
}
|
||||
|
||||
|
||||
+51
-45
@@ -11,56 +11,62 @@ WiFiUDP udpClient;
|
||||
|
||||
namespace SYSLOG_Utils {
|
||||
|
||||
void log(String type, String packet, int rssi, float snr, int freqError) {
|
||||
void log(uint8_t type, const String& packet, int rssi, float snr, int freqError) {
|
||||
String syslogPacket = "<165>1 - " + Config.callsign + " CA2RXU_LoRa_iGate_1.3" + " - - - "; //RFC5424 The Syslog Protocol
|
||||
if (Config.syslog.active && WiFi.status() == WL_CONNECTED) {
|
||||
if (type == "APRSIS Tx") {
|
||||
if (packet.indexOf(":>") > 10) {
|
||||
syslogPacket += type + " / StartUp_Status / " + packet.substring(packet.indexOf(":>")+2);
|
||||
} else {
|
||||
syslogPacket += type + " / QUERY / " + packet;
|
||||
}
|
||||
} else if (type == "Rx") {
|
||||
if (packet.indexOf("::") > 10) {
|
||||
syslogPacket += type + " / MESSAGE / " + packet.substring(3,packet.indexOf(">")) + " ---> " + packet.substring(packet.indexOf("::")+2);
|
||||
switch (type) {
|
||||
case 0: // CRC
|
||||
syslogPacket += type + " / CRC-ERROR / " + packet;
|
||||
syslogPacket += " / " + String(rssi) + "dBm / " + String(snr) + "dB / " + String(freqError) + "Hz";
|
||||
} else if (packet.indexOf(":!") > 10 || packet.indexOf(":=") > 10) {
|
||||
syslogPacket += type + " / GPS / " + packet.substring(3,packet.indexOf(">")) + " / ";
|
||||
if (packet.indexOf("WIDE1-1") > 10) {
|
||||
syslogPacket += packet.substring(packet.indexOf(">")+1,packet.indexOf(",")) + " / WIDE1-1 / ";
|
||||
break;
|
||||
case 1: // RX
|
||||
if (packet.indexOf("::") > 10) {
|
||||
syslogPacket += type + " / MESSAGE / " + packet.substring(3,packet.indexOf(">")) + " ---> " + packet.substring(packet.indexOf("::")+2);
|
||||
syslogPacket += " / " + String(rssi) + "dBm / " + String(snr) + "dB / " + String(freqError) + "Hz";
|
||||
} else if (packet.indexOf(":!") > 10 || packet.indexOf(":=") > 10) {
|
||||
syslogPacket += type + " / GPS / " + packet.substring(3,packet.indexOf(">")) + " / ";
|
||||
if (packet.indexOf("WIDE1-1") > 10) {
|
||||
syslogPacket += packet.substring(packet.indexOf(">")+1,packet.indexOf(",")) + " / WIDE1-1 / ";
|
||||
} else {
|
||||
syslogPacket += packet.substring(packet.indexOf(">")+1,packet.indexOf(":")) + " / - / ";
|
||||
}
|
||||
syslogPacket += String(rssi) + "dBm / " + String(snr) + "dB / " + String(freqError) + "Hz / " + GPS_Utils::getDistance(packet);
|
||||
} else if (packet.indexOf(":>") > 10) {
|
||||
syslogPacket += type + " / STATUS / " + packet.substring(3,packet.indexOf(">")) + " ---> " + packet.substring(packet.indexOf(":>")+2);
|
||||
syslogPacket += " / " + String(rssi) + "dBm / " + String(snr) + "dB / " + String(freqError) + "Hz";
|
||||
} else if (packet.indexOf(":`") > 10) {
|
||||
syslogPacket += type + " / MIC-E / " + packet.substring(3,packet.indexOf(">")) + " ---> " + packet.substring(packet.indexOf(":`")+2);
|
||||
syslogPacket += " / " + String(rssi) + "dBm / " + String(snr) + "dB / " + String(freqError) + "Hz";
|
||||
} else if (packet.indexOf(":T#") >= 10 && packet.indexOf(":=/") == -1) {
|
||||
syslogPacket += type + " / TELEMETRY / " + packet.substring(3,packet.indexOf(">")) + " ---> " + packet.substring(packet.indexOf(":T#")+3);
|
||||
syslogPacket += " / " + String(rssi) + "dBm / " + String(snr) + "dB / " + String(freqError) + "Hz";
|
||||
} else if (packet.indexOf(":;") > 10) {
|
||||
syslogPacket += type + " / OBJECT / " + packet.substring(3,packet.indexOf(">")) + " ---> " + packet.substring(packet.indexOf(":;")+2);
|
||||
syslogPacket += " / " + String(rssi) + "dBm / " + String(snr) + "dB / " + String(freqError) + "Hz";
|
||||
} else {
|
||||
syslogPacket += packet.substring(packet.indexOf(">")+1,packet.indexOf(":")) + " / - / ";
|
||||
syslogPacket += type + " / " + packet;
|
||||
syslogPacket += " / " + String(rssi) + "dBm / " + String(snr) + "dB / " + String(freqError) + "Hz";
|
||||
}
|
||||
syslogPacket += String(rssi) + "dBm / " + String(snr) + "dB / " + String(freqError) + "Hz / " + GPS_Utils::getDistance(packet);
|
||||
} else if (packet.indexOf(":>") > 10) {
|
||||
syslogPacket += type + " / STATUS / " + packet.substring(3,packet.indexOf(">")) + " ---> " + packet.substring(packet.indexOf(":>")+2);
|
||||
syslogPacket += " / " + String(rssi) + "dBm / " + String(snr) + "dB / " + String(freqError) + "Hz";
|
||||
} else if (packet.indexOf(":`") > 10) {
|
||||
syslogPacket += type + " / MIC-E / " + packet.substring(3,packet.indexOf(">")) + " ---> " + packet.substring(packet.indexOf(":`")+2);
|
||||
syslogPacket += " / " + String(rssi) + "dBm / " + String(snr) + "dB / " + String(freqError) + "Hz";
|
||||
} else if (packet.indexOf(":T#") >= 10 && packet.indexOf(":=/") == -1) {
|
||||
syslogPacket += type + " / TELEMETRY / " + packet.substring(3,packet.indexOf(">")) + " ---> " + packet.substring(packet.indexOf(":T#")+3);
|
||||
syslogPacket += " / " + String(rssi) + "dBm / " + String(snr) + "dB / " + String(freqError) + "Hz";
|
||||
} else if (packet.indexOf(":;") > 10) {
|
||||
syslogPacket += type + " / OBJECT / " + packet.substring(3,packet.indexOf(">")) + " ---> " + packet.substring(packet.indexOf(":;")+2);
|
||||
syslogPacket += " / " + String(rssi) + "dBm / " + String(snr) + "dB / " + String(freqError) + "Hz";
|
||||
} else {
|
||||
syslogPacket += type + " / " + packet;
|
||||
syslogPacket += " / " + String(rssi) + "dBm / " + String(snr) + "dB / " + String(freqError) + "Hz";
|
||||
}
|
||||
} else if (type == "Tx") {
|
||||
if (packet.indexOf("RFONLY") > 10) {
|
||||
syslogPacket += type + " / RFONLY / " + packet;
|
||||
} else if (packet.indexOf("::") > 10) {
|
||||
syslogPacket += type + " / MESSAGE / " + packet.substring(0,packet.indexOf(">")) + " ---> " + packet.substring(packet.indexOf("::")+2);
|
||||
} else {
|
||||
syslogPacket += type + " / " + packet;
|
||||
}
|
||||
} else if (type == "CRC") {
|
||||
syslogPacket += type + " / CRC-ERROR / " + packet;
|
||||
syslogPacket += " / " + String(rssi) + "dBm / " + String(snr) + "dB / " + String(freqError) + "Hz";
|
||||
} else {
|
||||
syslogPacket = "<165>1 - ERROR LoRa - - - ERROR / Error in Syslog Packet"; //RFC5424 The Syslog Protocol
|
||||
break;
|
||||
case 2: // APRSIS TX
|
||||
if (packet.indexOf(":>") > 10) {
|
||||
syslogPacket += type + " / StartUp_Status / " + packet.substring(packet.indexOf(":>")+2);
|
||||
} else {
|
||||
syslogPacket += type + " / QUERY / " + packet;
|
||||
}
|
||||
break;
|
||||
case 3: // TX
|
||||
if (packet.indexOf("RFONLY") > 10) {
|
||||
syslogPacket += type + " / RFONLY / " + packet;
|
||||
} else if (packet.indexOf("::") > 10) {
|
||||
syslogPacket += type + " / MESSAGE / " + packet.substring(0,packet.indexOf(">")) + " ---> " + packet.substring(packet.indexOf("::")+2);
|
||||
} else {
|
||||
syslogPacket += type + " / " + packet;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
syslogPacket = "<165>1 - ERROR LoRa - - - ERROR / Error in Syslog Packet"; //RFC5424 The Syslog Protocol
|
||||
break;
|
||||
}
|
||||
udpClient.beginPacket(Config.syslog.server.c_str(), Config.syslog.port);
|
||||
udpClient.write((const uint8_t*)syslogPacket.c_str(), syslogPacket.length());
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
|
||||
namespace SYSLOG_Utils {
|
||||
|
||||
void log(String type ,String packet, int rssi, float snr, int freqError);
|
||||
void log(uint8_t type ,const String& packet, int rssi, float snr, int freqError);
|
||||
void setup();
|
||||
|
||||
}
|
||||
|
||||
+17
-13
@@ -49,7 +49,7 @@ namespace Utils {
|
||||
delay(1000);
|
||||
status += ",qAC:>https://github.com/richonguzman/LoRa_APRS_iGate " + versionDate;
|
||||
APRS_IS_Utils::upload(status);
|
||||
SYSLOG_Utils::log("APRSIS Tx", status,0,0,0);
|
||||
SYSLOG_Utils::log(2, status,0,0,0); // APRSIS TX
|
||||
statusAfterBoot = false;
|
||||
}
|
||||
if (statusAfterBoot && !Config.beacon.sendViaAPRSIS && Config.beacon.sendViaRF) {
|
||||
@@ -191,17 +191,21 @@ namespace Utils {
|
||||
}
|
||||
}
|
||||
|
||||
void typeOfPacket(String packet, String packetType) {
|
||||
void typeOfPacket(const String& packet, uint8_t packetType) {
|
||||
String sender;
|
||||
if (packetType == "LoRa-APRS") {
|
||||
fifthLine = "LoRa Rx ----> APRS-IS";
|
||||
sender = packet.substring(0,packet.indexOf(">"));
|
||||
} else if (packetType == "APRS-LoRa") {
|
||||
fifthLine = "APRS-IS ----> LoRa Tx";
|
||||
sender = packet.substring(0,packet.indexOf(">"));
|
||||
} else if (packetType == "Digi") {
|
||||
fifthLine = "LoRa Rx ----> LoRa Tx";
|
||||
sender = packet.substring(0,packet.indexOf(">"));
|
||||
switch (packetType) {
|
||||
case 0: // LoRa-APRS
|
||||
fifthLine = "LoRa Rx ----> APRS-IS";
|
||||
sender = packet.substring(0,packet.indexOf(">"));
|
||||
break;
|
||||
case 1: // APRS-LoRa
|
||||
fifthLine = "APRS-IS ----> LoRa Tx";
|
||||
sender = packet.substring(0,packet.indexOf(">"));
|
||||
break;
|
||||
case 2: // Digi
|
||||
fifthLine = "LoRa Rx ----> LoRa Tx";
|
||||
sender = packet.substring(0,packet.indexOf(">"));
|
||||
break;
|
||||
}
|
||||
for (int i = sender.length(); i < 9; i++) {
|
||||
sender += " ";
|
||||
@@ -240,13 +244,13 @@ namespace Utils {
|
||||
}
|
||||
}
|
||||
|
||||
void print(String text) {
|
||||
void print(const String& text) {
|
||||
if (!Config.tnc.enableSerial) {
|
||||
Serial.print(text);
|
||||
}
|
||||
}
|
||||
|
||||
void println(String text) {
|
||||
void println(const String& text) {
|
||||
if (!Config.tnc.enableSerial) {
|
||||
Serial.println(text);
|
||||
}
|
||||
|
||||
+3
-3
@@ -21,9 +21,9 @@ namespace Utils {
|
||||
void checkDisplayInterval();
|
||||
void checkWiFiInterval();
|
||||
void validateFreqs();
|
||||
void typeOfPacket(String packet, String packetType);
|
||||
void print(String text);
|
||||
void println(String text);
|
||||
void typeOfPacket(const String& packet, uint8_t packetType);
|
||||
void print(const String& text);
|
||||
void println(const String& text);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user