mirror of
https://github.com/richonguzman/LoRa_APRS_iGate.git
synced 2026-07-14 13:51:09 +02:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d4fc99466f | |||
| 41f09af7b5 |
+35
-40
@@ -43,24 +43,29 @@ extern bool backupDigiMode;
|
|||||||
|
|
||||||
namespace DIGI_Utils {
|
namespace DIGI_Utils {
|
||||||
|
|
||||||
String buildPacket(const String& path, const String& packet, bool thirdParty, bool crossFreq) {
|
String cleanPathAsterisks(String path) {
|
||||||
String stationCallsign = (Config.tacticalCallsign == "" ? Config.callsign : Config.tacticalCallsign);
|
String terms[] = {",WIDE1*", ",WIDE2*", "*"};
|
||||||
if (!crossFreq) {
|
for (String term : terms) {
|
||||||
String packetToRepeat = packet.substring(0, packet.indexOf(",") + 1);
|
int index = path.indexOf(term);
|
||||||
String tempPath = path;
|
if (index != -1) path.remove(index, term.length()); // less memory than: tempPath.replace("*", "");
|
||||||
int digiMode = Config.digi.mode;
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
if (path.indexOf("WIDE1-1") != -1 && (digiMode == 2 || digiMode == 3)) {
|
String buildPacket(const String& path, const String& packet, bool thirdParty, bool crossFreq) {
|
||||||
|
String stationCallsign = (Config.tacticalCallsign == "" ? Config.callsign : Config.tacticalCallsign);
|
||||||
|
String suffix = thirdParty ? ":}" : ":";
|
||||||
|
int suffixIndex = packet.indexOf(suffix);
|
||||||
|
String packetToRepeat;
|
||||||
|
if (!crossFreq) {
|
||||||
|
int digiMode = Config.digi.mode;
|
||||||
|
String tempPath = path;
|
||||||
|
|
||||||
|
if (tempPath.indexOf("WIDE1-1") != -1 && (digiMode == 2 || digiMode == 3)) { // WIDE1-1 Digipeater
|
||||||
|
if (tempPath.indexOf("*") != -1 ) return ""; // "*" shouldn't be in WIDE1-1 (only) type of packet
|
||||||
tempPath.replace("WIDE1-1", stationCallsign + "*");
|
tempPath.replace("WIDE1-1", stationCallsign + "*");
|
||||||
} else if (path.indexOf("WIDE2-") != -1 && digiMode == 3) {
|
} else if (tempPath.indexOf("WIDE2-") != -1 && digiMode == 3) { // WIDE2-n Digipeater
|
||||||
int wide1AsteriskIndex = path.indexOf(",WIDE1*"); // less memory than: tempPath.replace(",WIDE1*", "");
|
tempPath = cleanPathAsterisks(path);
|
||||||
if (wide1AsteriskIndex != -1) {
|
|
||||||
tempPath.remove(wide1AsteriskIndex, 7);
|
|
||||||
}
|
|
||||||
int asteriskIndex = path.indexOf("*"); // less memory than: tempPath.replace("*", "");
|
|
||||||
if (asteriskIndex != -1) {
|
|
||||||
tempPath.remove(asteriskIndex, 1);
|
|
||||||
}
|
|
||||||
if (path.indexOf("WIDE2-1") != -1) {
|
if (path.indexOf("WIDE2-1") != -1) {
|
||||||
tempPath.replace("WIDE2-1", stationCallsign + "*");
|
tempPath.replace("WIDE2-1", stationCallsign + "*");
|
||||||
} else if (path.indexOf("WIDE2-2") != -1) {
|
} else if (path.indexOf("WIDE2-2") != -1) {
|
||||||
@@ -69,32 +74,22 @@ namespace DIGI_Utils {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
packetToRepeat = packet.substring(0, packet.indexOf(",") + 1);
|
||||||
packetToRepeat += tempPath;
|
packetToRepeat += tempPath;
|
||||||
packetToRepeat += APRS_IS_Utils::checkForStartingBytes(packet.substring(packet.indexOf(thirdParty ? ":}" : ":")));
|
|
||||||
return packetToRepeat;
|
|
||||||
} else { // CrossFreq Digipeater
|
} else { // CrossFreq Digipeater
|
||||||
String suffix = thirdParty ? ":}" : ":";
|
packetToRepeat = cleanPathAsterisks(packet.substring(0, suffixIndex));
|
||||||
int suffixIndex = packet.indexOf(suffix);
|
if (packetToRepeat.indexOf(stationCallsign) != -1) return ""; // stationCallsign shouldn't be in path
|
||||||
String packetToRepeat = packet.substring(0, suffixIndex);
|
|
||||||
|
|
||||||
String terms[] = {",WIDE1*", ",WIDE2*", "*"};
|
|
||||||
for (String term : terms) {
|
|
||||||
int index = packetToRepeat.indexOf(term);
|
|
||||||
if (index != -1) {
|
|
||||||
packetToRepeat.remove(index, term.length());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
packetToRepeat += ",";
|
packetToRepeat += ",";
|
||||||
packetToRepeat += stationCallsign;
|
packetToRepeat += stationCallsign;
|
||||||
packetToRepeat += "*";
|
packetToRepeat += "*";
|
||||||
packetToRepeat += APRS_IS_Utils::checkForStartingBytes(packet.substring(suffixIndex));
|
|
||||||
return packetToRepeat;
|
|
||||||
}
|
}
|
||||||
|
packetToRepeat += APRS_IS_Utils::checkForStartingBytes(packet.substring(suffixIndex));
|
||||||
|
return packetToRepeat;
|
||||||
}
|
}
|
||||||
|
|
||||||
String generateDigipeatedPacket(const String& packet, bool thirdParty){
|
String generateDigipeatedPacket(const String& packet, bool thirdParty){
|
||||||
String temp;
|
String temp;
|
||||||
if (thirdParty) { // only header is used
|
if (thirdParty) { // only header is used
|
||||||
const String& header = packet.substring(0, packet.indexOf(":}"));
|
const String& header = packet.substring(0, packet.indexOf(":}"));
|
||||||
temp = header.substring(header.indexOf(">") + 1);
|
temp = header.substring(header.indexOf(">") + 1);
|
||||||
} else {
|
} else {
|
||||||
@@ -104,7 +99,7 @@ namespace DIGI_Utils {
|
|||||||
int digiMode = Config.digi.mode;
|
int digiMode = Config.digi.mode;
|
||||||
bool crossFreq = abs(Config.loramodule.txFreq - Config.loramodule.rxFreq) >= 125000; // CrossFreq Digi
|
bool crossFreq = abs(Config.loramodule.txFreq - Config.loramodule.rxFreq) >= 125000; // CrossFreq Digi
|
||||||
|
|
||||||
if (commaIndex > 2) { // Packet has "path"
|
if (commaIndex > 2) { // "path" found
|
||||||
const String& path = temp.substring(commaIndex + 1);
|
const String& path = temp.substring(commaIndex + 1);
|
||||||
if (digiMode == 2 || backupDigiMode) {
|
if (digiMode == 2 || backupDigiMode) {
|
||||||
bool hasWide = path.indexOf("WIDE1-1") != -1;
|
bool hasWide = path.indexOf("WIDE1-1") != -1;
|
||||||
@@ -167,13 +162,13 @@ namespace DIGI_Utils {
|
|||||||
queryMessage = APRS_IS_Utils::processReceivedLoRaMessage(Sender, AddresseeAndMessage, thirdPartyPacket);
|
queryMessage = APRS_IS_Utils::processReceivedLoRaMessage(Sender, AddresseeAndMessage, thirdPartyPacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!queryMessage) {
|
if (queryMessage) return; // answer should not be repeated.
|
||||||
String loraPacket = generateDigipeatedPacket(packet.substring(3), thirdPartyPacket);
|
|
||||||
if (loraPacket != "") {
|
String loraPacket = generateDigipeatedPacket(packet.substring(3), thirdPartyPacket);
|
||||||
STATION_Utils::addToOutputPacketBuffer(loraPacket);
|
if (loraPacket != "") {
|
||||||
if (Config.digi.ecoMode != 1) displayToggle(true);
|
STATION_Utils::addToOutputPacketBuffer(loraPacket);
|
||||||
lastScreenOn = millis();
|
if (Config.digi.ecoMode != 1) displayToggle(true);
|
||||||
}
|
lastScreenOn = millis();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user