diff options
-rw-r--r-- | src/org/traccar/protocol/MeitrackProtocolDecoder.java | 12 | ||||
-rw-r--r-- | test/org/traccar/protocol/MeitrackProtocolDecoderTest.java | 3 |
2 files changed, 12 insertions, 3 deletions
diff --git a/src/org/traccar/protocol/MeitrackProtocolDecoder.java b/src/org/traccar/protocol/MeitrackProtocolDecoder.java index 490d44226..166c77e60 100644 --- a/src/org/traccar/protocol/MeitrackProtocolDecoder.java +++ b/src/org/traccar/protocol/MeitrackProtocolDecoder.java @@ -39,11 +39,14 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + //$$J163,123123123123123,AFF,0004,35,58.588926,16.180473,140928192856,A,10,27,0,161,1.2,19 + //,1648894,435695,240|24|88B9|E435,0000,|||0A22|0000,00000001,,50,,,,,,,,,,,,,*70\r\n private static final Pattern pattern = Pattern.compile( "\\$\\$." + // Flag "\\d+," + // Length "(\\d+)," + // IMEI "\\p{XDigit}{3}," + // Command + "(?:\\d+,)?" + "(\\d+)," + // Event "(-?\\d+\\.\\d+)," + // Latitude "(-?\\d+\\.\\d+)," + // Longitude @@ -60,11 +63,11 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder { "(\\d+)," + // Runtime "(\\d+\\|\\d+\\|\\p{XDigit}+\\|\\p{XDigit}+)," + // Cell "(\\p{XDigit}+)," + // State - "(\\p{XDigit}+)\\|" + // ADC1 + "(\\p{XDigit}+)?\\|" + // ADC1 "(\\p{XDigit}+)?\\|" + // ADC2 "(\\p{XDigit}+)?\\|" + // ADC3 "(\\p{XDigit}+)\\|" + // Battery - "(\\p{XDigit}+)," + // Power + "(\\p{XDigit}+)," + // Power*/ ".*(\r\n)?"); private Position decodeRegularMessage(Channel channel, ChannelBuffer buf) { @@ -137,7 +140,10 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder { extendedInfo.set("state", parser.group(index++)); // ADC - extendedInfo.set("adc1", Integer.parseInt(parser.group(index++), 16)); + String adc1 = parser.group(index++); + if (adc1 != null) { + extendedInfo.set("adc1", Integer.parseInt(adc1, 16)); + } String adc2 = parser.group(index++); if (adc2 != null) { extendedInfo.set("adc2", Integer.parseInt(adc2, 16)); diff --git a/test/org/traccar/protocol/MeitrackProtocolDecoderTest.java b/test/org/traccar/protocol/MeitrackProtocolDecoderTest.java index f02c18a78..fe7c31b92 100644 --- a/test/org/traccar/protocol/MeitrackProtocolDecoderTest.java +++ b/test/org/traccar/protocol/MeitrackProtocolDecoderTest.java @@ -49,6 +49,9 @@ public class MeitrackProtocolDecoderTest { verify(decoder.decode(null, null, ChannelBuffers.copiedBuffer( "$$B140,013777001293701,AAA,35,-7.266760,112.743550,140521095314,A,3,22,0,275,2.7,45,1984,8059,510|1|3504|EBFE,0000,0000|0000|0000|0914|0002,,*F9\r\n", Charset.defaultCharset()))); + verify(decoder.decode(null, null, ChannelBuffers.copiedBuffer( + "$$J163,123123123123123,AFF,0004,35,58.588926,16.180473,140928192856,A,10,27,0,161,1.2,19,1648894,435695,240|24|88B9|E435,0000,|||0A22|0000,00000001,,50,,,,,,,,,,,,,*70\r\n", Charset.defaultCharset()))); + int[] buf1 = {0x24,0x24,0x47,0x39,0x37,0x30,0x2c,0x33,0x36,0x39,0x38,0x30,0x30,0x30,0x31,0x33,0x34,0x36,0x30,0x36,0x37,0x34,0x2c,0x43,0x43,0x43,0x2c,0x02,0x01,0x34,0x00,0x5b,0x00,0x00,0x00,0x01,0x0c,0xe3,0x04,0x03,0x5d,0xb9,0xe0,0x00,0xec,0x6f,0x59,0x1a,0x00,0x00,0x13,0x00,0x00,0x00,0x00,0x0c,0x00,0x18,0x01,0xed,0xb7,0x02,0x00,0xc9,0x6d,0x01,0x00,0xe6,0x00,0x01,0x00,0x48,0x38,0x57,0x65,0x01,0x00,0x03,0x00,0xa1,0x01,0xc2,0x04,0x00,0x00,0x00,0x00,0x01,0x0c,0xe3,0x04,0x03,0x5d,0xb9,0xe0,0x00,0xee,0x6f,0x59,0x1a,0x00,0x00,0x13,0x00,0x00,0x00,0x00,0x0c,0x00,0x18,0x01,0xed,0xb7,0x02,0x00,0xca,0x6d,0x01,0x00,0xe6,0x00,0x01,0x00,0x48,0x38,0x57,0x65,0x01,0x00,0x03,0x00,0xa1,0x01,0xc2,0x04,0x00,0x00,0x00,0x00,0x01,0x0c,0xe3,0x04,0x03,0x5d,0xb9,0xe0,0x00,0xef,0x6f,0x59,0x1a,0x00,0x00,0x13,0x00,0x00,0x00,0x00,0x0c,0x00,0x18,0x01,0xed,0xb7,0x02,0x00,0xcc,0x6d,0x01,0x00,0xe6,0x00,0x01,0x00,0x48,0x38,0x57,0x65,0x01,0x00,0x03,0x00,0xa1,0x01,0xc2,0x04,0x00,0x00,0x00,0x00,0x02,0x0c,0xe3,0x04,0x03,0x5d,0xb9,0xe0,0x00,0xf7,0x6f,0x59,0x1a,0x00,0x00,0x16,0x00,0x00,0x00,0x00,0x0c,0x00,0x18,0x01,0xed,0xb7,0x02,0x00,0xd3,0x6d,0x01,0x00,0xe6,0x00,0x01,0x00,0x48,0x38,0x57,0x65,0x02,0x00,0x03,0x00,0xa1,0x01,0xbf,0x04,0x00,0x00,0x00,0x00,0x0a,0x0c,0xe3,0x04,0x03,0x5d,0xb9,0xe0,0x00,0xf7,0x6f,0x59,0x1a,0x00,0x00,0x16,0x00,0x00,0x00,0x00,0x0c,0x00,0x18,0x01,0xed,0xb7,0x02,0x00,0xd4,0x6d,0x01,0x00,0xe6,0x00,0x01,0x00,0x48,0x38,0x57,0x65,0x00,0x00,0x03,0x00,0xa1,0x01,0xbf,0x04,0x00,0x00,0x00,0x00,0x02,0x0c,0xe3,0x04,0x03,0x5d,0xb9,0xe0,0x00,0xfb,0x6f,0x59,0x1a,0x00,0x00,0x16,0x00,0x00,0x00,0x00,0x0c,0x00,0x18,0x01,0xed,0xb7,0x02,0x00,0xd8,0x6d,0x01,0x00,0xe6,0x00,0x01,0x00,0x48,0x38,0x57,0x65,0x02,0x00,0x03,0x00,0xa1,0x01,0x76,0x04,0x00,0x00,0x00,0x00,0x18,0x0c,0xe3,0x04,0x03,0x5d,0xb9,0xe0,0x00,0xfc,0x6f,0x59,0x1a,0x00,0x00,0x12,0x00,0x00,0x00,0x00,0x00,0x00,0x8c,0x00,0xed,0xb7,0x02,0x00,0xd9,0x6d,0x01,0x00,0xe6,0x00,0x01,0x00,0x48,0x38,0x57,0x65,0x02,0x00,0x03,0x00,0xa1,0x01,0x76,0x04,0x00,0x00,0x00,0x00,0x19,0xb1,0xe2,0x04,0x03,0x23,0xb9,0xe0,0x00,0x0b,0x70,0x59,0x1a,0x01,0x05,0x15,0x06,0x00,0xbb,0x00,0x12,0x00,0x29,0x01,0xed,0xb7,0x02,0x00,0xe7,0x6d,0x01,0x00,0xe6,0x00,0x01,0x00,0x48,0x38,0x57,0x65,0x02,0x00,0x03,0x00,0xa2,0x01,0x70,0x05,0x00,0x00,0x00,0x00,0x20,0x23,0xe3,0x04,0x03,0x1f,0xb9,0xe0,0x00,0x10,0x70,0x59,0x1a,0x01,0x06,0x15,0x07,0x00,0x27,0x01,0x0d,0x00,0x16,0x01,0xfc,0xb7,0x02,0x00,0xec,0x6d,0x01,0x00,0xe6,0x00,0x01,0x00,0x48,0x38,0x57,0x65,0x02,0x00,0x03,0x00,0xa2,0x01,0x80,0x05,0x00,0x00,0x00,0x00,0x20,0x1f,0xe3,0x04,0x03,0x02,0xb9,0xe0,0x00,0x11,0x70,0x59,0x1a,0x01,0x06,0x15,0x09,0x00,0x19,0x01,0x0d,0x00,0x15,0x01,0xfe,0xb7,0x02,0x00,0xed,0x6d,0x01,0x00,0xe6,0x00,0x01,0x00,0x48,0x38,0x57,0x65,0x02,0x00,0x03,0x00,0xa2,0x01,0x80,0x05,0x00,0x00,0x00,0x00,0x20,0x18,0xe3,0x04,0x03,0xdc,0xb8,0xe0,0x00,0x12,0x70,0x59,0x1a,0x01,0x06,0x15,0x0b,0x00,0x11,0x01,0x0d,0x00,0x15,0x01,0x00,0xb8,0x02,0x00,0xee,0x6d,0x01,0x00,0xe6,0x00,0x01,0x00,0x48,0x38,0x57,0x65,0x02,0x00,0x03,0x00,0xa2,0x01,0x80,0x05,0x00,0x00,0x00,0x00,0x20,0x36,0xe3,0x04,0x03,0x45,0xb8,0xe0,0x00,0x15,0x70,0x59,0x1a,0x01,0x07,0x15,0x0b,0x00,0x2d,0x01,0x0b,0x00,0x13,0x01,0x0a,0xb8,0x02,0x00,0xf1,0x6d,0x01,0x00,0xe6,0x00,0x01,0x00,0x48,0x38,0x57,0x65,0x02,0x00,0x03,0x00,0xa2,0x01,0x80,0x05,0x00,0x00,0x00,0x00,0x20,0x53,0xe3,0x04,0x03,0x26,0xb8,0xe0,0x00,0x16,0x70,0x59,0x1a,0x01,0x07,0x15,0x0d,0x00,0x41,0x01,0x0b,0x00,0x13,0x01,0x0e,0xb8,0x02,0x00,0xf2,0x6d,0x01,0x00,0xe6,0x00,0x01,0x00,0x48,0x38,0x57,0x65,0x02,0x00,0x03,0x00,0xa2,0x01,0x80,0x05,0x00,0x00,0x00,0x00,0x20,0x70,0xe3,0x04,0x03,0x10,0xb8,0xe0,0x00,0x17,0x70,0x59,0x1a,0x01,0x07,0x15,0x0e,0x00,0x4f,0x01,0x0b,0x00,0x13,0x01,0x11,0xb8,0x02,0x00,0xf3,0x6d,0x01,0x00,0xe6,0x00,0x01,0x00,0x48,0x38,0x57,0x65,0x02,0x00,0x03,0x00,0xa2,0x01,0x80,0x05,0x00,0x00,0x00,0x00,0x20,0x95,0xe3,0x04,0x03,0x06,0xb8,0xe0,0x00,0x18,0x70,0x59,0x1a,0x01,0x07,0x15,0x0d,0x00,0x5a,0x01,0x0b,0x00,0x14,0x01,0x15,0xb8,0x02,0x00,0xf4,0x6d,0x01,0x00,0xe6,0x00,0x01,0x00,0x48,0x38,0x57,0x65,0x02,0x00,0x03,0x00,0xa2,0x01,0x80,0x05,0x00,0x00,0x00,0x00,0x20,0xb3,0xe3,0x04,0x03,0x05,0xb8,0xe0,0x00,0x19,0x70,0x59,0x1a,0x01,0x07,0x15,0x0b,0x00,0x60,0x01,0x0b,0x00,0x14,0x01,0x18,0xb8,0x02,0x00,0xf5,0x6d,0x01,0x00,0xe6,0x00,0x01,0x00,0x48,0x38,0x57,0x65,0x02,0x00,0x03,0x00,0xa2,0x01,0x83,0x05,0x00,0x00,0x00,0x00,0x20,0xcf,0xe3,0x04,0x03,0x08,0xb8,0xe0,0x00,0x1a,0x70,0x59,0x1a,0x01,0x07,0x15,0x0b,0x00,0x66,0x01,0x0b,0x00,0x14,0x01,0x1b,0xb8,0x02,0x00,0xf6,0x6d,0x01,0x00,0xe6,0x00,0x01,0x00,0x48,0x38,0x57,0x65,0x02,0x00,0x03,0x00,0xa2,0x01,0x83,0x05,0x00,0x00,0x00,0x00,0x20,0xee,0xe3,0x04,0x03,0x0c,0xb8,0xe0,0x00,0x1b,0x70,0x59,0x1a,0x01,0x06,0x17,0x0b,0x00,0x04,0x00,0x0d,0x00,0x14,0x01,0x1e,0xb8,0x02,0x00,0xf7,0x6d,0x01,0x00,0xe6,0x00,0x01,0x00,0x48,0x38,0x57,0x65,0x02,0x00,0x03,0x00,0xa2,0x01,0x83,0x05,0x00,0x00,0x00,0x00,0x2a,0x62,0x35,0x0d,0x0a}; verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ByteOrder.LITTLE_ENDIAN, ChannelBufferTools.convertArray(buf1)))); |