diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-07-29 11:38:49 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-07-29 11:38:49 +1200 |
commit | a10e925a97cf839a5c30fb7891af12bc111b14c4 (patch) | |
tree | 2f81727373e22058c16fb4d9cf48ad374c20f10e | |
parent | 411f631b6a9dd898476b43d342180db02e45dd9c (diff) | |
download | traccar-server-a10e925a97cf839a5c30fb7891af12bc111b14c4.tar.gz traccar-server-a10e925a97cf839a5c30fb7891af12bc111b14c4.tar.bz2 traccar-server-a10e925a97cf839a5c30fb7891af12bc111b14c4.zip |
Update Totem commands
-rw-r--r-- | src/org/traccar/model/Command.java | 4 | ||||
-rw-r--r-- | src/org/traccar/protocol/TotemProtocolEncoder.java | 22 | ||||
-rw-r--r-- | test/org/traccar/protocol/TotemProtocolEncoderTest.java | 8 |
3 files changed, 19 insertions, 15 deletions
diff --git a/src/org/traccar/model/Command.java b/src/org/traccar/model/Command.java index 8c4e3f0f1..defa904f7 100644 --- a/src/org/traccar/model/Command.java +++ b/src/org/traccar/model/Command.java @@ -25,11 +25,11 @@ public class Command implements Factory { public static final String TYPE_POSITION_STOP = "positionStop"; public static final String TYPE_POSITION_FIX = "positionFix"; public static final String TYPE_ENGINE_STOP = "engineStop"; - public static final String TYPE_ENGINE_RESUME = "engineResume"; + public static final String TYPE_ENGINE_RESUME = "engineResume"; public static final String KEY_UNIQUE_ID = "uniqueId"; public static final String KEY_FREQUENCY = "frequency"; - public static final String KEY_GPS_PASSWORD = "gpsPassword"; + public static final String KEY_DEVICE_PASSWORD = "devicePassword"; } diff --git a/src/org/traccar/protocol/TotemProtocolEncoder.java b/src/org/traccar/protocol/TotemProtocolEncoder.java index d236a7e2c..39e3214cc 100644 --- a/src/org/traccar/protocol/TotemProtocolEncoder.java +++ b/src/org/traccar/protocol/TotemProtocolEncoder.java @@ -1,5 +1,6 @@ /* - * Copyright 2015 alexis. + * Copyright 2015 Irving Gonzalez + * Copyright 2015 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. @@ -18,21 +19,28 @@ package org.traccar.protocol; import org.traccar.StringProtocolEncoder; import org.traccar.model.Command; -/** - * - * @author Irving Gonzalez [ialexis93@gmail.com] - */ +import java.util.HashMap; +import java.util.Map; + public class TotemProtocolEncoder extends StringProtocolEncoder{ @Override protected Object encodeCommand(Command command) { + + // Temporary put default password + Map<String, Object> other = command.getOther(); + if (other == null) { + other = new HashMap<>(); + command.setOther(other); + } + other.put(Command.KEY_DEVICE_PASSWORD, "000000"); switch (command.getType()) { //Assuming PIN 8 (Output C) is the power wire, like manual says but it can be PIN 5,7,8 case Command.TYPE_ENGINE_STOP: - return formatCommand(command, "*{%s},025,C,1#", Command.KEY_GPS_PASSWORD); + return formatCommand(command, "*{%s},025,C,1#", Command.KEY_DEVICE_PASSWORD); case Command.TYPE_ENGINE_RESUME: - return formatCommand(command, "*{%s},025,C,0#", Command.KEY_GPS_PASSWORD); + return formatCommand(command, "*{%s},025,C,0#", Command.KEY_DEVICE_PASSWORD); } return null; diff --git a/test/org/traccar/protocol/TotemProtocolEncoderTest.java b/test/org/traccar/protocol/TotemProtocolEncoderTest.java index 365173bd2..ce5574bb1 100644 --- a/test/org/traccar/protocol/TotemProtocolEncoderTest.java +++ b/test/org/traccar/protocol/TotemProtocolEncoderTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 alexis. + * Copyright 2015 Irving Gonzalez * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,10 +21,6 @@ import org.junit.Assert; import org.junit.Test; import org.traccar.model.Command; -/** - * - * @author alexis - */ public class TotemProtocolEncoderTest { @Test public void testDecode() throws Exception { @@ -36,7 +32,7 @@ public class TotemProtocolEncoderTest { command.setType(Command.TYPE_ENGINE_STOP); Map<String, Object> other = new HashMap<>(); - other.put(Command.KEY_GPS_PASSWORD, "000000"); + other.put(Command.KEY_DEVICE_PASSWORD, "000000"); command.setOther(other); |