aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/traccar/protocol/SuntechProtocolEncoder.java28
1 files changed, 21 insertions, 7 deletions
diff --git a/src/main/java/org/traccar/protocol/SuntechProtocolEncoder.java b/src/main/java/org/traccar/protocol/SuntechProtocolEncoder.java
index 0638e29d3..d1e8dd046 100644
--- a/src/main/java/org/traccar/protocol/SuntechProtocolEncoder.java
+++ b/src/main/java/org/traccar/protocol/SuntechProtocolEncoder.java
@@ -65,16 +65,30 @@ public class SuntechProtocolEncoder extends StringProtocolEncoder {
case Command.TYPE_REBOOT_DEVICE:
return formatCommand(command, prefix + ";%s;03;03\r", Command.KEY_UNIQUE_ID);
case Command.TYPE_POSITION_SINGLE:
- return formatCommand(command, prefix + ";%s;02;\r", Command.KEY_UNIQUE_ID);
+ return formatCommand(command, prefix + ";%s;03;01\r", Command.KEY_UNIQUE_ID);
case Command.TYPE_OUTPUT_CONTROL:
if (command.getAttributes().containsKey(Command.KEY_DATA)) {
- if (command.getAttributes().get(Command.KEY_DATA).equals("1")) {
- return formatCommand(command, prefix + ";%s;02;Enable%s\r",
- Command.KEY_UNIQUE_ID, Command.KEY_INDEX);
- } else {
- return formatCommand(command, prefix + ";%s;02;Disable%s\r",
- Command.KEY_UNIQUE_ID, Command.KEY_INDEX);
+ boolean status = command.getAttributes().get(Command.KEY_DATA).equals("1");
+ char index = Command.KEY_INDEX.charAt(0);
+ String n;
+ switch (index) {
+ case '1':
+ n = status ? "01" : "02"; // Enable1 : Disable1
+ break;
+ case '2':
+ n = status ? "03" : "04"; // Enable2 : Disable2
+ break;
+ case '3':
+ n = status ? "09" : "10"; // Enable3 : Disable3
+ break;
+ case '4':
+ n = status ? "13" : "14"; // Enable4 : Disable4
+ break;
+ default:
+ return null;
}
+ return formatCommand(command, prefix + ";%s;04;%s\r",
+ Command.KEY_UNIQUE_ID, n);
}
case Command.TYPE_ENGINE_STOP:
return formatCommand(command, prefix + ";%s;04;01\r", Command.KEY_UNIQUE_ID);