diff options
author | Edward Valley <ed.valley@yandex.com> | 2019-07-10 17:03:25 -0400 |
---|---|---|
committer | Edward Valley <ed.valley@yandex.com> | 2019-07-10 17:03:25 -0400 |
commit | 2c604b9c9ee8f996902acfdd60626324a8414d34 (patch) | |
tree | db8a77746ff1b59b846b6806e1019c128803bec1 /src/main/java/org/traccar/protocol/LaipacProtocolDecoder.java | |
parent | 11568839d89fa5bf58da0a654248f9b7696ee406 (diff) | |
download | trackermap-server-2c604b9c9ee8f996902acfdd60626324a8414d34.tar.gz trackermap-server-2c604b9c9ee8f996902acfdd60626324a8414d34.tar.bz2 trackermap-server-2c604b9c9ee8f996902acfdd60626324a8414d34.zip |
Changes after third review
Diffstat (limited to 'src/main/java/org/traccar/protocol/LaipacProtocolDecoder.java')
-rw-r--r-- | src/main/java/org/traccar/protocol/LaipacProtocolDecoder.java | 39 |
1 files changed, 12 insertions, 27 deletions
diff --git a/src/main/java/org/traccar/protocol/LaipacProtocolDecoder.java b/src/main/java/org/traccar/protocol/LaipacProtocolDecoder.java index c028d78b6..381f497e4 100644 --- a/src/main/java/org/traccar/protocol/LaipacProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/LaipacProtocolDecoder.java @@ -26,8 +26,6 @@ import org.traccar.helper.DateBuilder; import org.traccar.helper.Parser; import org.traccar.helper.PatternBuilder; import org.traccar.model.CellTower; -import org.traccar.model.Device; -import org.traccar.model.Command; import org.traccar.model.Network; import org.traccar.model.Position; @@ -123,21 +121,6 @@ public class LaipacProtocolDecoder extends BaseProtocolDecoder { return event; } - private String getDevicePassword(DeviceSession deviceSession) { - - String devicePassword = DEFAULT_DEVICE_PASSWORD; - - Device device = Context.getIdentityManager().getById(deviceSession.getDeviceId()); - if (device != null) { - String password = device.getString(Command.KEY_DEVICE_PASSWORD); - if (password != null) { - devicePassword = password; - } - } - - return devicePassword; - } - private void sendEventResponse( String event, String devicePassword, Channel channel, SocketAddress remoteAddress) { @@ -247,7 +230,8 @@ public class LaipacProtocolDecoder extends BaseProtocolDecoder { sendAcknowledge(status, event, checksum, channel, remoteAddress); - String devicePassword = getDevicePassword(deviceSession); + String devicePassword = Context.getIdentityManager() + .getDevicePassword(deviceSession.getDeviceId(), DEFAULT_DEVICE_PASSWORD); sendEventResponse(event, devicePassword, channel, remoteAddress); } @@ -260,18 +244,19 @@ public class LaipacProtocolDecoder extends BaseProtocolDecoder { String sentence = (String) msg; - Parser parser = new Parser(PATTERN_ECHK, sentence); - if (parser.matches()) { - return handleEchk(sentence, parser, channel, remoteAddress); - } - - parser = new Parser(PATTERN_AVRMC, sentence); - if (parser.matches()) { - return handleAvrmc(sentence, parser, channel, remoteAddress); + if (sentence.startsWith("$ECHK")) { + Parser parser = new Parser(PATTERN_ECHK, sentence); + if (parser.matches()) { + return handleEchk(sentence, parser, channel, remoteAddress); + } + } else if (sentence.startsWith("$AVRMC")) { + Parser parser = new Parser(PATTERN_AVRMC, sentence); + if (parser.matches()) { + return handleAvrmc(sentence, parser, channel, remoteAddress); + } } return null; } - } |