diff options
author | Iván Ávalos <avalos@disroot.org> | 2022-01-10 19:50:56 -0600 |
---|---|---|
committer | Iván Ávalos <avalos@disroot.org> | 2022-01-10 19:50:56 -0600 |
commit | 05a81cfb6c0887afd3b736fa70f58df009fbf401 (patch) | |
tree | 848926c37841e9c7d76f3454c120e4f233978729 | |
parent | bc29caef7a5ca1451b6643f3e7e86a9fc42c643f (diff) | |
parent | 860274f79b91d6ba136e3496db8aa9b2073184cb (diff) | |
download | traccar-server-suntech-fixes.tar.gz traccar-server-suntech-fixes.tar.bz2 traccar-server-suntech-fixes.zip |
Merge branch 'suntech-fixes' of lraspi:/secret/git/repos/traccar-server into suntech-fixessuntech-fixes
-rw-r--r-- | src/main/java/org/traccar/protocol/SuntechProtocolEncoder.java | 28 |
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); |