From 0239489230ff7c9fc16d0dd8911123700b535b31 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 4 Oct 2014 15:46:46 +1300 Subject: Extend GT06 protocol --- src/org/traccar/protocol/Gt06ProtocolDecoder.java | 21 +++++++++++++-------- .../traccar/protocol/Gt06ProtocolDecoderTest.java | 3 +++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java index 4b9aaedf3..44702924c 100644 --- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java @@ -61,11 +61,13 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { private static final int MSG_LOGIN = 0x01; private static final int MSG_GPS = 0x10; private static final int MSG_LBS = 0x11; - private static final int MSG_GPS_LBS = 0x12; + private static final int MSG_GPS_LBS_1 = 0x12; + private static final int MSG_GPS_LBS_2 = 0x22; private static final int MSG_STATUS = 0x13; private static final int MSG_SATELLITE = 0x14; private static final int MSG_STRING = 0x15; - private static final int MSG_GPS_LBS_STATUS = 0x16; + private static final int MSG_GPS_LBS_STATUS_1 = 0x16; + private static final int MSG_GPS_LBS_STATUS_2 = 0x26; private static final int MSG_LBS_PHONE = 0x17; private static final int MSG_LBS_EXTEND = 0x18; private static final int MSG_LBS_STATUS = 0x19; @@ -130,10 +132,12 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { } - else if (/*deviceId != null && */( + else if (deviceId != null && ( type == MSG_GPS || - type == MSG_GPS_LBS || - type == MSG_GPS_LBS_STATUS || + type == MSG_GPS_LBS_1 || + type == MSG_GPS_LBS_2 || + type == MSG_GPS_LBS_STATUS_1 || + type == MSG_GPS_LBS_STATUS_2 || type == MSG_GPS_PHONE || type == MSG_GPS_LBS_EXTEND)) { @@ -184,10 +188,11 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { buf.skipBytes(gpsLength - 12); // skip reserved - if (type == MSG_GPS_LBS || type == MSG_GPS_LBS_STATUS) { + if (type == MSG_GPS_LBS_1 || type == MSG_GPS_LBS_2 || + type == MSG_GPS_LBS_STATUS_1 || type == MSG_GPS_LBS_STATUS_2) { int lbsLength = 0; - if (type == MSG_GPS_LBS_STATUS) { + if (type == MSG_GPS_LBS_STATUS_1 || type == MSG_GPS_LBS_STATUS_2) { lbsLength = buf.readUnsignedByte(); } @@ -199,7 +204,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { buf.skipBytes(lbsLength - 9); // Status - if (type == MSG_GPS_LBS_STATUS) { + if (type == MSG_GPS_LBS_STATUS_1 || type == MSG_GPS_LBS_STATUS_2) { extendedInfo.set("alarm", true); int flags = buf.readUnsignedByte(); diff --git a/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java b/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java index 7542bde61..a910cb618 100644 --- a/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java @@ -54,6 +54,9 @@ public class Gt06ProtocolDecoderTest { assertNull(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertArray( new int[] {0x78,0x78,0x8b,0x81,0x83,0x00,0x00,0x00,0x00,0x53,0x45,0x45,0x46,0x4e,0x26,0x26,0x00,0x4f,0x04,0x22,0x00,0x45,0x04,0x26,0x26,0x26,0x2b,0x37,0x39,0x30,0x35,0x34,0x30,0x31,0x35,0x35,0x34,0x36,0x26,0x26,0x26,0x26,0x26,0x26,0x04,0x10,0x04,0x1b,0x04,0x15,0x04,0x1a,0x04,0x21,0x04,0x15,0x04,0x19,0x26,0x26,0x2b,0x37,0x39,0x30,0x36,0x34,0x33,0x33,0x30,0x31,0x31,0x35,0x26,0x26,0x04,0x10,0x04,0x3d,0x04,0x4f,0x26,0x26,0x2b,0x37,0x39,0x36,0x30,0x34,0x37,0x38,0x34,0x30,0x36,0x34,0x26,0x26,0x04,0x12,0x04,0x3e,0x04,0x32,0x04,0x30,0x26,0x26,0x2b,0x37,0x39,0x32,0x38,0x38,0x34,0x37,0x37,0x38,0x38,0x31,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x23,0x23,0x00,0x02,0x00,0x22,0x15,0x5d,0x0d,0x0a})))); + verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertArray( + new int[] {0x78,0x78,0x22,0x22,0x0e,0x09,0x14,0x16,0x0f,0x07,0xc9,0x02,0x1a,0x36,0x28,0x05,0x09,0x0a,0x78,0x00,0xd8,0xb8,0x02,0xd4,0x02,0xc3,0x0e,0x00,0xa9,0x8a,0x01,0x05,0x01,0x02,0x13,0xf4,0xbb,0x0d,0x0a})))); + } } -- cgit v1.2.3