From 4022d0c0e4166716b6b20063de4daf5631c4579b Mon Sep 17 00:00:00 2001 From: Gavriel Fleischer Date: Mon, 14 Jan 2019 19:54:56 +0200 Subject: added message sending to WatchProtocol --- src/org/traccar/protocol/WatchProtocol.java | 1 + src/org/traccar/protocol/WatchProtocolEncoder.java | 4 ++++ 2 files changed, 5 insertions(+) (limited to 'src/org/traccar/protocol') 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: -- cgit v1.2.3