diff options
author | Ivan Muratov <binakot@gmail.com> | 2017-07-13 09:15:54 +0300 |
---|---|---|
committer | Ivan Muratov <binakot@gmail.com> | 2017-07-13 09:15:54 +0300 |
commit | a2376cf6354a94c8bd8c8e13c4e78936d4f2ae97 (patch) | |
tree | 7516026071e88fd1fdc37fd7d00372f08f57710a /src/org | |
parent | 93227f9bffdfce2f1d60a61ea88f4eb152dfada5 (diff) | |
parent | f643173b6b2c52a3896d6ee13578edd86f9eb3e7 (diff) | |
download | trackermap-server-a2376cf6354a94c8bd8c8e13c4e78936d4f2ae97.tar.gz trackermap-server-a2376cf6354a94c8bd8c8e13c4e78936d4f2ae97.tar.bz2 trackermap-server-a2376cf6354a94c8bd8c8e13c4e78936d4f2ae97.zip |
Merge branch 'anravi4_fix'
Diffstat (limited to 'src/org')
-rw-r--r-- | src/org/traccar/protocol/Arnavi4FrameDecoder.java | 2 | ||||
-rw-r--r-- | src/org/traccar/protocol/Arnavi4ProtocolDecoder.java | 16 |
2 files changed, 10 insertions, 8 deletions
diff --git a/src/org/traccar/protocol/Arnavi4FrameDecoder.java b/src/org/traccar/protocol/Arnavi4FrameDecoder.java index eaf829cc3..97bf75a20 100644 --- a/src/org/traccar/protocol/Arnavi4FrameDecoder.java +++ b/src/org/traccar/protocol/Arnavi4FrameDecoder.java @@ -10,7 +10,7 @@ import org.jboss.netty.handler.codec.frame.FrameDecoder; */ public class Arnavi4FrameDecoder extends FrameDecoder { - static final byte HEADER_START_SIGN = (byte)0xFF; + static final byte HEADER_START_SIGN = (byte) 0xFF; static final byte HEADER_VERSION_1 = 0x22; static final byte HEADER_VERSION_2 = 0x23; static final int HEADER_LENGTH = 10; diff --git a/src/org/traccar/protocol/Arnavi4ProtocolDecoder.java b/src/org/traccar/protocol/Arnavi4ProtocolDecoder.java index 46caebb71..c5ec3f31f 100644 --- a/src/org/traccar/protocol/Arnavi4ProtocolDecoder.java +++ b/src/org/traccar/protocol/Arnavi4ProtocolDecoder.java @@ -15,7 +15,11 @@ import java.util.Date; import java.util.LinkedList; import java.util.List; -import static org.traccar.protocol.Arnavi4FrameDecoder.*; +import static org.traccar.protocol.Arnavi4FrameDecoder.HEADER_START_SIGN; +import static org.traccar.protocol.Arnavi4FrameDecoder.HEADER_VERSION_1; +import static org.traccar.protocol.Arnavi4FrameDecoder.HEADER_VERSION_2; +import static org.traccar.protocol.Arnavi4FrameDecoder.PACKAGE_START_SIGN; +import static org.traccar.protocol.Arnavi4FrameDecoder.PACKAGE_END_SIGN; /** * Created by Ivan Muratov @binakot on 11.07.2017. @@ -99,9 +103,9 @@ public class Arnavi4ProtocolDecoder extends BaseProtocolDecoder { } else if (version == HEADER_VERSION_2) { response = ChannelBuffers.dynamicBuffer(ByteOrder.LITTLE_ENDIAN, 9); response.writeBytes(new byte[]{0x7B, 0x04, 0x00}); - byte[] timestampBytes = ByteBuffer.allocate(4).putInt((int) (System.currentTimeMillis() / 1000)).array(); - response.writeByte(Checksum.modulo256(timestampBytes)); - response.writeBytes(timestampBytes); + byte[] timeBytes = ByteBuffer.allocate(4).putInt((int) (System.currentTimeMillis() / 1000)).array(); + response.writeByte(Checksum.modulo256(timeBytes)); + response.writeBytes(timeBytes); response.writeByte(0x7D); } else { @@ -132,7 +136,7 @@ public class Arnavi4ProtocolDecoder extends BaseProtocolDecoder { case RECORD_DATA: case RECORD_TEXT: case RECORD_FILE: - case RECORD_BINARY: { + case RECORD_BINARY: int length = buf.readUnsignedShort(); long timestamp = buf.readUnsignedInt() * 1000; ChannelBuffer recordBuf = buf.readBytes(length); @@ -142,9 +146,7 @@ public class Arnavi4ProtocolDecoder extends BaseProtocolDecoder { } buf.readUnsignedByte(); // crc - break; - } default: throw new IllegalArgumentException("unsupported record type"); |