diff options
-rw-r--r-- | src/org/traccar/protocol/CastelProtocolDecoder.java | 30 | ||||
-rw-r--r-- | test/org/traccar/protocol/CastelProtocolDecoderTest.java | 2 |
2 files changed, 16 insertions, 16 deletions
diff --git a/src/org/traccar/protocol/CastelProtocolDecoder.java b/src/org/traccar/protocol/CastelProtocolDecoder.java index 09d314dae..bf82bede1 100644 --- a/src/org/traccar/protocol/CastelProtocolDecoder.java +++ b/src/org/traccar/protocol/CastelProtocolDecoder.java @@ -183,26 +183,26 @@ public class CastelProtocolDecoder extends BaseProtocolDecoder { sendResponse(channel, remoteAddress, version, id, MSG_CC_HEARTBEAT_RESPONSE, null); - if (buf.readUnsignedByte() == 0x01) { - int count = buf.readUnsignedByte(); - List<Position> positions = new LinkedList<>(); + buf.readUnsignedByte(); // 0x01 for history + int count = buf.readUnsignedByte(); + + List<Position> positions = new LinkedList<>(); - for (int i = 0; i < count; i++) { - Position position = readPosition(buf); + for (int i = 0; i < count; i++) { + Position position = readPosition(buf); - position.set(Event.KEY_STATUS, buf.readUnsignedInt()); - position.set(Event.KEY_BATTERY, buf.readUnsignedByte()); - position.set(Event.KEY_ODOMETER, buf.readUnsignedInt()); + position.set(Event.KEY_STATUS, buf.readUnsignedInt()); + position.set(Event.KEY_BATTERY, buf.readUnsignedByte()); + position.set(Event.KEY_ODOMETER, buf.readUnsignedInt()); - buf.readUnsignedByte(); // geo-fencing id - buf.readUnsignedByte(); // geo-fencing flags - buf.readUnsignedByte(); // additional flags + buf.readUnsignedByte(); // geo-fencing id + buf.readUnsignedByte(); // geo-fencing flags + buf.readUnsignedByte(); // additional flags - position.set(Event.KEY_LAC, buf.readUnsignedShort()); - position.set(Event.KEY_CELL, buf.readUnsignedShort()); + position.set(Event.KEY_LAC, buf.readUnsignedShort()); + position.set(Event.KEY_CELL, buf.readUnsignedShort()); - positions.add(position); - } + positions.add(position); return positions; } diff --git a/test/org/traccar/protocol/CastelProtocolDecoderTest.java b/test/org/traccar/protocol/CastelProtocolDecoderTest.java index 576c2c772..5613e954b 100644 --- a/test/org/traccar/protocol/CastelProtocolDecoderTest.java +++ b/test/org/traccar/protocol/CastelProtocolDecoderTest.java @@ -13,7 +13,7 @@ public class CastelProtocolDecoderTest extends ProtocolDecoderTest { CastelProtocolDecoder decoder = new CastelProtocolDecoder(new CastelProtocol()); - verifyNothing(decoder, binary(ByteOrder.LITTLE_ENDIAN, + verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN, "404044000c3631313135303030303935360000000000000000420600011e0a0f0b1312864fcd08c07a13030100640acf000004000a000000000000007ba083a66ad80d0a")); verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN, |