diff --git a/src/aprs_is_utils.cpp b/src/aprs_is_utils.cpp index 4b22fbe..0e7c190 100644 --- a/src/aprs_is_utils.cpp +++ b/src/aprs_is_utils.cpp @@ -262,7 +262,7 @@ namespace APRS_IS_Utils { #else upload(queryAnswer); #endif - SYSLOG_Utils::log(2, queryAnswer, 0, 0, 0); // APRSIS TX + SYSLOG_Utils::log(2, queryAnswer, 0, 0.0, 0); // APRSIS TX fifthLine = "APRS-IS ----> APRS-IS"; sixthLine = Config.callsign; for (int j = sixthLine.length();j < 9;j++) { diff --git a/src/lora_utils.cpp b/src/lora_utils.cpp index f77bd79..8e0c022 100644 --- a/src/lora_utils.cpp +++ b/src/lora_utils.cpp @@ -118,7 +118,7 @@ namespace LoRa_Utils { transmitFlag = true; if (state == RADIOLIB_ERR_NONE) { if (Config.syslog.active && WiFi.status() == WL_CONNECTED) { - SYSLOG_Utils::log(3, newPacket, 0, 0, 0); // TX + SYSLOG_Utils::log(3, newPacket, 0, 0.0, 0); // TX } Utils::print("---> LoRa Packet Tx : "); Utils::println(newPacket); diff --git a/src/syslog_utils.cpp b/src/syslog_utils.cpp index c5d6770..45c93ad 100644 --- a/src/syslog_utils.cpp +++ b/src/syslog_utils.cpp @@ -12,58 +12,94 @@ WiFiUDP udpClient; namespace SYSLOG_Utils { 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) { + String syslogPacket = "<165>1 - "; + syslogPacket.concat(Config.callsign); + syslogPacket.concat(" CA2RXU_LoRa_iGate_1.3 - - - "); //RFC5424 The Syslog Protocol + + char signalData[35]; + snprintf(signalData, sizeof(signalData), " / %ddBm / %.2fdB / %dHz", rssi, snr, freqError); + switch (type) { case 0: // CRC - syslogPacket += type + " / CRC-ERROR / " + packet; - syslogPacket += " / " + String(rssi) + "dBm / " + String(snr) + "dB / " + String(freqError) + "Hz"; + syslogPacket.concat("CRC / CRC-ERROR / "); + syslogPacket.concat(packet); + syslogPacket.concat(signalData); break; case 1: // RX + syslogPacket.concat("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"; + syslogPacket.concat("MESSAGE / "); + syslogPacket.concat(packet.substring(3, packet.indexOf(">"))); + syslogPacket.concat(" ---> "); syslogPacket.concat(packet.substring(packet.indexOf("::") + 2)); + syslogPacket.concat(signalData); } else if (packet.indexOf(":!") > 10 || packet.indexOf(":=") > 10) { - syslogPacket += type + " / GPS / " + packet.substring(3,packet.indexOf(">")) + " / "; + syslogPacket.concat("GPS / "); + syslogPacket.concat(packet.substring(3, packet.indexOf(">"))); + syslogPacket.concat(" / "); if (packet.indexOf("WIDE1-1") > 10) { - syslogPacket += packet.substring(packet.indexOf(">")+1,packet.indexOf(",")) + " / WIDE1-1 / "; + syslogPacket.concat(packet.substring(packet.indexOf(">") + 1, packet.indexOf(","))); + syslogPacket.concat(" / WIDE1-1"); } else { - syslogPacket += packet.substring(packet.indexOf(">")+1,packet.indexOf(":")) + " / - / "; + syslogPacket.concat(packet.substring(packet.indexOf(">") + 1, packet.indexOf(":"))); + syslogPacket.concat(" / -"); } - syslogPacket += String(rssi) + "dBm / " + String(snr) + "dB / " + String(freqError) + "Hz / " + GPS_Utils::getDistanceAndComment(packet); + syslogPacket.concat(signalData); + syslogPacket.concat(" / "); + syslogPacket.concat(GPS_Utils::getDistanceAndComment(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"; + syslogPacket.concat("STATUS / "); + syslogPacket.concat(packet.substring(3, packet.indexOf(">"))); + syslogPacket.concat(" ---> "); + syslogPacket.concat(packet.substring(packet.indexOf(":>") + 2)); + syslogPacket.concat(signalData); } 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"; + syslogPacket.concat("MIC-E / "); + syslogPacket.concat(packet.substring(3, packet.indexOf(">"))); + syslogPacket.concat(" ---> "); + syslogPacket.concat(packet.substring(packet.indexOf(":`") + 2)); + syslogPacket.concat(signalData); } 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"; + syslogPacket.concat("TELEMETRY / "); + syslogPacket.concat(packet.substring(3, packet.indexOf(">"))); + syslogPacket.concat(" ---> "); + syslogPacket.concat(packet.substring(packet.indexOf(":T#") + 3)); + syslogPacket.concat(signalData); } 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"; + syslogPacket.concat("OBJECT / "); + syslogPacket.concat(packet.substring(3, packet.indexOf(">"))); + syslogPacket.concat(" ---> "); + syslogPacket.concat(packet.substring(packet.indexOf(":;") + 2)); + syslogPacket.concat(signalData); } else { - syslogPacket += type + " / " + packet; - syslogPacket += " / " + String(rssi) + "dBm / " + String(snr) + "dB / " + String(freqError) + "Hz"; + syslogPacket.concat(packet); + syslogPacket.concat(signalData); } break; case 2: // APRSIS TX + syslogPacket.concat("APRSIS TX / "); if (packet.indexOf(":>") > 10) { - syslogPacket += type + " / StartUp_Status / " + packet.substring(packet.indexOf(":>")+2); + syslogPacket.concat("StartUp_Status / "); + syslogPacket.concat(packet.substring(packet.indexOf(":>") + 2)); } else { - syslogPacket += type + " / QUERY / " + packet; + syslogPacket.concat("QUERY / "); + syslogPacket.concat(packet); } break; case 3: // TX + syslogPacket.concat("TX / "); if (packet.indexOf("RFONLY") > 10) { - syslogPacket += type + " / RFONLY / " + packet; + syslogPacket.concat("RFONLY / "); + syslogPacket.concat(packet); } else if (packet.indexOf("::") > 10) { - syslogPacket += type + " / MESSAGE / " + packet.substring(0,packet.indexOf(">")) + " ---> " + packet.substring(packet.indexOf("::")+2); + syslogPacket.concat("MESSAGE / "); + syslogPacket.concat(packet.substring(0,packet.indexOf(">"))); + syslogPacket.concat(" ---> "); + syslogPacket.concat(packet.substring(packet.indexOf("::") + 2)); } else { - syslogPacket += type + " / " + packet; + syslogPacket.concat(packet); } - break; + break; default: syslogPacket = "<165>1 - ERROR LoRa - - - ERROR / Error in Syslog Packet"; //RFC5424 The Syslog Protocol break; diff --git a/src/utils.cpp b/src/utils.cpp index fbb6ffd..2c215f2 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -51,7 +51,7 @@ namespace Utils { delay(1000); status += ",qAC:>https://github.com/richonguzman/LoRa_APRS_iGate " + versionDate; APRS_IS_Utils::upload(status); - SYSLOG_Utils::log(2, status,0,0,0); // APRSIS TX + SYSLOG_Utils::log(2, status, 0, 0.0, 0); // APRSIS TX statusAfterBoot = false; } if (statusAfterBoot && !Config.beacon.sendViaAPRSIS && Config.beacon.sendViaRF) {