aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-12-21 17:39:08 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2016-12-21 17:39:08 +1300
commit5328e632eaac60549cc901e2f17695f75fe4f8b9 (patch)
tree36280a3e1b0f2e231ac3be77a26860c3f0b9b360 /src/org/traccar/protocol
parentff3cf10de072d4ee522447b05278d8c2f029a034 (diff)
downloadtraccar-server-5328e632eaac60549cc901e2f17695f75fe4f8b9.tar.gz
traccar-server-5328e632eaac60549cc901e2f17695f75fe4f8b9.tar.bz2
traccar-server-5328e632eaac60549cc901e2f17695f75fe4f8b9.zip
Fix some minor GT06 code issues
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r--src/org/traccar/protocol/Gt06ProtocolDecoder.java46
1 files changed, 14 insertions, 32 deletions
diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
index 59c301186..356097fb2 100644
--- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
@@ -222,8 +222,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
}
}
- DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, imei);
- if (deviceSession != null) {
+ if (getDeviceSession(channel, remoteAddress, imei) != null) {
buf.skipBytes(buf.readableBytes() - 6);
sendResponse(channel, type, buf.readUnsignedShort());
}
@@ -235,11 +234,11 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
return null;
}
- if (type == MSG_LBS_EXTEND) {
+ Position position = new Position();
+ position.setDeviceId(deviceSession.getDeviceId());
+ position.setProtocol(getProtocolName());
- Position position = new Position();
- position.setDeviceId(deviceSession.getDeviceId());
- position.setProtocol(getProtocolName());
+ if (type == MSG_LBS_EXTEND) {
DateBuilder dateBuilder = new DateBuilder(timeZone)
.setDate(buf.readUnsignedByte(), buf.readUnsignedByte(), buf.readUnsignedByte())
@@ -257,13 +256,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
}
position.setNetwork(network);
- return position;
-
- } if (type == MSG_STRING) {
-
- Position position = new Position();
- position.setDeviceId(deviceSession.getDeviceId());
- position.setProtocol(getProtocolName());
+ } else if (type == MSG_STRING) {
getLastLocation(position, null);
@@ -274,18 +267,8 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
position.set("command", buf.readBytes(commandLength - 1).toString(StandardCharsets.US_ASCII));
}
- buf.readUnsignedShort(); // language
-
- sendResponse(channel, type, buf.readUnsignedShort());
-
- return position;
-
} else if (isSupported(type)) {
- Position position = new Position();
- position.setDeviceId(deviceSession.getDeviceId());
- position.setProtocol(getProtocolName());
-
if (hasGps(type)) {
decodeGps(position, buf);
} else {
@@ -304,24 +287,23 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_ODOMETER, buf.readUnsignedInt());
}
- if (buf.readableBytes() > 6) {
- buf.skipBytes(buf.readableBytes() - 6);
- }
- int index = buf.readUnsignedShort();
- position.set(Position.KEY_INDEX, index);
- sendResponse(channel, type, index);
-
- return position;
-
} else {
buf.skipBytes(dataLength);
if (type != MSG_COMMAND_0 && type != MSG_COMMAND_1 && type != MSG_COMMAND_2) {
sendResponse(channel, type, buf.readUnsignedShort());
}
+ return null;
}
+ if (buf.readableBytes() > 6) {
+ buf.skipBytes(buf.readableBytes() - 6);
+ }
+ sendResponse(channel, type, buf.readUnsignedShort());
+
+ return position;
+
}
} else if (header == 0x7979) {