aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-11-01 08:54:27 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-11-01 08:54:27 +1300
commitc35dcf705127726f266d4b31572d2494e00d627b (patch)
treecd8765039d419aee6fa699c092e545e0ff299adb
parentb4fb0f86ac1825f10922c8df1a0efb5b5f5e6514 (diff)
downloadtrackermap-server-c35dcf705127726f266d4b31572d2494e00d627b.tar.gz
trackermap-server-c35dcf705127726f266d4b31572d2494e00d627b.tar.bz2
trackermap-server-c35dcf705127726f266d4b31572d2494e00d627b.zip
Decode heartbeat Castel position
-rw-r--r--src/org/traccar/protocol/CastelProtocolDecoder.java30
-rw-r--r--test/org/traccar/protocol/CastelProtocolDecoderTest.java2
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,