diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2013-06-03 01:51:45 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2013-06-03 01:51:45 +1200 |
commit | 35033a6176e06d14c9fc7118f1320d01ede6ac89 (patch) | |
tree | 51eb9643f6ea856ab79ffb8edbf0ffa494cfba08 | |
parent | b16593f062d304e000899085b22d1232b055639b (diff) | |
download | traccar-server-35033a6176e06d14c9fc7118f1320d01ede6ac89.tar.gz traccar-server-35033a6176e06d14c9fc7118f1320d01ede6ac89.tar.bz2 traccar-server-35033a6176e06d14c9fc7118f1320d01ede6ac89.zip |
Update Apel decoder
-rw-r--r-- | src/org/traccar/protocol/ApelProtocolDecoder.java | 14 | ||||
-rw-r--r-- | test/org/traccar/protocol/ApelProtocolDecoderTest.java | 11 |
2 files changed, 14 insertions, 11 deletions
diff --git a/src/org/traccar/protocol/ApelProtocolDecoder.java b/src/org/traccar/protocol/ApelProtocolDecoder.java index 4a4596591..5f626a496 100644 --- a/src/org/traccar/protocol/ApelProtocolDecoder.java +++ b/src/org/traccar/protocol/ApelProtocolDecoder.java @@ -153,7 +153,7 @@ public class ApelProtocolDecoder extends BaseProtocolDecoder { else if (type == MSG_TYPE_LAST_LOG_INDEX) { long index = buf.readUnsignedInt(); if (index > 0) { - newIndex = index - 1; + newIndex = index; requestArchive(channel); } } @@ -173,16 +173,18 @@ public class ApelProtocolDecoder extends BaseProtocolDecoder { position.setDeviceId(deviceId); // Message index + int subtype = type; if (type == MSG_TYPE_LOG_RECORDS) { extendedInfo.set("archive", true); - lastIndex = buf.readUnsignedInt(); + lastIndex = buf.readUnsignedInt() + 1; position.setId(lastIndex); - int subtype = buf.readUnsignedShort(); - if (subtype != MSG_TYPE_CURRENT_GPS_DATA) { + subtype = buf.readUnsignedShort(); + if (subtype != MSG_TYPE_CURRENT_GPS_DATA && subtype != MSG_TYPE_STATE_FULL_INFO_T104) { buf.skipBytes(buf.readUnsignedShort()); continue; } + buf.readUnsignedShort(); // length } // Time @@ -198,7 +200,7 @@ public class ApelProtocolDecoder extends BaseProtocolDecoder { position.setLongitude(buf.readInt() * 180.0 / 0x7FFFFFFF); // Speed and Validity - if (type == MSG_TYPE_STATE_FULL_INFO_T104) { + if (subtype == MSG_TYPE_STATE_FULL_INFO_T104) { int speed = buf.readUnsignedByte(); position.setValid(speed != 255); position.setSpeed(speed * 0.539957); @@ -215,7 +217,7 @@ public class ApelProtocolDecoder extends BaseProtocolDecoder { // Altitude position.setAltitude((double) buf.readShort()); - if (type == MSG_TYPE_STATE_FULL_INFO_T104) { + if (subtype == MSG_TYPE_STATE_FULL_INFO_T104) { // Satellites extendedInfo.set("satellites", buf.readUnsignedByte()); diff --git a/test/org/traccar/protocol/ApelProtocolDecoderTest.java b/test/org/traccar/protocol/ApelProtocolDecoderTest.java index 1cd1291f4..f5c226acb 100644 --- a/test/org/traccar/protocol/ApelProtocolDecoderTest.java +++ b/test/org/traccar/protocol/ApelProtocolDecoderTest.java @@ -15,13 +15,14 @@ public class ApelProtocolDecoderTest { decoder.setDataManager(new TestDataManager()); /*byte[] buf1 = {0x40,0x4E,0x54,0x43,0x01,0x00,0x00,0x00,0x7B,0x00,0x00,0x00,0x13,0x00,0x44,0x34,0x2A,0x3E,0x53,0x3A,0x38,0x36,0x31,0x37,0x38,0x35,0x30,0x30,0x35,0x32,0x30,0x35,0x30,0x37,0x39}; - assertNull(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ByteOrder.LITTLE_ENDIAN, buf1))); + assertNull(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ByteOrder.LITTLE_ENDIAN, buf1)));*/ - byte[] buf2 = {0x40,0x4E,0x54,0x43,0x01,0x00,0x00,0x00,0x7B,0x00,0x00,0x00,0x5A,0x00,0x50,0x69,0x2A,0x3E,0x41,0x01,0x25,(byte)0xDB,0x0E,0x00,0x00,0x00,0x15,0x11,0x07,0x07,0x11,0x0A,0x0C,0x08,(byte)0x80,0x63,0x00,0x00,(byte)0xAA,0x39,(byte)0xA2,0x38,0x16,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x11,0x07,0x08,0x11,0x0A,0x0C,(byte)0xB3,(byte)0x89,(byte)0x79,0x3F,0x1A,(byte)0xEF,0x26,0x3F,0x00,0x00,0x00,0x00,0x12,0x00,0x34,(byte)0xF5,0x16,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,(byte)0xFA,(byte)0xFF,0x00,0x00,0x00,(byte)0xFA,(byte)0xFF,0x00,0x00,0x00,(byte)0xFA,(byte)0xFF,(byte)0x80,(byte)0x80,(byte)0x80,(byte)0x80}; - assertNotNull(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ByteOrder.LITTLE_ENDIAN, buf2))); + //0c002900f12a00000f003235303032363533343135313036340f0033353638393530333632373938313101002000000000 + //5c00380046e6a95136b693277f11b41a00172709f2ff03160002b9bc630007000000000000000000000000000000c31071090000880500000000000000000000 + //5c00380072e7a95136b693277f11b41a00172709f2ff03160002b9bc630007000000000000000000000000000000c31071090000880500000000000000000000 - byte[] buf3 = {0x40,0x4E,0x54,0x43,0x01,0x00,0x00,0x00,0x7B,0x00,0x00,0x00,0x13,0x00,0x47,0x37,0x2A,0x3E,0x53,0x3A,0x38,0x36,0x31,0x37,0x38,0x35,0x30,0x30,0x35,0x31,0x32,0x36,0x30,0x36,0x39}; - assertNull(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ByteOrder.LITTLE_ENDIAN, buf3)));*/ + //7900040069ea030000000000 + //8300c20003006aea03005c003800223aab5107a393276617b41a0030d506e3000414010250bf630007000000000000000000000000000000c3107209000089050000000000006bea03005c003800403aab5107a393276617b41a0030d506e3000414010250bf630007000000000000000000000000000000c3107209000089050000000000006cea03005c0038005e3aab5107a393276617b41a0030d506e3000414010250bf630007000000000000000000000000000000c31072090000890500000000000000000000 } |