aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar
diff options
context:
space:
mode:
authorEdward Valley <ed.valley@yandex.com>2019-07-10 18:11:13 -0400
committerEdward Valley <ed.valley@yandex.com>2019-07-10 18:11:13 -0400
commit0064dec35205fba7b1c8e6c1c0553407688055a8 (patch)
tree87d117c73daaf3ab3c301262ee3d9d815cc405ad /src/main/java/org/traccar
parent2c604b9c9ee8f996902acfdd60626324a8414d34 (diff)
downloadtraccar-server-0064dec35205fba7b1c8e6c1c0553407688055a8.tar.gz
traccar-server-0064dec35205fba7b1c8e6c1c0553407688055a8.tar.bz2
traccar-server-0064dec35205fba7b1c8e6c1c0553407688055a8.zip
Changes after fourth review
Diffstat (limited to 'src/main/java/org/traccar')
-rw-r--r--src/main/java/org/traccar/database/DeviceManager.java7
-rw-r--r--src/main/java/org/traccar/database/IdentityManager.java2
-rw-r--r--src/main/java/org/traccar/protocol/LaipacProtocolDecoder.java31
-rw-r--r--src/main/java/org/traccar/protocol/LaipacProtocolEncoder.java3
4 files changed, 20 insertions, 23 deletions
diff --git a/src/main/java/org/traccar/database/DeviceManager.java b/src/main/java/org/traccar/database/DeviceManager.java
index d1a205b01..231be7b07 100644
--- a/src/main/java/org/traccar/database/DeviceManager.java
+++ b/src/main/java/org/traccar/database/DeviceManager.java
@@ -115,14 +115,9 @@ public class DeviceManager extends BaseObjectManager<Device> implements Identity
return devicesByUniqueId.get(uniqueId);
}
- public String getDevicePassword(long id) {
-
- return getById(id).getString(Command.KEY_DEVICE_PASSWORD);
- }
-
public String getDevicePassword(long id, String defaultPassword) {
- String password = getDevicePassword(id);
+ String password = getById(id).getString(Command.KEY_DEVICE_PASSWORD);
if (password != null) {
return password;
}
diff --git a/src/main/java/org/traccar/database/IdentityManager.java b/src/main/java/org/traccar/database/IdentityManager.java
index 331706669..add3e5a79 100644
--- a/src/main/java/org/traccar/database/IdentityManager.java
+++ b/src/main/java/org/traccar/database/IdentityManager.java
@@ -26,8 +26,6 @@ public interface IdentityManager {
Device getByUniqueId(String uniqueId) throws Exception;
- String getDevicePassword(long id);
-
String getDevicePassword(long id, String defaultPassword);
Position getLastPosition(long deviceId);
diff --git a/src/main/java/org/traccar/protocol/LaipacProtocolDecoder.java b/src/main/java/org/traccar/protocol/LaipacProtocolDecoder.java
index 381f497e4..3eecf58a3 100644
--- a/src/main/java/org/traccar/protocol/LaipacProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/LaipacProtocolDecoder.java
@@ -167,8 +167,13 @@ public class LaipacProtocolDecoder extends BaseProtocolDecoder {
}
- private Object handleEchk(
- String sentence, Parser parser, Channel channel, SocketAddress remoteAddress) {
+ private Object decodeEchk(
+ String sentence, Channel channel, SocketAddress remoteAddress) {
+
+ Parser parser = new Parser(PATTERN_ECHK, sentence);
+ if (!parser.matches()) {
+ return null;
+ }
if (channel != null) {
channel.writeAndFlush(new NetworkMessage(sentence + "\r\n", remoteAddress));
@@ -177,8 +182,13 @@ public class LaipacProtocolDecoder extends BaseProtocolDecoder {
return null;
}
- protected Object handleAvrmc(
- String sentence, Parser parser, Channel channel, SocketAddress remoteAddress) {
+ protected Object decodeAvrmc(
+ String sentence, Channel channel, SocketAddress remoteAddress) {
+
+ Parser parser = new Parser(PATTERN_AVRMC, sentence);
+ if (!parser.matches()) {
+ return null;
+ }
DeviceSession deviceSession =
getDeviceSession(channel, remoteAddress, parser.next());
@@ -245,15 +255,10 @@ public class LaipacProtocolDecoder extends BaseProtocolDecoder {
String sentence = (String) msg;
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 decodeEchk(sentence, channel, remoteAddress);
+ }
+ if (sentence.startsWith("$AVRMC")) {
+ return decodeAvrmc(sentence, channel, remoteAddress);
}
return null;
diff --git a/src/main/java/org/traccar/protocol/LaipacProtocolEncoder.java b/src/main/java/org/traccar/protocol/LaipacProtocolEncoder.java
index 9b99486f7..dec76b83c 100644
--- a/src/main/java/org/traccar/protocol/LaipacProtocolEncoder.java
+++ b/src/main/java/org/traccar/protocol/LaipacProtocolEncoder.java
@@ -44,10 +44,9 @@ public class LaipacProtocolEncoder extends StringProtocolEncoder {
return formatCommand(command, "AVRESET,{%s},{%s}",
Command.KEY_UNIQUE_ID, Command.KEY_DEVICE_PASSWORD);
default:
- break;
+ return null;
}
- return null;
}
}