aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/org/traccar/BaseProtocolDecoder.java8
-rw-r--r--src/org/traccar/protocol/Gt06ProtocolDecoder.java9
-rw-r--r--test/org/traccar/protocol/Gt06ProtocolDecoderTest.java4
3 files changed, 15 insertions, 6 deletions
diff --git a/src/org/traccar/BaseProtocolDecoder.java b/src/org/traccar/BaseProtocolDecoder.java
index 12762c19b..e9c678930 100644
--- a/src/org/traccar/BaseProtocolDecoder.java
+++ b/src/org/traccar/BaseProtocolDecoder.java
@@ -74,7 +74,7 @@ public abstract class BaseProtocolDecoder extends ExtendedObjectDecoder {
this.protocol = protocol;
}
- public void getLastLocation(Position position) {
+ public void getLastLocation(Position position, Date deviceTime) {
Position last = Context.getConnectionManager().getLastPosition(getDeviceId());
if (last != null) {
position.setFixTime(last.getFixTime());
@@ -87,6 +87,12 @@ public abstract class BaseProtocolDecoder extends ExtendedObjectDecoder {
} else {
position.setFixTime(new Date(0));
}
+
+ if (deviceTime != null) {
+ position.setDeviceTime(deviceTime);
+ } else {
+ position.setDeviceTime(new Date());
+ }
}
}
diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
index a551e65ce..f30b71c54 100644
--- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
@@ -75,12 +75,13 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
}
private static boolean hasLbs(int type) {
- return 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_LBS_STATUS_3;
+ return type == MSG_LBS || type == MSG_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_LBS_STATUS_3;
}
private static boolean hasStatus(int type) {
- return type == MSG_GPS_LBS_STATUS_1 || type == MSG_GPS_LBS_STATUS_2 || type == MSG_GPS_LBS_STATUS_3;
+ return type == MSG_STATUS || type == MSG_LBS_STATUS
+ || type == MSG_GPS_LBS_STATUS_1 || type == MSG_GPS_LBS_STATUS_2 || type == MSG_GPS_LBS_STATUS_3;
}
private static void sendResponse(Channel channel, int type, int index) {
@@ -212,7 +213,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
if (hasGps(type)) {
decodeGps(position, buf);
} else {
- getLastLocation(position);
+ getLastLocation(position, null);
}
if (hasLbs(type)) {
diff --git a/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java b/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java
index a72c709f2..d3a588e48 100644
--- a/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java
@@ -1,6 +1,8 @@
package org.traccar.protocol;
import org.jboss.netty.buffer.ChannelBuffers;
+
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import org.junit.Test;
import org.traccar.helper.ChannelBufferTools;
@@ -16,7 +18,7 @@ public class Gt06ProtocolDecoderTest extends ProtocolDecoderTest {
assertNull(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertHexString(
"787811010123456789012345100B3201000171930D0A"))));
- assertNull(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertHexString(
+ assertNotNull(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertHexString(
"78780a13440604000201baaf540d0a"))));
verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertHexString(