From 71a9d9f6df3bc0ef17bcb834487838b94d989a74 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 26 Jun 2017 15:45:04 +1200 Subject: Support watch audio file --- src/org/traccar/model/Position.java | 2 +- src/org/traccar/protocol/WatchProtocolDecoder.java | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/org/traccar/model/Position.java b/src/org/traccar/model/Position.java index bf2518c3c..2198d3b24 100644 --- a/src/org/traccar/model/Position.java +++ b/src/org/traccar/model/Position.java @@ -39,7 +39,7 @@ public class Position extends Message { public static final String KEY_OUTPUT = "output"; public static final String KEY_IMAGE = "image"; public static final String KEY_VIDEO = "video"; - public static final String KEY_SOUND = "sound"; + public static final String KEY_AUDIO = "audio"; // The units for the below four KEYs currently vary. // The preferred units of measure are specified in the comment for each. diff --git a/src/org/traccar/protocol/WatchProtocolDecoder.java b/src/org/traccar/protocol/WatchProtocolDecoder.java index d0c066954..57f5d7e78 100644 --- a/src/org/traccar/protocol/WatchProtocolDecoder.java +++ b/src/org/traccar/protocol/WatchProtocolDecoder.java @@ -222,15 +222,20 @@ public class WatchProtocolDecoder extends BaseProtocolDecoder { } else if (type.equals("PULSE") || type.equals("heart")) { if (buf.readable()) { + Position position = new Position(); position.setProtocol(getProtocolName()); position.setDeviceId(deviceSession.getDeviceId()); + getLastLocation(position, new Date()); + position.setValid(false); String pulse = buf.toString(StandardCharsets.US_ASCII); position.set("pulse", pulse); position.set(Position.KEY_RESULT, pulse); + return position; + } } else if (type.equals("img")) { @@ -247,6 +252,18 @@ public class WatchProtocolDecoder extends BaseProtocolDecoder { return position; + } else if (type.equals("TK")) { + + Position position = new Position(); + position.setProtocol(getProtocolName()); + position.setDeviceId(deviceSession.getDeviceId()); + + getLastLocation(position, null); + + position.set(Position.KEY_AUDIO, Context.getMediaManager().writeFile(id, buf, "amr")); + + return position; + } return null; -- cgit v1.2.3