diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2018-04-20 15:44:50 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2018-04-20 15:44:50 +1200 |
commit | 184f9bb3ffa4015836ca6c67552771a4a901c15e (patch) | |
tree | 75fee04a5d778862f2a21b37e6ce484c539b1cdb /src/org/traccar/protocol | |
parent | 773768093c6c78906e54abe128cb1b4ca9430313 (diff) | |
download | trackermap-server-184f9bb3ffa4015836ca6c67552771a4a901c15e.tar.gz trackermap-server-184f9bb3ffa4015836ca6c67552771a4a901c15e.tar.bz2 trackermap-server-184f9bb3ffa4015836ca6c67552771a4a901c15e.zip |
Decode additional P60 parameters
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r-- | src/org/traccar/protocol/Pt60ProtocolDecoder.java | 49 | ||||
-rw-r--r-- | src/org/traccar/protocol/WatchProtocolDecoder.java | 2 |
2 files changed, 43 insertions, 8 deletions
diff --git a/src/org/traccar/protocol/Pt60ProtocolDecoder.java b/src/org/traccar/protocol/Pt60ProtocolDecoder.java index c87c22c5f..26f07a0a9 100644 --- a/src/org/traccar/protocol/Pt60ProtocolDecoder.java +++ b/src/org/traccar/protocol/Pt60ProtocolDecoder.java @@ -34,16 +34,19 @@ public class Pt60ProtocolDecoder extends BaseProtocolDecoder { super(protocol); } + public static final int MSG_TRACK = 6; + public static final int MSG_STEP_COUNT = 13; + public static final int MSG_HEART_RATE = 14; + private static final Pattern PATTERN = new PatternBuilder() .text("@G#@,") // header .number("Vdd,") // protocol version - .number("d,") // type + .number("(d+),") // type .number("(d+),") // imei .number("(d+),") // imsi .number("(dddd)(dd)(dd)") // date (yyyymmdd) .number("(dd)(dd)(dd),") // time (hhmmss) - .number("(-?d+.d+);") // latitude - .number("(-?d+.d+),") // longitude + .expression("(.*)") // data .compile(); private void sendResponse(Channel channel) { @@ -64,6 +67,12 @@ public class Pt60ProtocolDecoder extends BaseProtocolDecoder { return null; } + int type = parser.nextInt(); + + if (type != MSG_TRACK && type != MSG_STEP_COUNT && type != MSG_HEART_RATE) { + return null; + } + Position position = new Position(getProtocolName()); DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next(), parser.next()); @@ -72,10 +81,36 @@ public class Pt60ProtocolDecoder extends BaseProtocolDecoder { } position.setDeviceId(deviceSession.getDeviceId()); - position.setValid(true); - position.setTime(parser.nextDateTime()); - position.setLatitude(parser.nextDouble()); - position.setLongitude(parser.nextDouble()); + position.setDeviceTime(parser.nextDateTime()); + + String[] values = parser.next().split(","); + + if (type == MSG_TRACK) { + + position.setValid(true); + position.setFixTime(position.getDeviceTime()); + + String[] coordinates = values[0].split(";"); + position.setLatitude(Double.parseDouble(coordinates[0])); + position.setLongitude(Double.parseDouble(coordinates[1])); + + } else { + + getLastLocation(position, position.getDeviceTime()); + + switch (type) { + case MSG_STEP_COUNT: + position.set(Position.KEY_STEPS, Integer.parseInt(values[0])); + break; + case MSG_HEART_RATE: + position.set(Position.KEY_HEART_RATE, Integer.parseInt(values[0])); + position.set(Position.KEY_BATTERY, Integer.parseInt(values[1])); + break; + default: + break; + } + + } return position; } diff --git a/src/org/traccar/protocol/WatchProtocolDecoder.java b/src/org/traccar/protocol/WatchProtocolDecoder.java index b58c3b6a1..f55b6f7be 100644 --- a/src/org/traccar/protocol/WatchProtocolDecoder.java +++ b/src/org/traccar/protocol/WatchProtocolDecoder.java @@ -273,7 +273,7 @@ public class WatchProtocolDecoder extends BaseProtocolDecoder { position.set("pressureHigh", values[valueIndex++]); position.set("pressureLow", values[valueIndex++]); } - position.set("pulse", values[valueIndex]); + position.set(Position.KEY_HEART_RATE, Integer.parseInt(values[valueIndex])); return position; |