aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2019-01-14 11:19:26 -0800
committerGitHub <noreply@github.com>2019-01-14 11:19:26 -0800
commitff0572b84c85f2bcfb177d1fe7a119a6dc51627a (patch)
tree3051f972ec54f9243467947e1d7091ecbb2eefd6
parent4650b7f1c866c9471a7ae79eb355256976d4b6c5 (diff)
parent872f672e7832da3755cb7576f04dd2aec4132bd5 (diff)
downloadtraccar-server-ff0572b84c85f2bcfb177d1fe7a119a6dc51627a.tar.gz
traccar-server-ff0572b84c85f2bcfb177d1fe7a119a6dc51627a.tar.bz2
traccar-server-ff0572b84c85f2bcfb177d1fe7a119a6dc51627a.zip
Merge pull request #4192 from flocsy/send-message
Send message (that is displayed on the watch's display)
-rw-r--r--src/org/traccar/helper/Log.java2
-rw-r--r--src/org/traccar/model/Command.java1
-rw-r--r--src/org/traccar/protocol/WatchProtocol.java1
-rw-r--r--src/org/traccar/protocol/WatchProtocolEncoder.java4
-rw-r--r--test/org/traccar/protocol/WatchProtocolEncoderTest.java6
5 files changed, 13 insertions, 1 deletions
diff --git a/src/org/traccar/helper/Log.java b/src/org/traccar/helper/Log.java
index 6f5a875bc..df0c9abc1 100644
--- a/src/org/traccar/helper/Log.java
+++ b/src/org/traccar/helper/Log.java
@@ -66,7 +66,7 @@ public final class Log {
writer.close();
writer = null;
if (!new File(name).renameTo(new File(name + "." + this.suffix))) {
- throw new RuntimeException("Log file renaiming failed");
+ throw new RuntimeException("Log file renaming failed");
}
}
}
diff --git a/src/org/traccar/model/Command.java b/src/org/traccar/model/Command.java
index d50a66b36..336fc61f4 100644
--- a/src/org/traccar/model/Command.java
+++ b/src/org/traccar/model/Command.java
@@ -40,6 +40,7 @@ public class Command extends Message implements Cloneable {
public static final String TYPE_SOS_NUMBER = "sosNumber";
public static final String TYPE_SILENCE_TIME = "silenceTime";
public static final String TYPE_SET_PHONEBOOK = "setPhonebook";
+ public static final String TYPE_MESSAGE = "message";
public static final String TYPE_VOICE_MESSAGE = "voiceMessage";
public static final String TYPE_OUTPUT_CONTROL = "outputControl";
public static final String TYPE_VOICE_MONITORING = "voiceMonitoring";
diff --git a/src/org/traccar/protocol/WatchProtocol.java b/src/org/traccar/protocol/WatchProtocol.java
index 926d2826d..5d923106d 100644
--- a/src/org/traccar/protocol/WatchProtocol.java
+++ b/src/org/traccar/protocol/WatchProtocol.java
@@ -37,6 +37,7 @@ public class WatchProtocol extends BaseProtocol {
Command.TYPE_SILENCE_TIME,
Command.TYPE_ALARM_CLOCK,
Command.TYPE_SET_PHONEBOOK,
+ Command.TYPE_MESSAGE,
Command.TYPE_VOICE_MESSAGE,
Command.TYPE_SET_TIMEZONE,
Command.TYPE_SET_INDICATOR);
diff --git a/src/org/traccar/protocol/WatchProtocolEncoder.java b/src/org/traccar/protocol/WatchProtocolEncoder.java
index 17952e3cd..f66ba4072 100644
--- a/src/org/traccar/protocol/WatchProtocolEncoder.java
+++ b/src/org/traccar/protocol/WatchProtocolEncoder.java
@@ -36,6 +36,8 @@ public class WatchProtocolEncoder extends StringProtocolEncoder implements Strin
double offset = TimeZone.getTimeZone((String) value).getRawOffset() / 3600000.0;
DecimalFormat fmt = new DecimalFormat("+#.##;-#.##", DecimalFormatSymbols.getInstance(Locale.US));
return fmt.format(offset);
+ } else if (key.equals(Command.KEY_MESSAGE)) {
+ return DataConverter.printHex(value.toString().getBytes());
}
return null;
@@ -134,6 +136,8 @@ public class WatchProtocolEncoder extends StringProtocolEncoder implements Strin
return formatCommand(channel, command, "REMIND,{%s}", Command.KEY_DATA);
case Command.TYPE_SET_PHONEBOOK:
return formatCommand(channel, command, "PHB,{%s}", Command.KEY_DATA);
+ case Command.TYPE_MESSAGE:
+ return formatCommand(channel, command, "MESSAGE,{%s}", Command.KEY_MESSAGE);
case Command.TYPE_VOICE_MESSAGE:
return formatCommand(channel, command, "TK,%s", getBinaryData(command));
case Command.TYPE_POSITION_PERIODIC:
diff --git a/test/org/traccar/protocol/WatchProtocolEncoderTest.java b/test/org/traccar/protocol/WatchProtocolEncoderTest.java
index 9b9e68cdb..e088a2b04 100644
--- a/test/org/traccar/protocol/WatchProtocolEncoderTest.java
+++ b/test/org/traccar/protocol/WatchProtocolEncoderTest.java
@@ -41,6 +41,12 @@ public class WatchProtocolEncoderTest extends ProtocolTest {
command = new Command();
command.setDeviceId(1);
+ command.setType(Command.TYPE_MESSAGE);
+ command.set(Command.KEY_MESSAGE, "text");
+ assertEquals("[CS*123456789012345*0010*MESSAGE,74657874]", encoder.encodeCommand(null, command));
+
+ command = new Command();
+ command.setDeviceId(1);
command.setType(Command.TYPE_CUSTOM);
command.set(Command.KEY_DATA, "WORK,6-9,11-13,13-15,17-19");
assertEquals("[CS*123456789012345*001a*WORK,6-9,11-13,13-15,17-19]", encoder.encodeCommand(null, command));