diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2020-12-15 21:07:42 -0800 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2020-12-15 21:07:42 -0800 |
commit | 3ca5ec4a61978ddcd89bd774d301796bd2718d1a (patch) | |
tree | 217b927b876c2bf7d3c23f4ed4e6df6eda4ff86b /src | |
parent | 83a139303ef18afcfe706b4f1123457906c89f82 (diff) | |
download | trackermap-server-3ca5ec4a61978ddcd89bd774d301796bd2718d1a.tar.gz trackermap-server-3ca5ec4a61978ddcd89bd774d301796bd2718d1a.tar.bz2 trackermap-server-3ca5ec4a61978ddcd89bd774d301796bd2718d1a.zip |
Fix status decoding
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/traccar/protocol/SwiftechProtocolDecoder.java | 8 | ||||
-rw-r--r-- | src/test/java/org/traccar/protocol/SwiftechProtocolDecoderTest.java | 3 |
2 files changed, 5 insertions, 6 deletions
diff --git a/src/main/java/org/traccar/protocol/SwiftechProtocolDecoder.java b/src/main/java/org/traccar/protocol/SwiftechProtocolDecoder.java index b668202dd..8d0b31c8f 100644 --- a/src/main/java/org/traccar/protocol/SwiftechProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/SwiftechProtocolDecoder.java @@ -19,7 +19,6 @@ import io.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.DeviceSession; import org.traccar.Protocol; -import org.traccar.helper.BitUtil; import org.traccar.helper.DateBuilder; import org.traccar.helper.Parser; import org.traccar.helper.PatternBuilder; @@ -47,7 +46,7 @@ public class SwiftechProtocolDecoder extends BaseProtocolDecoder { .number("(d+.d+),") // speed .number("(dd)(dd)(dd),") // date (ddmmyy) .expression("([AV]),") // validity - .number("([01]{4}),") // status + .number("(d{4}),") // status .number("([01]),") // charge .number("d+,") // reserved .number("(d+),") // adc1 @@ -84,10 +83,7 @@ public class SwiftechProtocolDecoder extends BaseProtocolDecoder { position.setValid(parser.next().equals("A")); - int status = parser.nextBinInt(); - position.set(Position.KEY_IGNITION, BitUtil.check(status, 3)); - position.set(Position.PREFIX_OUT + 1, BitUtil.check(status, 1)); - position.set(Position.PREFIX_OUT + 2, BitUtil.check(status, 0)); + position.set(Position.KEY_STATUS, parser.nextInt()); position.set(Position.KEY_CHARGE, parser.nextInt() > 0); diff --git a/src/test/java/org/traccar/protocol/SwiftechProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/SwiftechProtocolDecoderTest.java index e8ee64518..88006606e 100644 --- a/src/test/java/org/traccar/protocol/SwiftechProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/SwiftechProtocolDecoderTest.java @@ -11,6 +11,9 @@ public class SwiftechProtocolDecoderTest extends ProtocolTest { SwiftechProtocolDecoder decoder = new SwiftechProtocolDecoder(null); verifyPosition(decoder, text( + "@@861551041946971,,0,102040,1023.9670,N,07606.8160,E,2.26,151220,A,0127,1,1,03962,00000,#")); + + verifyPosition(decoder, text( "@@864502036102531,,,070739,1100.7798,N,07657.7126,E,0.43,210813,A,1100,1,0,02700,05800,")); } |