From 3884c75ab3849cdb7b2a86ff7fa64c1c22df4ad2 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Thu, 11 Feb 2016 19:05:52 +1100 Subject: Add support for new Castel format --- .../traccar/protocol/CastelProtocolDecoder.java | 23 +++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/protocol/CastelProtocolDecoder.java b/src/org/traccar/protocol/CastelProtocolDecoder.java index e36d086f8..4b8f3b716 100644 --- a/src/org/traccar/protocol/CastelProtocolDecoder.java +++ b/src/org/traccar/protocol/CastelProtocolDecoder.java @@ -115,9 +115,14 @@ public class CastelProtocolDecoder extends BaseProtocolDecoder { ChannelBuffer buf = (ChannelBuffer) msg; - buf.skipBytes(2); // header + int header = buf.readUnsignedShort(); buf.readUnsignedShort(); // length - int version = buf.readUnsignedByte(); + + int version = -1; + if (header == 0x4040) { + version = buf.readUnsignedByte(); + } + ChannelBuffer id = buf.readBytes(20); int type = ChannelBuffers.swapShort(buf.readShort()); @@ -125,7 +130,19 @@ public class CastelProtocolDecoder extends BaseProtocolDecoder { return null; } - if (version == 4) { + if (version == -1) { + + if (type == 0x2001) { + + buf.readUnsignedInt(); // index + buf.readUnsignedInt(); // unix time + buf.readUnsignedByte(); + + return readPosition(buf); + + } + + } else if (version == 4) { if (type == MSG_SC_HEARTBEAT) { -- cgit v1.2.3