diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2014-03-08 13:46:32 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2014-03-08 13:46:32 +1300 |
commit | d330393bcae1a3b6a6ea2210dd1646ffe056222b (patch) | |
tree | 8d4179fdb18280ff367e9199ca897aaef64464f8 | |
parent | f9187c8d4c8b9e147fcfbdf6ffaddbdfccddc88d (diff) | |
download | traccar-server-d330393bcae1a3b6a6ea2210dd1646ffe056222b.tar.gz traccar-server-d330393bcae1a3b6a6ea2210dd1646ffe056222b.tar.bz2 traccar-server-d330393bcae1a3b6a6ea2210dd1646ffe056222b.zip |
Handle Teltonika 12 codec
-rw-r--r-- | src/org/traccar/protocol/TeltonikaProtocolDecoder.java | 7 | ||||
-rw-r--r-- | test/org/traccar/protocol/TeltonikaProtocolDecoderTest.java | 7 |
2 files changed, 12 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java index 3874828ba..876a1e4ff 100644 --- a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java +++ b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java @@ -63,6 +63,7 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder { private static final int CODEC_GH3000 = 0x07; private static final int CODEC_FM4X00 = 0x08; + private static final int CODEC_12 = 0x0C; private List<Position> parseLocation(Channel channel, ChannelBuffer buf) { List<Position> positions = new LinkedList<Position>(); @@ -70,6 +71,12 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder { buf.skipBytes(4); // marker buf.readUnsignedInt(); // data length int codec = buf.readUnsignedByte(); // codec + + if (codec == CODEC_12) { + // TODO: decode serial port data + return null; + } + int count = buf.readUnsignedByte(); for (int i = 0; i < count; i++) { diff --git a/test/org/traccar/protocol/TeltonikaProtocolDecoderTest.java b/test/org/traccar/protocol/TeltonikaProtocolDecoderTest.java index 5c16f054a..080f240a5 100644 --- a/test/org/traccar/protocol/TeltonikaProtocolDecoderTest.java +++ b/test/org/traccar/protocol/TeltonikaProtocolDecoderTest.java @@ -36,8 +36,11 @@ public class TeltonikaProtocolDecoderTest { int[] buf7 = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2b,0x08,0x01,0x00,0x00,0x01,0x40,0xd4,0xe3,0xec,0x6e,0x00,0x0c,0xc6,0x61,0xd0,0x16,0x74,0xa5,0xe0,0xff,0xfc,0x00,0x00,0x09,0x00,0x00,0x00,0x04,0x02,0x01,0x00,0xf0,0x00,0x02,0x42,0x32,0x23,0x18,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x7a,0x04}; verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertArray(buf7)))); - //int[] buf8 = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2d,0x0c,0x01,0x06,0x00,0x00,0x00,0x25,0x23,0x46,0x4d,0x32,0x3d,0x32,0x36,0x32,0x30,0x33,0x32,0x37,0x36,0x31,0x37,0x32,0x31,0x33,0x39,0x36,0x2c,0x32,0x36,0x32,0x30,0x33,0x2c,0x30,0x37,0x2e,0x30,0x32,0x2e,0x30,0x35,0x0d,0x0a,0x01,0x00,0x00,0x9a,0x2e}; - //verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertArray(buf8)))); + int[] buf8 = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2d,0x0c,0x01,0x06,0x00,0x00,0x00,0x25,0x23,0x46,0x4d,0x32,0x3d,0x32,0x36,0x32,0x30,0x33,0x32,0x37,0x36,0x31,0x37,0x32,0x31,0x33,0x39,0x36,0x2c,0x32,0x36,0x32,0x30,0x33,0x2c,0x30,0x37,0x2e,0x30,0x32,0x2e,0x30,0x35,0x0d,0x0a,0x01,0x00,0x00,0x9a,0x2e}; + assertNull(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertArray(buf8)))); + + int[] buf9 = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0a,0x0c,0x02,0x06,0x00,0x00,0x00,0x02,0x0d,0x0a,0x02,0x00,0x00,0x6f,0x4e}; + assertNull(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertArray(buf9)))); } |