Handle third party header with rx gating

master
sh123 2023-07-01 12:25:13 +03:00
rodzic 55997a703e
commit 2db9c0154e
3 zmienionych plików z 25 dodań i 4 usunięć

Wyświetl plik

@ -10,8 +10,8 @@ android {
applicationId "com.radio.codec2talkie"
minSdkVersion 23
targetSdkVersion 30
versionCode 160
versionName "1.60"
versionCode 161
versionName "1.61"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

Wyświetl plik

@ -171,9 +171,14 @@ public class AprsIs implements Protocol, Runnable {
@Override
protected void onReceiveData(String src, String dst, String path, byte[] data) {
if (_isRxGateEnabled && !_isLoopbackTransport) {
// NOTE, https://aprs-is.net/IGateDetails.aspx
AprsIsData aprsIsData = new AprsIsData(src, dst, path, new String(data));
if (aprsIsData.isEligibleForRxGate()) {
synchronized (_toAprsIsQueue) {
// strip "rf header" for third party packets before gating
if (aprsIsData.hasThirdParty()) {
aprsIsData = aprsIsData.thirdParty;
}
String rawData = aprsIsData.toString() + "\n";
_toAprsIsQueue.put(rawData.getBytes());
}

Wyświetl plik

@ -11,6 +11,7 @@ public class AprsIsData {
public String digipath;
public String rawDigipath;
public String data;
public AprsIsData thirdParty;
public AprsIsData() {
}
@ -20,6 +21,14 @@ public class AprsIsData {
this.dst = dst;
this.digipath = path;
this.data = data;
// handle third party packet
if (data.length() > 10 && data.startsWith("}")) {
thirdParty = AprsIsData.fromString(data.substring(1));
}
}
public boolean hasThirdParty() {
return thirdParty != null;
}
@NonNull
@ -39,8 +48,12 @@ public class AprsIsData {
rawDigipath.contains("NOGATE") ||
rawDigipath.contains("RFONLY");
// do not gate TCPIP/NOGATE and queries
return !hasNoGate && !data.startsWith("?");
boolean thirdPartyHasNoGate = thirdParty != null &&
(thirdParty.rawDigipath.contains("TCPIP") ||
thirdParty.rawDigipath.contains("TCPXX"));
// do not gate TCPIP/NOGATE, queries and third party tcp ip packets
return !hasNoGate && !data.startsWith("?") && !thirdPartyHasNoGate;
}
public boolean isEligibleForTxGate() {
@ -65,6 +78,9 @@ public class AprsIsData {
aprsIsData.digipath = joinTail(path, ",", "^WIDE.+$");
aprsIsData.rawDigipath = joinTail(path, ",", ".*");
aprsIsData.data = joinTail(digipathData, ":", ".*");
if (aprsIsData.data.length() > 10 && aprsIsData.data.startsWith("}")) {
aprsIsData.thirdParty = AprsIsData.fromString(aprsIsData.data.substring(1));
}
return aprsIsData;
}