From db6e8564001a31cf7c4954cc422a1422fcd3c14a Mon Sep 17 00:00:00 2001 From: drecchia Date: Tue, 12 Jul 2016 18:36:42 -0300 Subject: - Added support for activate output1, reboot device and request position. --- src/org/traccar/protocol/SuntechProtocolEncoder.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/org/traccar/protocol/SuntechProtocolEncoder.java b/src/org/traccar/protocol/SuntechProtocolEncoder.java index d988f97be..2f66d8d0c 100644 --- a/src/org/traccar/protocol/SuntechProtocolEncoder.java +++ b/src/org/traccar/protocol/SuntechProtocolEncoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2016 Anton Tananaev (anton.tananaev@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,12 @@ public class SuntechProtocolEncoder extends StringProtocolEncoder { protected Object encodeCommand(Command command) { switch (command.getType()) { + case Command.TYPE_REBOOT_DEVICE: + return formatCommand(command, "SA200CMD;{%s};02;Reboot\r", Command.KEY_UNIQUE_ID); + case Command.TYPE_POSITION_SINGLE: + return formatCommand(command, "SA200GTR;{%s};02;\r", Command.KEY_UNIQUE_ID); + case Command.TYPE_OUTPUT_CONTROL: + return formatCommand(command, "SA200CMD;{%s};0{%s};Enable1\r", Command.KEY_UNIQUE_ID, Command.KEY_DATA); case Command.TYPE_ENGINE_STOP: return formatCommand(command, "SA200CMD;{%s};02;Enable1\r", Command.KEY_UNIQUE_ID); case Command.TYPE_ENGINE_RESUME: -- cgit v1.2.3 From 8ed94697f46788d56d71551940b2f4f4778bb9de Mon Sep 17 00:00:00 2001 From: drecchia Date: Tue, 12 Jul 2016 18:42:01 -0300 Subject: - Added new commands. --- src/org/traccar/protocol/SuntechProtocol.java | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/org/traccar/protocol/SuntechProtocol.java b/src/org/traccar/protocol/SuntechProtocol.java index ce0e73280..35d72673c 100644 --- a/src/org/traccar/protocol/SuntechProtocol.java +++ b/src/org/traccar/protocol/SuntechProtocol.java @@ -31,6 +31,9 @@ public class SuntechProtocol extends BaseProtocol { public SuntechProtocol() { super("suntech"); setSupportedCommands( + Command.TYPE_OUTPUT_CONTROL, + Command.TYPE_REBOOT_DEVICE, + Command.TYPE_POSITION_SINGLE, Command.TYPE_ENGINE_STOP, Command.TYPE_ENGINE_RESUME); } -- cgit v1.2.3 From 9c20d2d85c9909b41711e7fe198539dc8cd7d485 Mon Sep 17 00:00:00 2001 From: drecchia Date: Tue, 12 Jul 2016 18:50:31 -0300 Subject: - Fix typpo. --- src/org/traccar/protocol/SuntechProtocolEncoder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/org/traccar/protocol/SuntechProtocolEncoder.java b/src/org/traccar/protocol/SuntechProtocolEncoder.java index 2f66d8d0c..e63637584 100644 --- a/src/org/traccar/protocol/SuntechProtocolEncoder.java +++ b/src/org/traccar/protocol/SuntechProtocolEncoder.java @@ -30,7 +30,7 @@ public class SuntechProtocolEncoder extends StringProtocolEncoder { case Command.TYPE_POSITION_SINGLE: return formatCommand(command, "SA200GTR;{%s};02;\r", Command.KEY_UNIQUE_ID); case Command.TYPE_OUTPUT_CONTROL: - return formatCommand(command, "SA200CMD;{%s};0{%s};Enable1\r", Command.KEY_UNIQUE_ID, Command.KEY_DATA); + return formatCommand(command, "SA200CMD;{%s};0{%s};Enable{%s}\r", Command.KEY_UNIQUE_ID, Command.KEY_DATA); case Command.TYPE_ENGINE_STOP: return formatCommand(command, "SA200CMD;{%s};02;Enable1\r", Command.KEY_UNIQUE_ID); case Command.TYPE_ENGINE_RESUME: -- cgit v1.2.3 From fee6c4709866248e26f63db2fd265deac7edde99 Mon Sep 17 00:00:00 2001 From: drecchia Date: Tue, 12 Jul 2016 18:57:44 -0300 Subject: - Fix number of params. --- src/org/traccar/protocol/SuntechProtocolEncoder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/org/traccar/protocol/SuntechProtocolEncoder.java b/src/org/traccar/protocol/SuntechProtocolEncoder.java index e63637584..86c07c7d2 100644 --- a/src/org/traccar/protocol/SuntechProtocolEncoder.java +++ b/src/org/traccar/protocol/SuntechProtocolEncoder.java @@ -30,7 +30,7 @@ public class SuntechProtocolEncoder extends StringProtocolEncoder { case Command.TYPE_POSITION_SINGLE: return formatCommand(command, "SA200GTR;{%s};02;\r", Command.KEY_UNIQUE_ID); case Command.TYPE_OUTPUT_CONTROL: - return formatCommand(command, "SA200CMD;{%s};0{%s};Enable{%s}\r", Command.KEY_UNIQUE_ID, Command.KEY_DATA); + return formatCommand(command, "SA200CMD;{%s};0{%s};Enable{%s}\r", Command.KEY_UNIQUE_ID, Command.KEY_DATA, Command.KEY_DATA); case Command.TYPE_ENGINE_STOP: return formatCommand(command, "SA200CMD;{%s};02;Enable1\r", Command.KEY_UNIQUE_ID); case Command.TYPE_ENGINE_RESUME: -- cgit v1.2.3 From 80bbc136baf6a91b967732fdae4238f827b9bf19 Mon Sep 17 00:00:00 2001 From: drecchia Date: Wed, 13 Jul 2016 10:41:29 -0300 Subject: - Fixed pull request issues --- src/org/traccar/protocol/SuntechProtocol.java | 2 +- src/org/traccar/protocol/SuntechProtocolEncoder.java | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/org/traccar/protocol/SuntechProtocol.java b/src/org/traccar/protocol/SuntechProtocol.java index 35d72673c..a604a07fd 100644 --- a/src/org/traccar/protocol/SuntechProtocol.java +++ b/src/org/traccar/protocol/SuntechProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2015-2016 Anton Tananaev (anton.tananaev@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/org/traccar/protocol/SuntechProtocolEncoder.java b/src/org/traccar/protocol/SuntechProtocolEncoder.java index 86c07c7d2..aaf4ac50e 100644 --- a/src/org/traccar/protocol/SuntechProtocolEncoder.java +++ b/src/org/traccar/protocol/SuntechProtocolEncoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2015-2016 Anton Tananaev (anton.tananaev@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,8 @@ public class SuntechProtocolEncoder extends StringProtocolEncoder { case Command.TYPE_POSITION_SINGLE: return formatCommand(command, "SA200GTR;{%s};02;\r", Command.KEY_UNIQUE_ID); case Command.TYPE_OUTPUT_CONTROL: - return formatCommand(command, "SA200CMD;{%s};0{%s};Enable{%s}\r", Command.KEY_UNIQUE_ID, Command.KEY_DATA, Command.KEY_DATA); + return formatCommand(command, "SA200CMD;{%s};0{%s};Enable{%s}\r", + Command.KEY_UNIQUE_ID, Command.KEY_DATA, Command.KEY_DATA); case Command.TYPE_ENGINE_STOP: return formatCommand(command, "SA200CMD;{%s};02;Enable1\r", Command.KEY_UNIQUE_ID); case Command.TYPE_ENGINE_RESUME: -- cgit v1.2.3 From e1c811133ba207d2233ac7f9ef531102a91eb4eb Mon Sep 17 00:00:00 2001 From: drecchia Date: Wed, 13 Jul 2016 10:43:22 -0300 Subject: - Removed trailing space. --- src/org/traccar/protocol/SuntechProtocolEncoder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/org/traccar/protocol/SuntechProtocolEncoder.java b/src/org/traccar/protocol/SuntechProtocolEncoder.java index aaf4ac50e..c41cc7ef9 100644 --- a/src/org/traccar/protocol/SuntechProtocolEncoder.java +++ b/src/org/traccar/protocol/SuntechProtocolEncoder.java @@ -30,7 +30,7 @@ public class SuntechProtocolEncoder extends StringProtocolEncoder { case Command.TYPE_POSITION_SINGLE: return formatCommand(command, "SA200GTR;{%s};02;\r", Command.KEY_UNIQUE_ID); case Command.TYPE_OUTPUT_CONTROL: - return formatCommand(command, "SA200CMD;{%s};0{%s};Enable{%s}\r", + return formatCommand(command, "SA200CMD;{%s};0{%s};Enable{%s}\r", Command.KEY_UNIQUE_ID, Command.KEY_DATA, Command.KEY_DATA); case Command.TYPE_ENGINE_STOP: return formatCommand(command, "SA200CMD;{%s};02;Enable1\r", Command.KEY_UNIQUE_ID); -- cgit v1.2.3 From 901c483ac358e5dc38f2014287e5018e79aa7b08 Mon Sep 17 00:00:00 2001 From: drecchia Date: Thu, 14 Jul 2016 13:34:36 -0300 Subject: - Fixed style --- src/org/traccar/protocol/SuntechProtocol.java | 2 +- src/org/traccar/protocol/SuntechProtocolEncoder.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/org/traccar/protocol/SuntechProtocol.java b/src/org/traccar/protocol/SuntechProtocol.java index a604a07fd..4a40e1bfc 100644 --- a/src/org/traccar/protocol/SuntechProtocol.java +++ b/src/org/traccar/protocol/SuntechProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2015 - 2016 Anton Tananaev (anton.tananaev@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/org/traccar/protocol/SuntechProtocolEncoder.java b/src/org/traccar/protocol/SuntechProtocolEncoder.java index c41cc7ef9..708b24e79 100644 --- a/src/org/traccar/protocol/SuntechProtocolEncoder.java +++ b/src/org/traccar/protocol/SuntechProtocolEncoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2015 - 2016 Anton Tananaev (anton.tananaev@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. -- cgit v1.2.3 From 22afcdff52d47e9705c446dc8590deeb6786a701 Mon Sep 17 00:00:00 2001 From: drecchia Date: Fri, 15 Jul 2016 08:22:06 -0300 Subject: - Fixed output control command construction. --- src/org/traccar/protocol/SuntechProtocolEncoder.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/org/traccar/protocol/SuntechProtocolEncoder.java b/src/org/traccar/protocol/SuntechProtocolEncoder.java index 708b24e79..5f6835e92 100644 --- a/src/org/traccar/protocol/SuntechProtocolEncoder.java +++ b/src/org/traccar/protocol/SuntechProtocolEncoder.java @@ -30,8 +30,14 @@ public class SuntechProtocolEncoder extends StringProtocolEncoder { case Command.TYPE_POSITION_SINGLE: return formatCommand(command, "SA200GTR;{%s};02;\r", Command.KEY_UNIQUE_ID); case Command.TYPE_OUTPUT_CONTROL: - return formatCommand(command, "SA200CMD;{%s};0{%s};Enable{%s}\r", - Command.KEY_UNIQUE_ID, Command.KEY_DATA, Command.KEY_DATA); + if (command.getAttributes().containsKey(Command.KEY_DATA)) { + if (command.getAttributes().get(Command.KEY_DATA).equals("1")) { + return formatCommand(command, "SA200CMD;{%s};02;Enable{%s}\r", + Command.KEY_UNIQUE_ID, Command.KEY_INDEX); + } else + return formatCommand(command, "SA200CMD;{%s};02;Disable{%s}\r", + Command.KEY_UNIQUE_ID, Command.KEY_INDEX); + } case Command.TYPE_ENGINE_STOP: return formatCommand(command, "SA200CMD;{%s};02;Enable1\r", Command.KEY_UNIQUE_ID); case Command.TYPE_ENGINE_RESUME: -- cgit v1.2.3