diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2019-03-09 09:32:29 -0800 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2019-03-09 09:32:29 -0800 |
commit | 8018a9269789d532431ed455b82c3a67acdd0e50 (patch) | |
tree | 2ba7965428371117810e3c1abf521ccfd4c6daba | |
parent | 39f5dcfec7a3bfb9358c9f3a11038cfce21815b4 (diff) | |
download | trackermap-server-8018a9269789d532431ed455b82c3a67acdd0e50.tar.gz trackermap-server-8018a9269789d532431ed455b82c3a67acdd0e50.tar.bz2 trackermap-server-8018a9269789d532431ed455b82c3a67acdd0e50.zip |
Update box protocol
-rw-r--r-- | src/org/traccar/protocol/BoxProtocolDecoder.java | 15 | ||||
-rw-r--r-- | test/org/traccar/protocol/BoxProtocolDecoderTest.java | 5 |
2 files changed, 12 insertions, 8 deletions
diff --git a/src/org/traccar/protocol/BoxProtocolDecoder.java b/src/org/traccar/protocol/BoxProtocolDecoder.java index 9f3ce29b2..d7b401a2d 100644 --- a/src/org/traccar/protocol/BoxProtocolDecoder.java +++ b/src/org/traccar/protocol/BoxProtocolDecoder.java @@ -20,6 +20,7 @@ import org.traccar.BaseProtocolDecoder; import org.traccar.DeviceSession; import org.traccar.NetworkMessage; import org.traccar.Protocol; +import org.traccar.helper.BitUtil; import org.traccar.helper.Parser; import org.traccar.helper.PatternBuilder; import org.traccar.helper.UnitsConverter; @@ -84,16 +85,16 @@ public class BoxProtocolDecoder extends BaseProtocolDecoder { position.setTime(parser.nextDateTime()); - position.setLatitude(parser.nextDouble(0)); - position.setLongitude(parser.nextDouble(0)); - position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble(0))); - position.setCourse(parser.nextDouble(0)); + position.setLatitude(parser.nextDouble()); + position.setLongitude(parser.nextDouble()); + position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble())); + position.setCourse(parser.nextDouble()); - position.set(Position.KEY_ODOMETER_TRIP, parser.nextDouble(0) * 1000); + position.set(Position.KEY_ODOMETER_TRIP, parser.nextDouble() * 1000); position.set(Position.KEY_EVENT, parser.next()); - int status = parser.nextInt(0); - position.setValid((status & 0x04) == 0); + int status = parser.nextInt(); + position.setValid(!BitUtil.check(status, 2)); position.set(Position.KEY_STATUS, status); return position; diff --git a/test/org/traccar/protocol/BoxProtocolDecoderTest.java b/test/org/traccar/protocol/BoxProtocolDecoderTest.java index f117d1ede..d661a10f2 100644 --- a/test/org/traccar/protocol/BoxProtocolDecoderTest.java +++ b/test/org/traccar/protocol/BoxProtocolDecoderTest.java @@ -10,7 +10,7 @@ public class BoxProtocolDecoderTest extends ProtocolTest { public void testDecode() throws Exception { BoxProtocolDecoder decoder = new BoxProtocolDecoder(null); - + verifyNull(decoder, text( "H,BT,358281002435893,081028142432,F5813D19,6D6E6DC2")); @@ -18,6 +18,9 @@ public class BoxProtocolDecoderTest extends ProtocolTest { "H,BT,N878123,080415081234,D63E6DD9,6D6E6DC2,8944100300825505377")); verifyPosition(decoder, text( + "L,190227043304,G,25.68773,48.59788,71,53,261.42,1,23;A,0.03;D,0.06;I,0")); + + verifyPosition(decoder, text( "L,081028142429,G,52.51084,-1.70849,0,170,0,1,0")); verifyPosition(decoder, text( |