testing new Syslog Comments info

This commit is contained in:
richonguzman 2024-05-19 23:34:29 -04:00
parent 2496c12763
commit 916cbade8c
4 changed files with 22 additions and 10 deletions

View File

@ -69,6 +69,7 @@ namespace GPS_Utils {
String GPSPacket = packet.substring(packet.indexOf(":!")+3); String GPSPacket = packet.substring(packet.indexOf(":!")+3);
String encodedLatitude = GPSPacket.substring(0,4); String encodedLatitude = GPSPacket.substring(0,4);
String encodedLongtitude = GPSPacket.substring(4,8); String encodedLongtitude = GPSPacket.substring(4,8);
String comment = GPSPacket.substring(13);
int Y1 = int(encodedLatitude[0]); int Y1 = int(encodedLatitude[0]);
int Y2 = int(encodedLatitude[1]); int Y2 = int(encodedLatitude[1]);
@ -82,8 +83,12 @@ namespace GPS_Utils {
int X4 = int(encodedLongtitude[3]); int X4 = int(encodedLongtitude[3]);
float decodedLongitude = -180.0 + ((((X1-33) * pow(91,3)) + ((X2-33) * pow(91,2)) + ((X3-33) * 91) + X4-33) / 190463.0); float decodedLongitude = -180.0 + ((((X1-33) * pow(91,3)) + ((X2-33) * pow(91,2)) + ((X3-33) * 91) + X4-33) / 190463.0);
distance = String(calculateDistanceTo(decodedLatitude, decodedLongitude),1); distance = String(calculateDistanceTo(decodedLatitude, decodedLongitude),1);
if (comment != "") {
return String(decodedLatitude,5) + "N / " + String(decodedLongitude,5) + "E / " + distance + "km / " + comment;
} else {
return String(decodedLatitude,5) + "N / " + String(decodedLongitude,5) + "E / " + distance + "km"; return String(decodedLatitude,5) + "N / " + String(decodedLongitude,5) + "E / " + distance + "km";
} }
}
String getReceivedGPS(const String& packet) { String getReceivedGPS(const String& packet) {
String infoGPS; String infoGPS;
@ -94,6 +99,7 @@ namespace GPS_Utils {
} }
String Latitude = infoGPS.substring(0,8); String Latitude = infoGPS.substring(0,8);
String Longitude = infoGPS.substring(9,18); String Longitude = infoGPS.substring(9,18);
String comment = infoGPS.substring(19);
float convertedLatitude, convertedLongitude; float convertedLatitude, convertedLongitude;
String firstLatPart = Latitude.substring(0,2); String firstLatPart = Latitude.substring(0,2);
@ -114,10 +120,14 @@ namespace GPS_Utils {
convertedLongitude = -convertedLongitude; convertedLongitude = -convertedLongitude;
} }
distance = String(calculateDistanceTo(convertedLatitude, convertedLongitude),1); distance = String(calculateDistanceTo(convertedLatitude, convertedLongitude),1);
if (comment != "") {
return String(convertedLatitude,5) + "N / " + String(convertedLongitude,5) + "E / " + distance + "km / " + comment;
} else {
return String(convertedLatitude,5) + "N / " + String(convertedLongitude,5) + "E / " + distance + "km"; return String(convertedLatitude,5) + "N / " + String(convertedLongitude,5) + "E / " + distance + "km";
} }
}
String getDistance(const String& packet) { String getDistanceAndComment(const String& packet) {
uint8_t encodedBytePosition = 0; uint8_t encodedBytePosition = 0;
if (packet.indexOf(":!") > 10) { if (packet.indexOf(":!") > 10) {
encodedBytePosition = packet.indexOf(":!") + 14; encodedBytePosition = packet.indexOf(":!") + 14;

View File

@ -13,7 +13,7 @@ namespace GPS_Utils {
double calculateDistanceCourse(double latitude, double longitude); double calculateDistanceCourse(double latitude, double longitude);
String decodeEncodedGPS(const String& packet); String decodeEncodedGPS(const String& packet);
String getReceivedGPS(const String& packet); String getReceivedGPS(const String& packet);
String getDistance(const String& packet); String getDistanceAndComment(const String& packet);
} }

View File

@ -30,7 +30,7 @@ namespace SYSLOG_Utils {
} else { } else {
syslogPacket += packet.substring(packet.indexOf(">")+1,packet.indexOf(":")) + " / - / "; syslogPacket += packet.substring(packet.indexOf(">")+1,packet.indexOf(":")) + " / - / ";
} }
syslogPacket += String(rssi) + "dBm / " + String(snr) + "dB / " + String(freqError) + "Hz / " + GPS_Utils::getDistance(packet); syslogPacket += String(rssi) + "dBm / " + String(snr) + "dB / " + String(freqError) + "Hz / " + GPS_Utils::getDistanceAndComment(packet);
} else if (packet.indexOf(":>") > 10) { } else if (packet.indexOf(":>") > 10) {
syslogPacket += type + " / STATUS / " + packet.substring(3,packet.indexOf(">")) + " ---> " + packet.substring(packet.indexOf(":>")+2); syslogPacket += type + " / STATUS / " + packet.substring(3,packet.indexOf(">")) + " ---> " + packet.substring(packet.indexOf(":>")+2);
syslogPacket += " / " + String(rssi) + "dBm / " + String(snr) + "dB / " + String(freqError) + "Hz"; syslogPacket += " / " + String(rssi) + "dBm / " + String(snr) + "dB / " + String(freqError) + "Hz";

View File

@ -218,7 +218,9 @@ namespace Utils {
seventhLine = "RSSI:" + String(rssi) + "dBm SNR: " + String(snr) + "dBm"; seventhLine = "RSSI:" + String(rssi) + "dBm SNR: " + String(snr) + "dBm";
} else if (packet.indexOf(":!") >= 10 || packet.indexOf(":=") >= 10) { } else if (packet.indexOf(":!") >= 10 || packet.indexOf(":=") >= 10) {
sixthLine = sender + "> GPS BEACON"; sixthLine = sender + "> GPS BEACON";
GPS_Utils::getDistance(packet); if (!Config.syslog.active) {
GPS_Utils::getDistanceAndComment(packet); // to be checked!!!
}
seventhLine = "RSSI:" + String(rssi) + "dBm"; seventhLine = "RSSI:" + String(rssi) + "dBm";
if (rssi <= -100) { if (rssi <= -100) {
seventhLine += " "; seventhLine += " ";