aboutsummaryrefslogtreecommitdiff
path: root/src/org
diff options
context:
space:
mode:
authorAnatoliy Golubev <darth.naihil@gmail.com>2017-09-10 01:48:01 +0300
committerAnatoliy Golubev <darth.naihil@gmail.com>2017-09-10 01:48:01 +0300
commitcdc7a0a0f8ba48b9581efeaeaa902f5a4ddcc306 (patch)
treec7632b59492af653160a8cbefb09b7d85d7524d0 /src/org
parent61ebffb15c72a0c73dfb82de7c62bce537019d9e (diff)
downloadtraccar-server-cdc7a0a0f8ba48b9581efeaeaa902f5a4ddcc306.tar.gz
traccar-server-cdc7a0a0f8ba48b9581efeaeaa902f5a4ddcc306.tar.bz2
traccar-server-cdc7a0a0f8ba48b9581efeaeaa902f5a4ddcc306.zip
Simplify ADM protocol decoder
Diffstat (limited to 'src/org')
-rw-r--r--src/org/traccar/protocol/AdmProtocolDecoder.java12
1 files changed, 2 insertions, 10 deletions
diff --git a/src/org/traccar/protocol/AdmProtocolDecoder.java b/src/org/traccar/protocol/AdmProtocolDecoder.java
index 4b6a5d3fc..b5a5c64dc 100644
--- a/src/org/traccar/protocol/AdmProtocolDecoder.java
+++ b/src/org/traccar/protocol/AdmProtocolDecoder.java
@@ -38,11 +38,6 @@ public class AdmProtocolDecoder extends BaseProtocolDecoder {
public static final int MSG_PHOTO = 0x0A;
public static final int MSG_ADM5 = 0x01;
- private DeviceSession parseIdentification(Channel channel, SocketAddress remoteAddress, ChannelBuffer buf) {
- String imei = buf.readBytes(15).toString(StandardCharsets.UTF_8);
- return getDeviceSession(channel, remoteAddress, imei);
- }
-
private Position parseData(Channel channel, SocketAddress remoteAddress, ChannelBuffer buf, int type) {
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress);
if (deviceSession == null) {
@@ -59,10 +54,7 @@ public class AdmProtocolDecoder extends BaseProtocolDecoder {
int status = buf.readUnsignedShort();
position.set(Position.KEY_STATUS, status);
-
- boolean isValid = !BitUtil.check(status, 5);
- position.setValid(isValid);
-
+ position.setValid(!BitUtil.check(status, 5));
position.setLatitude(buf.readFloat());
position.setLongitude(buf.readFloat());
position.setCourse(buf.readUnsignedShort() * 0.1);
@@ -150,7 +142,7 @@ public class AdmProtocolDecoder extends BaseProtocolDecoder {
if (size != CMD_RESPONSE_SIZE) {
int type = buf.readUnsignedByte();
if (type == MSG_IMEI) {
- parseIdentification(channel, remoteAddress, buf);
+ getDeviceSession(channel, remoteAddress, buf.readBytes(15).toString(StandardCharsets.UTF_8));
} else {
return parseData(channel, remoteAddress, buf, type);
}