From cdc7a0a0f8ba48b9581efeaeaa902f5a4ddcc306 Mon Sep 17 00:00:00 2001 From: Anatoliy Golubev Date: Sun, 10 Sep 2017 01:48:01 +0300 Subject: Simplify ADM protocol decoder --- src/org/traccar/protocol/AdmProtocolDecoder.java | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'src') 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); } -- cgit v1.2.3