aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-09-05 11:38:53 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2015-09-05 11:38:53 +1200
commit2415c0228487df2f2b0583c15859ef8cf8f012e1 (patch)
treea3e27f76b6a469f687119618eb224bfe522e1427
parent380bdd08e8fbe35b3f197b13363e0d6c17996c8a (diff)
downloadtrackermap-server-2415c0228487df2f2b0583c15859ef8cf8f012e1.tar.gz
trackermap-server-2415c0228487df2f2b0583c15859ef8cf8f012e1.tar.bz2
trackermap-server-2415c0228487df2f2b0583c15859ef8cf8f012e1.zip
Support alarm signal for SunTech
-rw-r--r--src/org/traccar/protocol/SuntechProtocolDecoder.java7
-rw-r--r--test/org/traccar/protocol/SuntechProtocolDecoderTest.java6
2 files changed, 12 insertions, 1 deletions
diff --git a/src/org/traccar/protocol/SuntechProtocolDecoder.java b/src/org/traccar/protocol/SuntechProtocolDecoder.java
index 7ba6020f5..3de785f9d 100644
--- a/src/org/traccar/protocol/SuntechProtocolDecoder.java
+++ b/src/org/traccar/protocol/SuntechProtocolDecoder.java
@@ -34,7 +34,7 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder {
private static final Pattern pattern = Pattern.compile(
"S.\\d{3}(?:\\w{3})?;" + // Header
- "(?:[^;]+;)?" +
+ "(?:([^;]+);)?" + // Type
"(\\d{6,});" + // Device ID
"(?:\\d+;)?" +
"(\\d+);" + // Version
@@ -66,6 +66,11 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder {
Position position = new Position();
position.setProtocol(getProtocolName());
int index = 1;
+
+ String type = parser.group(index++);
+ if (type != null && (type.equals("Alert") || type.equals("Emergency"))) {
+ position.set(Event.KEY_ALARM, true);
+ }
// Identifier
if (!identify(parser.group(index++), channel)) {
diff --git a/test/org/traccar/protocol/SuntechProtocolDecoderTest.java b/test/org/traccar/protocol/SuntechProtocolDecoderTest.java
index f58365e45..980119c31 100644
--- a/test/org/traccar/protocol/SuntechProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/SuntechProtocolDecoderTest.java
@@ -12,6 +12,12 @@ public class SuntechProtocolDecoderTest extends ProtocolDecoderTest {
SuntechProtocolDecoder decoder = new SuntechProtocolDecoder(new SuntechProtocol());
assertNull(decoder.decode(null, null, "SA200ALV;317652"));
+
+ verify(decoder.decode(null, null,
+ "ST910;Alert;123456;410;20141018;18:30:12;+37.478774;+126.889690;000.000;000.00;0;4.0;1;6002"));
+
+ verify(decoder.decode(null, null,
+ "ST910;Alert;123456;410;20141018;18:30:12;+37.478774;+126.889690;000.000;000.00;0;4.0;1;6002;02;0;0310000100;450;01;-282;70;255;3;0"));
verify(decoder.decode(null, null,
"SA200STT;317652;042;20120718;15:37:12;16d41;-15.618755;-056.083241;000.024;000.00;8;1;41548;12.17;100000;2;1979"));