aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/H02ProtocolEncoder.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/protocol/H02ProtocolEncoder.java')
-rw-r--r--src/org/traccar/protocol/H02ProtocolEncoder.java26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/org/traccar/protocol/H02ProtocolEncoder.java b/src/org/traccar/protocol/H02ProtocolEncoder.java
index 302773eaa..0b41b9c93 100644
--- a/src/org/traccar/protocol/H02ProtocolEncoder.java
+++ b/src/org/traccar/protocol/H02ProtocolEncoder.java
@@ -23,20 +23,15 @@ import org.traccar.model.Command;
public class H02ProtocolEncoder extends StringProtocolEncoder {
- DateTime getActualDateTime() {
- return new DateTime(DateTimeZone.UTC);
- }
-
- private Object formatCommand(String uniqueId, String cmd, String... params) {
+ private Object formatCommand(DateTime dt, String uniqueId, String cmd, String... params) {
- DateTime now = getActualDateTime();
String result = String.format(
"*HQ,%s,%s,%02d%02d%02d",
uniqueId,
cmd,
- now.getHourOfDay(),
- now.getMinuteOfHour(),
- now.getSecondOfMinute()
+ dt.getHourOfDay(),
+ dt.getMinuteOfHour(),
+ dt.getSecondOfMinute()
);
for(String param : params) {
@@ -48,15 +43,14 @@ public class H02ProtocolEncoder extends StringProtocolEncoder {
return result;
}
- @Override
- protected Object encodeCommand(Command command) {
+ protected Object encodeCommand(Command command, DateTime dt) {
String uniqueId = getUniqueId(command.getDeviceId());
switch (command.getType()) {
case Command.TYPE_ALARM_ARM:
- return formatCommand(uniqueId, "SCF", "0", "0");
+ return formatCommand(dt, uniqueId, "SCF", "0", "0");
case Command.TYPE_ALARM_DISARM:
- return formatCommand(uniqueId, "SCF", "1", "1");
+ return formatCommand(dt, uniqueId, "SCF", "1", "1");
default:
Log.warning(new UnsupportedOperationException(command.getType()));
break;
@@ -64,4 +58,10 @@ public class H02ProtocolEncoder extends StringProtocolEncoder {
return null;
}
+
+ @Override
+ protected Object encodeCommand(Command command) {
+ DateTime dt = new DateTime(DateTimeZone.UTC);
+ return encodeCommand(command, dt);
+ }
}