diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-11-15 22:06:41 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2016-11-15 22:06:41 +1300 |
commit | fcc70df74b1fb17280b837b2a31722c2f3fc8ad2 (patch) | |
tree | f144c463af82e2426e1f7f89fd522fcff2babc23 | |
parent | 3507d5f7aa0670c0970b7e65c91a31fdada41ea2 (diff) | |
download | traccar-server-fcc70df74b1fb17280b837b2a31722c2f3fc8ad2.tar.gz traccar-server-fcc70df74b1fb17280b837b2a31722c2f3fc8ad2.tar.bz2 traccar-server-fcc70df74b1fb17280b837b2a31722c2f3fc8ad2.zip |
Fix Astra decoding problem
-rw-r--r-- | src/org/traccar/protocol/AstraProtocolDecoder.java | 12 | ||||
-rw-r--r-- | test/org/traccar/protocol/AstraProtocolDecoderTest.java | 3 |
2 files changed, 12 insertions, 3 deletions
diff --git a/src/org/traccar/protocol/AstraProtocolDecoder.java b/src/org/traccar/protocol/AstraProtocolDecoder.java index d51be633d..390434d54 100644 --- a/src/org/traccar/protocol/AstraProtocolDecoder.java +++ b/src/org/traccar/protocol/AstraProtocolDecoder.java @@ -22,6 +22,7 @@ import org.traccar.BaseProtocolDecoder; import org.traccar.DeviceSession; import org.traccar.helper.BitUtil; import org.traccar.helper.DateBuilder; +import org.traccar.helper.Log; import org.traccar.helper.UnitsConverter; import org.traccar.model.Position; @@ -82,7 +83,9 @@ public class AstraProtocolDecoder extends BaseProtocolDecoder { int reason = buf.readUnsignedMedium(); position.set(Position.KEY_EVENT, reason); - position.set(Position.KEY_STATUS, buf.readUnsignedShort()); + int status = buf.readUnsignedShort(); + position.set(Position.KEY_STATUS, status); + position.set(Position.PREFIX_IO + 1, buf.readUnsignedByte()); position.set(Position.PREFIX_ADC + 1, buf.readUnsignedByte()); position.set(Position.KEY_BATTERY, buf.readUnsignedByte()); @@ -101,7 +104,7 @@ public class AstraProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedByte(); // geofence events - if (BitUtil.check(reason, 6) || BitUtil.check(reason, 7)) { + if (BitUtil.check(status, 8)) { position.set(Position.KEY_RFID, buf.readBytes(7).toString(StandardCharsets.US_ASCII)); position.set(Position.KEY_ODOMETER, buf.readUnsignedMedium() * 1000); @@ -110,7 +113,10 @@ public class AstraProtocolDecoder extends BaseProtocolDecoder { } - // extra data + if (BitUtil.check(status, 6)) { + Log.warning("Extension data is not supported"); + return position; + } positions.add(position); diff --git a/test/org/traccar/protocol/AstraProtocolDecoderTest.java b/test/org/traccar/protocol/AstraProtocolDecoderTest.java index e8a9b12b5..3531be5a8 100644 --- a/test/org/traccar/protocol/AstraProtocolDecoderTest.java +++ b/test/org/traccar/protocol/AstraProtocolDecoderTest.java @@ -11,6 +11,9 @@ public class AstraProtocolDecoderTest extends ProtocolTest { AstraProtocolDecoder decoder = new AstraProtocolDecoder(new AstraProtocol()); verifyPositions(decoder, binary( + "4b00700529c0c265976b8202cba9ff00676d864554a9c30000000020073401006436000300030008000000000000a0000100001920c43d00009600428302cba9ff00676d864554aa3e000000002007240100643b000300020008000000000000b0000100001920c43d00009600420f0e")); + + verifyPositions(decoder, binary( "4b00320524c1da58769e6d0322617effe874024453065600a800000100080000643e0000000000000000000000069500e7bb")); verifyPositions(decoder, binary( |