update 3rd party
This commit is contained in:
parent
f6c47cd938
commit
5e4d27ee39
|
|
@ -254,49 +254,34 @@ namespace APRSPacketLib {
|
|||
return generateBasePacket(callsign,tocall,path) + "::" + processedAddressee + ":" + processedMessage;
|
||||
}
|
||||
|
||||
String generateDigiRepeatedPacket(APRSPacket packet, const String& callsign) {
|
||||
if (packet.path.indexOf("WIDE1-") >= 0) {
|
||||
String buildDigiPacket(const String& packet, const String& callsign, const String& path, const String& fullPath, bool thirdParty) {
|
||||
String packetToRepeat = packet.substring(0, packet.indexOf(",") + 1);
|
||||
String tempPath = fullPath;
|
||||
tempPath.replace(path, callsign + "*");
|
||||
packetToRepeat += tempPath;
|
||||
if (thirdParty) {
|
||||
packetToRepeat += packet.substring(packet.indexOf(":}"));
|
||||
} else {
|
||||
packetToRepeat += packet.substring(packet.indexOf(":"));
|
||||
}
|
||||
return packetToRepeat;
|
||||
}
|
||||
|
||||
String hop = packet.path.substring(packet.path.indexOf("WIDE1-") + 6, packet.path.indexOf("WIDE1-") + 7);
|
||||
if (hop.toInt() >= 1 && hop.toInt() <= 7) {
|
||||
if (hop.toInt() == 1) {
|
||||
packet.path.replace("WIDE1-1", callsign + "*");
|
||||
} else {
|
||||
packet.path.replace("WIDE1-" + hop , callsign + "*,WIDE1-" + String(hop.toInt() - 1));
|
||||
}
|
||||
String generateDigiRepeatedPacket(const String& packet, const String &callsign, const String& path) {
|
||||
bool thirdParty = false;
|
||||
if (packet.indexOf(":}") != -1) thirdParty = true;
|
||||
|
||||
String repeatedPacket = packet.sender;
|
||||
repeatedPacket += ">";
|
||||
repeatedPacket += packet.tocall;
|
||||
repeatedPacket += ",";
|
||||
repeatedPacket += packet.path;
|
||||
|
||||
switch (packet.type) {
|
||||
case 0: // gps
|
||||
repeatedPacket += ":!";
|
||||
break;
|
||||
case 1: // message
|
||||
for(int i = packet.addressee.length(); i < 9; i++) {
|
||||
packet.addressee += ' ';
|
||||
}
|
||||
repeatedPacket += "::";
|
||||
repeatedPacket += packet.addressee;
|
||||
repeatedPacket += ":";
|
||||
break;
|
||||
case 2: // status
|
||||
repeatedPacket += ":>";
|
||||
break;
|
||||
case 3: // telemetry
|
||||
repeatedPacket += ":T#";
|
||||
break;
|
||||
case 4: // mic-e
|
||||
repeatedPacket += ":`";
|
||||
break;
|
||||
case 5: // object
|
||||
repeatedPacket += ":;";
|
||||
break;
|
||||
}
|
||||
return repeatedPacket + packet.message;
|
||||
String temp;
|
||||
if (thirdParty) { // only header is used
|
||||
const String& header = packet.substring(3, packet.indexOf(":}"));
|
||||
temp = header.substring(header.indexOf(">") + 1);
|
||||
} else {
|
||||
temp = packet.substring(packet.indexOf(">") + 1, packet.indexOf(":"));
|
||||
}
|
||||
if (temp.indexOf(",") > 2) { // checks for path
|
||||
const String& completePath = temp.substring(temp.indexOf(",") + 1); // after tocall
|
||||
if (completePath.indexOf(path) != -1) {
|
||||
return buildDigiPacket(packet.substring(3), callsign , path, completePath, thirdParty);
|
||||
} else {
|
||||
return "X";
|
||||
}
|
||||
|
|
@ -611,8 +596,10 @@ namespace APRSPacketLib {
|
|||
|
||||
String temp0;
|
||||
if (receivedPacket.indexOf(":}") != -1) { // 3rd Party
|
||||
aprsPacket.header = receivedPacket.substring(receivedPacket.indexOf(":}"));
|
||||
temp0 = receivedPacket.substring(receivedPacket.indexOf(":}") + 2);
|
||||
} else {
|
||||
aprsPacket.header = "";
|
||||
temp0 = receivedPacket;
|
||||
}
|
||||
aprsPacket.sender = temp0.substring(0, temp0.indexOf(">"));
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include <Arduino.h>
|
||||
|
||||
struct APRSPacket {
|
||||
String header;
|
||||
String sender;
|
||||
String tocall;
|
||||
String path;
|
||||
|
|
@ -55,7 +56,9 @@ namespace APRSPacketLib {
|
|||
String generateBasePacket(const String& callsign, const String& tocall, const String& path);
|
||||
String generateStatusPacket(const String& callsign, const String& tocall, const String& path, const String& status);
|
||||
String generateMessagePacket(const String& callsign, const String& tocall, const String& path, const String& addressee, const String& message);
|
||||
String generateDigiRepeatedPacket(APRSPacket packet, const String &callsign);
|
||||
|
||||
String buildDigiPacket(const String& packet, const String& callsign, const String& path, bool thirdParty);
|
||||
String generateDigiRepeatedPacket(const String& packet, const String &callsign, const String& path);
|
||||
|
||||
char *ax25_base91enc(char *s, uint8_t n, uint32_t v);
|
||||
String encodeGPS(float latitude, float longitude, float course, float speed, const String& symbol, bool sendAltitude, int altitude, bool sendStandingUpdate, const String& packetType);
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ TinyGPSPlus gps;
|
|||
OneButton userButton = OneButton(BUTTON_PIN, true, true);
|
||||
#endif
|
||||
|
||||
String versionDate = "2024.06.08";
|
||||
String versionDate = "2024.06.21";
|
||||
|
||||
uint8_t myBeaconsIndex = 0;
|
||||
int myBeaconsSize = Config.beacons.size();
|
||||
|
|
|
|||
|
|
@ -50,8 +50,8 @@ namespace AX25_Utils {
|
|||
String AX25FrameToLoRaPacket(const String& frame) {
|
||||
//Serial.println(frame);
|
||||
if (decodeAX25(frame, frame.length(), &decodedFrame)) {
|
||||
String packetToLoRa = "";
|
||||
packetToLoRa = decodeFrame(decodedFrame.sender) + ">" + decodeFrame(decodedFrame.tocall);
|
||||
//String packetToLoRa = "";
|
||||
String packetToLoRa = decodeFrame(decodedFrame.sender) + ">" + decodeFrame(decodedFrame.tocall);
|
||||
|
||||
if (decodedFrame.path1[0] != 0) {
|
||||
packetToLoRa += ",";
|
||||
|
|
@ -91,9 +91,7 @@ namespace AX25_Utils {
|
|||
}
|
||||
|
||||
String encodeAX25Address(const String& frame, uint8_t type, const bool lastAddress) {
|
||||
String packet = "";
|
||||
String address;
|
||||
std::string concatenatedBinary;
|
||||
int ssid;
|
||||
if (frame.indexOf("-") > 0) {
|
||||
address = frameCleaning(frame.substring(0, frame.indexOf("-")));
|
||||
|
|
@ -105,6 +103,7 @@ namespace AX25_Utils {
|
|||
address = frameCleaning(frame);
|
||||
ssid = 0;
|
||||
}
|
||||
String packet = "";
|
||||
for (int j = 0; j < 6; j++) {
|
||||
char c = address[j];
|
||||
packet += char(c<<1);
|
||||
|
|
@ -112,23 +111,24 @@ namespace AX25_Utils {
|
|||
std::string firstSSIDBit = std::to_string(type); //type=0 (sender or path not repeated) type=1 (tocall or path being repeated)
|
||||
std::string lastSSIDBit = "0";
|
||||
if (lastAddress) {
|
||||
lastSSIDBit = "1"; // address is the last from AX.25 Frame
|
||||
lastSSIDBit = "1"; // address is the last from AX.25 Frame
|
||||
}
|
||||
concatenatedBinary = firstSSIDBit + "11" + intToBinaryString(ssid,4) + lastSSIDBit; // ( CRRSSSSX / HRRSSSSX )
|
||||
std::string concatenatedBinary = firstSSIDBit + "11" + intToBinaryString(ssid,4) + lastSSIDBit; // ( CRRSSSSX / HRRSSSSX )
|
||||
long decimalValue = strtol(concatenatedBinary.c_str(), NULL, 2);
|
||||
packet += (char)decimalValue; //SSID
|
||||
return packet;
|
||||
}
|
||||
|
||||
String LoRaPacketToAX25Frame(const String& packet) {
|
||||
String encodedPacket = "";
|
||||
String tocall = "";
|
||||
String sender = packet.substring(0, packet.indexOf(">"));
|
||||
bool lastAddress = false;
|
||||
String payload = packet.substring(packet.indexOf(":") + 1);
|
||||
String temp = packet.substring(packet.indexOf(">") + 1, packet.indexOf(":"));
|
||||
//String encodedPacket = "";
|
||||
//String tocall = "";
|
||||
String sender = packet.substring(0, packet.indexOf(">"));
|
||||
bool lastAddress = false;
|
||||
//String payload = packet.substring(packet.indexOf(":") + 1);
|
||||
String temp = packet.substring(packet.indexOf(">") + 1, packet.indexOf(":"));
|
||||
|
||||
if (temp.indexOf(",")>0) {
|
||||
String tocall;
|
||||
if (temp.indexOf(",") != -1) {
|
||||
tocall = temp.substring(0, temp.indexOf(","));
|
||||
temp = temp.substring(temp.indexOf(",") + 1);
|
||||
} else {
|
||||
|
|
@ -136,12 +136,11 @@ namespace AX25_Utils {
|
|||
temp = "";
|
||||
lastAddress = true;
|
||||
}
|
||||
encodedPacket = encodeAX25Address(tocall, 1, false);
|
||||
String encodedPacket = encodeAX25Address(tocall, 1, false);
|
||||
encodedPacket += encodeAX25Address(sender, 0, lastAddress);
|
||||
|
||||
while (temp.length() > 0) {
|
||||
int repeatedPath = 0;
|
||||
String address = "";
|
||||
String address;
|
||||
if (temp.indexOf(",") > 0) {
|
||||
address = temp.substring(0, temp.indexOf(","));
|
||||
temp = temp.substring(temp.indexOf(",") + 1);
|
||||
|
|
@ -150,6 +149,7 @@ namespace AX25_Utils {
|
|||
temp = "";
|
||||
lastAddress = true;
|
||||
}
|
||||
int repeatedPath = 0;
|
||||
if (address.indexOf("*") > 0) {
|
||||
repeatedPath = 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -147,8 +147,7 @@ namespace BME_Utils {
|
|||
}
|
||||
|
||||
const String generateHumString(const float bmeHum, const uint8_t type) {
|
||||
String strHum;
|
||||
strHum = String((int)bmeHum);
|
||||
String strHum = String((int)bmeHum);
|
||||
switch (strHum.length()) {
|
||||
case 1:
|
||||
if (type == 1) {
|
||||
|
|
@ -209,7 +208,6 @@ namespace BME_Utils {
|
|||
}
|
||||
|
||||
const String readDataSensor(const uint8_t type) {
|
||||
String wx, tempStr, humStr, presStr;
|
||||
uint32_t lastReading = millis() - bmeLastReading;
|
||||
if (lastReading > 60 * 1000) {
|
||||
switch (wxModuleType) {
|
||||
|
|
@ -241,6 +239,7 @@ namespace BME_Utils {
|
|||
bmeLastReading = millis();
|
||||
}
|
||||
|
||||
String wx;
|
||||
if (isnan(newTemp) || isnan(newHum) || isnan(newPress)) {
|
||||
Serial.println("BME/BMP Module data failed");
|
||||
if (type == 1) {
|
||||
|
|
@ -250,13 +249,14 @@ namespace BME_Utils {
|
|||
}
|
||||
return wx;
|
||||
} else {
|
||||
tempStr = generateTempString(newTemp + Config.bme.temperatureCorrection, type);
|
||||
String tempStr = generateTempString(newTemp + Config.bme.temperatureCorrection, type);
|
||||
String humStr;
|
||||
if (wxModuleType == 1 || wxModuleType == 3) {
|
||||
humStr = generateHumString(newHum,type);
|
||||
} else if (wxModuleType == 2) {
|
||||
humStr = "..";
|
||||
}
|
||||
presStr = generatePresString(newPress + (gps.altitude.meters()/CORRECTION_FACTOR), type);
|
||||
String presStr = generatePresString(newPress + (gps.altitude.meters()/CORRECTION_FACTOR), type);
|
||||
if (type == 1) {
|
||||
if (wxModuleType == 1 || wxModuleType == 3) {
|
||||
wx = tempStr;
|
||||
|
|
|
|||
|
|
@ -427,7 +427,6 @@ namespace KEYBOARD_Utils {
|
|||
show_display("_WINLINK_>", "", " WLNK COMMENTs ON!", 2000);
|
||||
}
|
||||
} else if (menuDisplay == 5000) {
|
||||
// reemplazar con buffer
|
||||
MSG_Utils::addToOutputBuffer(1, "WLNK-1", "L");
|
||||
} else if (menuDisplay == 5010) {
|
||||
menuDisplay = 50100;
|
||||
|
|
|
|||
|
|
@ -391,7 +391,7 @@ namespace MSG_Utils {
|
|||
} else {
|
||||
packet25SegBuffer.push_back(String(millis()) + "," + station + "," + textMessage);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void checkReceivedMessage(ReceivedLoRaPacket packet) {
|
||||
|
|
@ -417,7 +417,7 @@ namespace MSG_Utils {
|
|||
}
|
||||
|
||||
if (digirepeaterActive && lastReceivedPacket.addressee != currentBeacon->callsign) {
|
||||
String digiRepeatedPacket = APRSPacketLib::generateDigiRepeatedPacket(lastReceivedPacket, currentBeacon->callsign);
|
||||
String digiRepeatedPacket = APRSPacketLib::generateDigiRepeatedPacket(packet.text, currentBeacon->callsign, Config.path);
|
||||
if (digiRepeatedPacket == "X") {
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_WARN, "Main", "%s", "Packet won't be Repeated (Missing WIDE1-X)");
|
||||
} else {
|
||||
|
|
@ -454,20 +454,20 @@ namespace MSG_Utils {
|
|||
|
||||
if (lastReceivedPacket.sender == "CA2RXU-15" && lastReceivedPacket.message.indexOf("WX") == 0) { // WX = WeatherReport
|
||||
Serial.println("Weather Report Received");
|
||||
String wxCleaning = lastReceivedPacket.message.substring(lastReceivedPacket.message.indexOf("WX ") + 3);
|
||||
String place = wxCleaning.substring(0,wxCleaning.indexOf(","));
|
||||
String placeCleaning = wxCleaning.substring(wxCleaning.indexOf(",")+1);
|
||||
String summary = placeCleaning.substring(0,placeCleaning.indexOf(","));
|
||||
String sumCleaning = placeCleaning.substring(placeCleaning.indexOf(",")+2);
|
||||
String temperature = sumCleaning.substring(0,sumCleaning.indexOf("P"));
|
||||
String tempCleaning = sumCleaning.substring(sumCleaning.indexOf("P")+1);
|
||||
String pressure = tempCleaning.substring(0,tempCleaning.indexOf("H"));
|
||||
String presCleaning = tempCleaning.substring(tempCleaning.indexOf("H")+1);
|
||||
String humidity = presCleaning.substring(0,presCleaning.indexOf("W"));
|
||||
String humCleaning = presCleaning.substring(presCleaning.indexOf("W")+1);
|
||||
String windSpeed = humCleaning.substring(0,humCleaning.indexOf(","));
|
||||
String windCleaning = humCleaning.substring(humCleaning.indexOf(",")+1);
|
||||
String windDegrees = windCleaning.substring(windCleaning.indexOf(",")+1,windCleaning.indexOf("\n"));
|
||||
const String& wxCleaning = lastReceivedPacket.message.substring(lastReceivedPacket.message.indexOf("WX ") + 3);
|
||||
const String& place = wxCleaning.substring(0,wxCleaning.indexOf(","));
|
||||
const String& placeCleaning = wxCleaning.substring(wxCleaning.indexOf(",")+1);
|
||||
const String& summary = placeCleaning.substring(0,placeCleaning.indexOf(","));
|
||||
const String& sumCleaning = placeCleaning.substring(placeCleaning.indexOf(",")+2);
|
||||
const String& temperature = sumCleaning.substring(0,sumCleaning.indexOf("P"));
|
||||
const String& tempCleaning = sumCleaning.substring(sumCleaning.indexOf("P")+1);
|
||||
const String& pressure = tempCleaning.substring(0,tempCleaning.indexOf("H"));
|
||||
const String& presCleaning = tempCleaning.substring(tempCleaning.indexOf("H")+1);
|
||||
const String& humidity = presCleaning.substring(0,presCleaning.indexOf("W"));
|
||||
const String& humCleaning = presCleaning.substring(presCleaning.indexOf("W")+1);
|
||||
const String& windSpeed = humCleaning.substring(0,humCleaning.indexOf(","));
|
||||
const String& windCleaning = humCleaning.substring(humCleaning.indexOf(",")+1);
|
||||
const String& windDegrees = windCleaning.substring(windCleaning.indexOf(",")+1,windCleaning.indexOf("\n"));
|
||||
|
||||
String fifthLineWR = temperature;
|
||||
fifthLineWR += "C ";
|
||||
|
|
|
|||
|
|
@ -78,28 +78,28 @@ namespace STATION_Utils {
|
|||
if (firstNearTracker != "") {
|
||||
firstNearTrackermillis = firstNearTracker.substring(firstNearTracker.indexOf(",") + 1);
|
||||
firstTrackermillis = firstNearTrackermillis.toInt();
|
||||
if ((millis() - firstTrackermillis) > Config.rememberStationTime*60*1000) {
|
||||
if ((millis() - firstTrackermillis) > Config.rememberStationTime * 60 * 1000) {
|
||||
firstNearTracker = "";
|
||||
}
|
||||
}
|
||||
if (secondNearTracker != "") {
|
||||
secondNearTrackermillis = secondNearTracker.substring(secondNearTracker.indexOf(",") + 1);
|
||||
secondTrackermillis = secondNearTrackermillis.toInt();
|
||||
if ((millis() - secondTrackermillis) > Config.rememberStationTime*60*1000) {
|
||||
if ((millis() - secondTrackermillis) > Config.rememberStationTime * 60 * 1000) {
|
||||
secondNearTracker = "";
|
||||
}
|
||||
}
|
||||
if (thirdNearTracker != "") {
|
||||
thirdNearTrackermillis = thirdNearTracker.substring(thirdNearTracker.indexOf(",") + 1);
|
||||
thirdTrackermillis = thirdNearTrackermillis.toInt();
|
||||
if ((millis() - thirdTrackermillis) > Config.rememberStationTime*60*1000) {
|
||||
if ((millis() - thirdTrackermillis) > Config.rememberStationTime * 60 * 1000) {
|
||||
thirdNearTracker = "";
|
||||
}
|
||||
}
|
||||
if (fourthNearTracker != "") {
|
||||
fourthNearTrackermillis = fourthNearTracker.substring(fourthNearTracker.indexOf(",") + 1);
|
||||
fourthTrackermillis = fourthNearTrackermillis.toInt();
|
||||
if ((millis() - fourthTrackermillis) > Config.rememberStationTime*60*1000) {
|
||||
if ((millis() - fourthTrackermillis) > Config.rememberStationTime * 60 * 1000) {
|
||||
fourthNearTracker = "";
|
||||
}
|
||||
}
|
||||
|
|
@ -129,8 +129,7 @@ namespace STATION_Utils {
|
|||
}
|
||||
|
||||
void orderListenedTrackersByDistance(const String& callsign, float distance, float course) {
|
||||
String firstNearTrackerDistance, secondNearTrackerDistance, thirdNearTrackerDistance, fourthNearTrackerDistance, newTrackerInfo, firstNearTrackerCallsign, secondNearTrackerCallsign,thirdNearTrackerCallsign, fourthNearTrackerCallsign;
|
||||
newTrackerInfo = callsign + "> " + String(distance,2) + "km " + String(int(course)) + "," + String(millis());
|
||||
String firstNearTrackerDistance, secondNearTrackerDistance, thirdNearTrackerDistance, fourthNearTrackerDistance, firstNearTrackerCallsign, secondNearTrackerCallsign,thirdNearTrackerCallsign, fourthNearTrackerCallsign;
|
||||
float firstDistance = 0.0;
|
||||
float secondDistance = 0.0;
|
||||
float thirdDistance = 0.0;
|
||||
|
|
@ -156,6 +155,14 @@ namespace STATION_Utils {
|
|||
fourthDistance = fourthNearTrackerDistance.toFloat();
|
||||
}
|
||||
|
||||
String newTrackerInfo = callsign;
|
||||
newTrackerInfo += "> ";
|
||||
newTrackerInfo += String(distance,2);
|
||||
newTrackerInfo += "km ";
|
||||
newTrackerInfo += String(int(course));
|
||||
newTrackerInfo += ",";
|
||||
newTrackerInfo += String(millis());
|
||||
|
||||
if (firstNearTracker == "" && secondNearTracker == "" && thirdNearTracker == "" && fourthNearTracker == "") {
|
||||
firstNearTracker = newTrackerInfo;
|
||||
} else if (firstNearTracker != "" && secondNearTracker == "" && thirdNearTracker == "" && fourthNearTracker == "") {
|
||||
|
|
@ -393,8 +400,7 @@ namespace STATION_Utils {
|
|||
}
|
||||
|
||||
void sendBeacon(uint8_t type) {
|
||||
String packet, comment;
|
||||
int sendCommentAfterXBeacons;
|
||||
String packet;
|
||||
if (Config.bme.sendTelemetry && type == 1) { // WX
|
||||
packet = APRSPacketLib::generateGPSBeaconPacket(currentBeacon->callsign, "APLRT1", Config.path, "/", APRSPacketLib::encodeGPS(gps.location.lat(),gps.location.lng(), gps.course.deg(), gps.speed.knots(), currentBeacon->symbol, Config.sendAltitude, gps.altitude.feet(), sendStandingUpdate, "Wx"));
|
||||
if (wxModuleType != 0) {
|
||||
|
|
@ -409,6 +415,8 @@ namespace STATION_Utils {
|
|||
packet = APRSPacketLib::generateGPSBeaconPacket(currentBeacon->callsign, "APLRT1", Config.path, currentBeacon->overlay, APRSPacketLib::encodeGPS(gps.location.lat(),gps.location.lng(), gps.course.deg(), gps.speed.knots(), currentBeacon->symbol, Config.sendAltitude, gps.altitude.feet(), sendStandingUpdate, "GPS"));
|
||||
}
|
||||
}
|
||||
String comment;
|
||||
int sendCommentAfterXBeacons;
|
||||
if (winlinkCommentState) {
|
||||
comment = " winlink";
|
||||
sendCommentAfterXBeacons = 1;
|
||||
|
|
|
|||
|
|
@ -66,11 +66,21 @@ namespace Utils {
|
|||
}
|
||||
|
||||
String createDateString(time_t t) {
|
||||
return String(padding(year(t), 4) + "-" + padding(month(t), 2) + "-" + padding(day(t), 2));
|
||||
String dateString = padding(year(t), 4);
|
||||
dateString += "-";
|
||||
dateString += padding(month(t), 2);
|
||||
dateString += "-";
|
||||
dateString += padding(day(t), 2);
|
||||
return dateString;
|
||||
}
|
||||
|
||||
String createTimeString(time_t t) {
|
||||
return String(padding(hour(t), 2) + ":" + padding(minute(t), 2) + ":" + padding(second(t), 2));
|
||||
String timeString = padding(hour(t), 2);
|
||||
timeString += ":";
|
||||
timeString += padding(minute(t), 2);
|
||||
timeString += ":";
|
||||
timeString += padding(second(t), 2);
|
||||
return timeString;
|
||||
}
|
||||
|
||||
void checkStatus() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue