aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol/LaipacProtocolEncoder.java
diff options
context:
space:
mode:
authorEdward Valley <ed.valley@yandex.com>2019-07-03 17:04:36 -0400
committerEdward Valley <ed.valley@yandex.com>2019-07-03 17:04:36 -0400
commit9cd863136dbcf9e8062f633869de212426bed960 (patch)
tree61b6329f32865076ed5608790e01657e923fc3d0 /src/main/java/org/traccar/protocol/LaipacProtocolEncoder.java
parentefb64c30835eccf1e532ea7d7618d2d40ce7b761 (diff)
downloadtrackermap-server-9cd863136dbcf9e8062f633869de212426bed960.tar.gz
trackermap-server-9cd863136dbcf9e8062f633869de212426bed960.tar.bz2
trackermap-server-9cd863136dbcf9e8062f633869de212426bed960.zip
Changes after first review
Diffstat (limited to 'src/main/java/org/traccar/protocol/LaipacProtocolEncoder.java')
-rw-r--r--src/main/java/org/traccar/protocol/LaipacProtocolEncoder.java20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/main/java/org/traccar/protocol/LaipacProtocolEncoder.java b/src/main/java/org/traccar/protocol/LaipacProtocolEncoder.java
index 090203806..fac82d2fd 100644
--- a/src/main/java/org/traccar/protocol/LaipacProtocolEncoder.java
+++ b/src/main/java/org/traccar/protocol/LaipacProtocolEncoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2019 Anton Tananaev (anton@traccar.org)
+ * Copyright 2019 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
*/
package org.traccar.protocol;
-import org.traccar.Context;
import org.traccar.Protocol;
import org.traccar.StringProtocolEncoder;
import org.traccar.model.Command;
@@ -28,8 +27,7 @@ public class LaipacProtocolEncoder extends StringProtocolEncoder {
public LaipacProtocolEncoder(Protocol protocol) {
this.protocol = protocol;
- defaultDevicePassword = Context.getConfig().getString(
- getProtocolName() + ".defaultPassword", "00000000");
+ defaultDevicePassword = "00000000";
}
protected String getProtocolName() {
@@ -41,28 +39,28 @@ public class LaipacProtocolEncoder extends StringProtocolEncoder {
initDevicePassword(command, defaultDevicePassword);
- String cmd = "";
+ String commandSentence = null;
switch (command.getType()) {
case Command.TYPE_CUSTOM:
- cmd = formatCommand(command, "${%s}",
+ commandSentence = formatCommand(command, "${%s}",
Command.KEY_DATA);
break;
case Command.TYPE_POSITION_SINGLE:
- cmd = formatCommand(command, "$AVREQ,{%s},1",
+ commandSentence = formatCommand(command, "$AVREQ,{%s},1",
Command.KEY_DEVICE_PASSWORD);
break;
case Command.TYPE_REBOOT_DEVICE:
- cmd = formatCommand(command, "$AVRESET,{%s},{%s}",
+ commandSentence = formatCommand(command, "$AVRESET,{%s},{%s}",
Command.KEY_UNIQUE_ID, Command.KEY_DEVICE_PASSWORD);
break;
default:
break;
}
- if (cmd.length() > 0) {
- cmd += Checksum.nmea(cmd) + "\r\n";
- return cmd;
+ if (commandSentence != null) {
+ commandSentence += Checksum.nmea(commandSentence) + "\r\n";
+ return commandSentence;
}
return null;