kopia lustrzana https://github.com/sh123/codec2_talkie
Aprsis fixes
rodzic
c2c3ef4fab
commit
46722e8873
|
@ -218,7 +218,7 @@ public class AprsDataPositionReport implements AprsData {
|
|||
String strTail = new String(tail);
|
||||
Pattern latLonPattern = Pattern.compile(
|
||||
"^" +
|
||||
"(?:\\d{6}z*)?" + // optional timestamp
|
||||
"(?:.*)?" + // optional timestamp
|
||||
"([\\d ]{4}[.][\\d ]{2})(N|S)" + // latitude "
|
||||
"([\\S])" + // symbol table
|
||||
"([\\d ]{5}[.][\\d ]{2})(E|W)" + // longitude
|
||||
|
|
|
@ -9,7 +9,8 @@ public class AprsDataType {
|
|||
POSITION_WITH_TIMESTAMP_MSG,
|
||||
POSITION_WITHOUT_TIMESTAMP_MSG,
|
||||
POSITION_WITH_TIMESTAMP_NO_MSG,
|
||||
POSITION_WITHOUT_TIMESTAMP_NO_MSG
|
||||
POSITION_WITHOUT_TIMESTAMP_NO_MSG,
|
||||
OBJECT
|
||||
}
|
||||
|
||||
private final DataType _dataType;
|
||||
|
@ -58,6 +59,8 @@ public class AprsDataType {
|
|||
return DataType.POSITION_WITH_TIMESTAMP_MSG;
|
||||
} else if (ident == '/') {
|
||||
return DataType.POSITION_WITH_TIMESTAMP_NO_MSG;
|
||||
} else if (ident == ';') {
|
||||
return DataType.OBJECT;
|
||||
} else {
|
||||
return DataType.UNKNOWN;
|
||||
}
|
||||
|
@ -76,6 +79,8 @@ public class AprsDataType {
|
|||
return '@';
|
||||
} else if (dataType == DataType.POSITION_WITH_TIMESTAMP_NO_MSG) {
|
||||
return '/';
|
||||
} else if (dataType == DataType.OBJECT) {
|
||||
return ';';
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
package com.radio.codec2talkie.protocol.aprs.tools;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import kotlin.text.Regex;
|
||||
import kotlin.text.RegexOption;
|
||||
|
||||
public class AprsIsData {
|
||||
public String src;
|
||||
public String dst;
|
||||
|
@ -8,27 +13,36 @@ public class AprsIsData {
|
|||
|
||||
public static AprsIsData fromString(String textData) {
|
||||
AprsIsData aprsIsData = new AprsIsData();
|
||||
// N0CALL>PATH:DATA
|
||||
String[] callsignData = textData.split(">");
|
||||
if (callsignData.length < 2) return null;
|
||||
aprsIsData.src = callsignData[0];
|
||||
String[] digipathData = callsignData[1].split(":");
|
||||
// PATH:DATA
|
||||
String[] digipathData = joinTail(callsignData, ">", ".*").split(":");
|
||||
if (digipathData.length < 2) return null;
|
||||
// DST,PATH1,PATH2,...
|
||||
String[] path = digipathData[0].split(",");
|
||||
if (path.length == 0) return null;
|
||||
aprsIsData.dst = path[0];
|
||||
aprsIsData.data = digipathData[1];
|
||||
String[] filteredPath = new String[path.length - 1];
|
||||
System.arraycopy(path, 1, filteredPath, 0, path.length - 1);
|
||||
StringBuilder digipath = new StringBuilder();
|
||||
String sep = "";
|
||||
for (String p : filteredPath) {
|
||||
if (p.startsWith("WIDE")) {
|
||||
digipath.append(sep);
|
||||
digipath.append(p);
|
||||
sep = ",";
|
||||
}
|
||||
}
|
||||
aprsIsData.path = digipath.toString();
|
||||
aprsIsData.path = joinTail(path, ",", "^WIDE.+$");
|
||||
aprsIsData.data = joinTail(digipathData, ":", ".*");
|
||||
return aprsIsData;
|
||||
}
|
||||
|
||||
private static String joinTail(String[] data, String separator, String filterRegex) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
if (data.length < 2) return result.toString();
|
||||
String[] tail = new String[data.length - 1];
|
||||
System.arraycopy(data, 1, tail, 0, data.length - 1);
|
||||
String sep = "";
|
||||
Regex regex = new Regex(filterRegex, RegexOption.DOT_MATCHES_ALL);
|
||||
for (String p : tail) {
|
||||
if (regex.matches(filterRegex)) {
|
||||
result.append(sep);
|
||||
result.append(p);
|
||||
sep = separator;
|
||||
}
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ public class LogItemGroupHolder extends RecyclerView.ViewHolder {
|
|||
String symbol = group.getSymbolCode();
|
||||
Bitmap iconBitmap = _symbolTable.bitmapFromSymbol(symbol, false);
|
||||
if (iconBitmap == null) {
|
||||
Log.e(TAG, "Cannot load bitmap for " + symbol);
|
||||
Log.w(TAG, "Cannot load bitmap for " + symbol);
|
||||
} else {
|
||||
_symbolIcon.setImageBitmap(iconBitmap);
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue