aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol/LaipacProtocolDecoder.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar/protocol/LaipacProtocolDecoder.java')
-rw-r--r--src/main/java/org/traccar/protocol/LaipacProtocolDecoder.java39
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;
}
-
}