aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-08-31 15:47:20 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2018-08-31 15:47:20 +1200
commit569fb5c36eb4b8b36196114bdeb64030b1516e48 (patch)
tree1bbb382507c7e81e473bb8825a90a71780d6427a
parentf312327ec8e13098c0cea7cb0a4f2495c210888e (diff)
downloadtrackermap-server-569fb5c36eb4b8b36196114bdeb64030b1516e48.tar.gz
trackermap-server-569fb5c36eb4b8b36196114bdeb64030b1516e48.tar.bz2
trackermap-server-569fb5c36eb4b8b36196114bdeb64030b1516e48.zip
Implement Suntech ST410 support
-rw-r--r--src/org/traccar/protocol/SuntechProtocolDecoder.java63
-rw-r--r--test/org/traccar/protocol/SuntechProtocolDecoderTest.java3
2 files changed, 65 insertions, 1 deletions
diff --git a/src/org/traccar/protocol/SuntechProtocolDecoder.java b/src/org/traccar/protocol/SuntechProtocolDecoder.java
index b076546a6..5166240d0 100644
--- a/src/org/traccar/protocol/SuntechProtocolDecoder.java
+++ b/src/org/traccar/protocol/SuntechProtocolDecoder.java
@@ -157,6 +157,65 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder {
return null;
}
}
+ private Position decode4(
+ Channel channel, SocketAddress remoteAddress, String[] values) throws ParseException {
+ int index = 0;
+
+ String type = values[index++].substring(5);
+
+ if (!type.equals("STT") && !type.equals("ALT")) {
+ return null;
+ }
+
+ DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, values[index++]);
+ if (deviceSession == null) {
+ return null;
+ }
+
+ Position position = new Position(getProtocolName());
+ position.setDeviceId(deviceSession.getDeviceId());
+ position.set(Position.KEY_TYPE, type);
+
+ position.set(Position.KEY_VERSION_FW, values[index++]);
+ index += 1; // model
+
+ Network network = new Network();
+
+ for (int i = 0; i < 7; i++) {
+ int cid = Integer.parseInt(values[index++]);
+ int mcc = Integer.parseInt(values[index++]);
+ int mnc = Integer.parseInt(values[index++]);
+ int rssi = Integer.parseInt(values[index++]);
+ int lac = Integer.parseInt(values[index++]);
+ index += 1; // timing advance
+ if (cid > 0) {
+ network.addCellTower(CellTower.from(mcc, mnc, lac, cid, rssi));
+ }
+ }
+
+ position.setNetwork(network);
+
+ position.set(Position.KEY_BATTERY, Double.parseDouble(values[index++]));
+ position.set(Position.KEY_ARCHIVE, values[index++].equals("0") ? true : null);
+ position.set(Position.KEY_INDEX, Integer.parseInt(values[index++]));
+
+ index += 1; // mode
+
+ DateFormat dateFormat = new SimpleDateFormat("yyyyMMddHH:mm:ss");
+ dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
+ position.setTime(dateFormat.parse(values[index++] + values[index++]));
+
+ position.setLatitude(Double.parseDouble(values[index++]));
+ position.setLongitude(Double.parseDouble(values[index++]));
+ position.setSpeed(UnitsConverter.knotsFromKph(Double.parseDouble(values[index++])));
+ position.setCourse(Double.parseDouble(values[index++]));
+
+ position.set(Position.KEY_SATELLITES, Integer.parseInt(values[index++]));
+
+ position.setValid(values[index++].equals("1"));
+
+ return position;
+ }
private Position decode2356(
Channel channel, SocketAddress remoteAddress, String protocol, String[] values) throws ParseException {
@@ -373,8 +432,10 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder {
if (values[0].length() < 5) {
return decodeUniversal(channel, remoteAddress, values);
- } else if (values[0].equals("ST910")) {
+ } else if (values[0].startsWith("ST9")) {
return decode9(channel, remoteAddress, values);
+ } else if (values[0].startsWith("ST4")) {
+ return decode4(channel, remoteAddress, values);
} else {
return decode2356(channel, remoteAddress, values[0].substring(0, 5), values);
}
diff --git a/test/org/traccar/protocol/SuntechProtocolDecoderTest.java b/test/org/traccar/protocol/SuntechProtocolDecoderTest.java
index b369ab41b..3b907e080 100644
--- a/test/org/traccar/protocol/SuntechProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/SuntechProtocolDecoderTest.java
@@ -28,6 +28,9 @@ public class SuntechProtocolDecoderTest extends ProtocolTest {
SuntechProtocolDecoder decoder = new SuntechProtocolDecoder(new SuntechProtocol());
verifyPosition(decoder, text(
+ "ST410STT;007272376;408;01;21651;732;123;-65;1824;1;21654;732;123;1824;0;0;22542;732;123;1824;0;0;21656;732;123;1824;0;0;21655;732;123;1824;0;0;22541;732;123;1824;0;0;0;0;0;0;0;0;3.7;1;0156;1;20180816;05:18:52;+04.722322;-074.052776;000.074;000.00;10;1"));
+
+ verifyPosition(decoder, text(
"ST600STT;008084783;20;419;20180308;18:00:36;0032cc3e;736;3;445c;41;-16.530023;-068.084267;018.640;267.99;10;1;11655;13.33;100000;2;0336;000061;4.5;0;0.00"));
verifyPosition(decoder, text(