diff options
author | Christoph Krey <krey.christoph@gmail.com> | 2017-06-24 09:20:41 +0200 |
---|---|---|
committer | Christoph Krey <krey.christoph@gmail.com> | 2017-06-24 09:20:41 +0200 |
commit | 6790c1b7e78543d427d8b93105e56e719f8ab6af (patch) | |
tree | c6576456e0514315521110928be1eecdafae6ace /src/org | |
parent | a0f389cf98e42a1794355be2a44167f61ad43557 (diff) | |
download | traccar-server-6790c1b7e78543d427d8b93105e56e719f8ab6af.tar.gz traccar-server-6790c1b7e78543d427d8b93105e56e719f8ab6af.tar.bz2 traccar-server-6790c1b7e78543d427d8b93105e56e719f8ab6af.zip |
add TYPE_POSITION_PERIODIC, TYPE_POSITION_STOP, TYPE_GET_VERSION, TYPE_REBOOT_DEVICE, and TYPE_SET_ODOMETER to Tk103 protocol
Diffstat (limited to 'src/org')
-rw-r--r-- | src/org/traccar/protocol/Tk103Protocol.java | 5 | ||||
-rw-r--r-- | src/org/traccar/protocol/Tk103ProtocolEncoder.java | 20 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/org/traccar/protocol/Tk103Protocol.java b/src/org/traccar/protocol/Tk103Protocol.java index 1d3497bfb..07a68e2d8 100644 --- a/src/org/traccar/protocol/Tk103Protocol.java +++ b/src/org/traccar/protocol/Tk103Protocol.java @@ -34,6 +34,11 @@ public class Tk103Protocol extends BaseProtocol { super("tk103"); setSupportedDataCommands( Command.TYPE_POSITION_SINGLE, + Command.TYPE_POSITION_PERIODIC, + Command.TYPE_POSITION_STOP, + Command.TYPE_GET_VERSION, + Command.TYPE_REBOOT_DEVICE, + Command.TYPE_SET_ODOMETER, Command.TYPE_ENGINE_STOP, Command.TYPE_ENGINE_RESUME); } diff --git a/src/org/traccar/protocol/Tk103ProtocolEncoder.java b/src/org/traccar/protocol/Tk103ProtocolEncoder.java index d3005296a..66cfc8dd2 100644 --- a/src/org/traccar/protocol/Tk103ProtocolEncoder.java +++ b/src/org/traccar/protocol/Tk103ProtocolEncoder.java @@ -26,12 +26,32 @@ public class Tk103ProtocolEncoder extends StringProtocolEncoder { protected Object encodeCommand(Command command) { switch (command.getType()) { + case Command.TYPE_GET_VERSION: + return formatCommand(command, "({%s}AP07)", Command.KEY_UNIQUE_ID); + + case Command.TYPE_REBOOT_DEVICE: + return formatCommand(command, "({%s}AT00)", Command.KEY_UNIQUE_ID); + + case Command.TYPE_SET_ODOMETER: + return formatCommand(command, "({%s}AX01)", Command.KEY_UNIQUE_ID); + case Command.TYPE_POSITION_SINGLE: return formatCommand(command, "({%s}AP00)", Command.KEY_UNIQUE_ID); + + case Command.TYPE_POSITION_PERIODIC: + return formatCommand(command, "({%s}AR00%s0000)", + Command.KEY_UNIQUE_ID, + String.format("%04X", command.getInteger(Command.KEY_FREQUENCY))); + + case Command.TYPE_POSITION_STOP: + return formatCommand(command, "({%s}AR0000000000)", Command.KEY_UNIQUE_ID); + case Command.TYPE_ENGINE_STOP: return formatCommand(command, "({%s}AV011)", Command.KEY_UNIQUE_ID); + case Command.TYPE_ENGINE_RESUME: return formatCommand(command, "({%s}AV010)", Command.KEY_UNIQUE_ID); + default: Log.warning(new UnsupportedOperationException(command.getType())); break; |