From aba44d6cb91ac0b54de743dbd469ee8ca118796f Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 11 Apr 2017 00:39:17 +1200 Subject: Fix ST940 Alert decoding --- src/org/traccar/protocol/SuntechProtocolDecoder.java | 4 +++- test/org/traccar/protocol/SuntechProtocolDecoderTest.java | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/org/traccar/protocol/SuntechProtocolDecoder.java b/src/org/traccar/protocol/SuntechProtocolDecoder.java index e19335cb0..42e81f60c 100644 --- a/src/org/traccar/protocol/SuntechProtocolDecoder.java +++ b/src/org/traccar/protocol/SuntechProtocolDecoder.java @@ -67,7 +67,9 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder { } position.setDeviceId(deviceSession.getDeviceId()); - position.set(Position.KEY_VERSION_FW, values[index++]); + if (!type.equals("Alert") || protocolType == 0) { + position.set(Position.KEY_VERSION_FW, values[index++]); + } DateFormat dateFormat = new SimpleDateFormat("yyyyMMddHH:mm:ss"); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); diff --git a/test/org/traccar/protocol/SuntechProtocolDecoderTest.java b/test/org/traccar/protocol/SuntechProtocolDecoderTest.java index 12d098a68..828eaaa21 100644 --- a/test/org/traccar/protocol/SuntechProtocolDecoderTest.java +++ b/test/org/traccar/protocol/SuntechProtocolDecoderTest.java @@ -77,6 +77,12 @@ public class SuntechProtocolDecoderTest extends ProtocolTest { decoder.setProtocolType(1); + verifyPosition(decoder, text( + "ST910;Alert;485195;20170409;22:37:41;3be0133057;+24.882410;-107.509152;000.070;000.00;1;286734;72;02;295;05;-415;4912;255;10;10")); + + verifyPosition(decoder, text( + "ST910;Location;485195;528;20170410;01:18:57;f1dd134840;+24.787139;-107.434679;000.020;000.00;1;286734;100;1;0;0188;02;295;05;-339;4936;255;4;74")); + verifyPosition(decoder, text( "ST910;Location;560266;500;20161207;21:33:11;af910be101;-25.504234;-049.278003;000.080;000.00;1;10054889;70;1;1;1311;02;724;06;-317;3041;2;10;92")); -- cgit v1.2.3