From b4185cbf84bdff2927f7d9a8b0cde9f4ea889353 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Fri, 9 Sep 2016 15:32:20 +0500 Subject: Store pulse for watch protocol --- src/org/traccar/protocol/WatchProtocolDecoder.java | 11 +++++++++++ test/org/traccar/protocol/WatchProtocolDecoderTest.java | 3 +++ 2 files changed, 14 insertions(+) diff --git a/src/org/traccar/protocol/WatchProtocolDecoder.java b/src/org/traccar/protocol/WatchProtocolDecoder.java index 326552e7f..488d05a3c 100644 --- a/src/org/traccar/protocol/WatchProtocolDecoder.java +++ b/src/org/traccar/protocol/WatchProtocolDecoder.java @@ -25,6 +25,7 @@ import org.traccar.helper.UnitsConverter; import org.traccar.model.Position; import java.net.SocketAddress; +import java.util.Date; import java.util.regex.Pattern; public class WatchProtocolDecoder extends BaseProtocolDecoder { @@ -146,6 +147,16 @@ public class WatchProtocolDecoder extends BaseProtocolDecoder { sendResponse(channel, manufacturer, id, "TKQ"); + } else if (type.equals("PULSE")) { + + Position position = new Position(); + position.setProtocol(getProtocolName()); + position.setDeviceId(deviceSession.getDeviceId()); + getLastLocation(position, new Date()); + position.setValid(false); + position.set("pulse", content.split(",")[1]); + return position; + } return null; diff --git a/test/org/traccar/protocol/WatchProtocolDecoderTest.java b/test/org/traccar/protocol/WatchProtocolDecoderTest.java index a8f7b12bc..6116c2c2b 100644 --- a/test/org/traccar/protocol/WatchProtocolDecoderTest.java +++ b/test/org/traccar/protocol/WatchProtocolDecoderTest.java @@ -54,6 +54,9 @@ public class WatchProtocolDecoderTest extends ProtocolTest { verifyPosition(decoder, text( "[SG*8800000015*0087*AL,220414,134652,A,22.571707,N,113.8613968,E,0.1,0.0,100,7,60,90,1000,50,0001,4,1,460,0,9360,4082,131,9360,4092,148,9360,4091,143,9360,4153,141")); + verifyAttributes(decoder, text( + "[CS*8800000015*0008*PULSE,72")); + } } -- cgit v1.2.3 From 91cc83f8d09f7ee591c9109e61cee6492226a612 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Fri, 9 Sep 2016 16:37:24 +0500 Subject: Also store "result" --- src/org/traccar/protocol/WatchProtocolDecoder.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/org/traccar/protocol/WatchProtocolDecoder.java b/src/org/traccar/protocol/WatchProtocolDecoder.java index 488d05a3c..d74fdbe81 100644 --- a/src/org/traccar/protocol/WatchProtocolDecoder.java +++ b/src/org/traccar/protocol/WatchProtocolDecoder.java @@ -154,7 +154,9 @@ public class WatchProtocolDecoder extends BaseProtocolDecoder { position.setDeviceId(deviceSession.getDeviceId()); getLastLocation(position, new Date()); position.setValid(false); - position.set("pulse", content.split(",")[1]); + String pulse = content.substring(1); + position.set("pulse", pulse); + position.set(Position.KEY_RESULT, pulse); return position; } -- cgit v1.2.3