diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/org/traccar/DefaultDataHandler.java | 2 | ||||
-rw-r--r-- | src/org/traccar/protocol/Gt06ProtocolEncoder.java | 3 |
2 files changed, 3 insertions, 2 deletions
diff --git a/src/org/traccar/DefaultDataHandler.java b/src/org/traccar/DefaultDataHandler.java index cb35baceb..594961389 100644 --- a/src/org/traccar/DefaultDataHandler.java +++ b/src/org/traccar/DefaultDataHandler.java @@ -26,7 +26,7 @@ public class DefaultDataHandler extends BaseDataHandler { try { Context.getDataManager().addPosition(position); Position lastPosition = Context.getConnectionManager().getLastPosition(position.getDeviceId()); - if (position.getFixTime().compareTo(lastPosition.getFixTime()) > 0) { + if (lastPosition == null || position.getFixTime().compareTo(lastPosition.getFixTime()) > 0) { Context.getDataManager().updateLatestPosition(position); } } catch (Exception error) { diff --git a/src/org/traccar/protocol/Gt06ProtocolEncoder.java b/src/org/traccar/protocol/Gt06ProtocolEncoder.java index 09773cc45..22d62e9e5 100644 --- a/src/org/traccar/protocol/Gt06ProtocolEncoder.java +++ b/src/org/traccar/protocol/Gt06ProtocolEncoder.java @@ -18,6 +18,7 @@ package org.traccar.protocol; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.traccar.BaseProtocolEncoder; +import org.traccar.Context; import org.traccar.helper.Crc; import org.traccar.model.Command; @@ -34,7 +35,7 @@ public class Gt06ProtocolEncoder extends BaseProtocolEncoder { buf.writeByte(0x80); // message type - buf.writeByte(content.length()); // command length + buf.writeByte(4 + content.length()); // command length buf.writeInt(0); buf.writeBytes(content.getBytes()); // command |