diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-08-06 10:34:41 +0300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2016-08-06 10:34:41 +0300 |
commit | b8b330317dbac78c2d0a007a195efd8d42b3e791 (patch) | |
tree | 38eae134fac5b9b549a6fdf06c0e3490b8f0b1e1 | |
parent | 08e058e868566e44a8e955fa8d18bdae5630ecec (diff) | |
download | trackermap-server-b8b330317dbac78c2d0a007a195efd8d42b3e791.tar.gz trackermap-server-b8b330317dbac78c2d0a007a195efd8d42b3e791.tar.bz2 trackermap-server-b8b330317dbac78c2d0a007a195efd8d42b3e791.zip |
Support temperature for TK103 protocol
-rw-r--r-- | src/org/traccar/protocol/Tk103ProtocolDecoder.java | 7 | ||||
-rw-r--r-- | test/org/traccar/protocol/Tk103ProtocolDecoderTest.java | 6 |
2 files changed, 12 insertions, 1 deletions
diff --git a/src/org/traccar/protocol/Tk103ProtocolDecoder.java b/src/org/traccar/protocol/Tk103ProtocolDecoder.java index 55a41f5a2..ac99a1440 100644 --- a/src/org/traccar/protocol/Tk103ProtocolDecoder.java +++ b/src/org/traccar/protocol/Tk103ProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 - 2015 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2012 - 2016 Anton Tananaev (anton.tananaev@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -51,6 +51,7 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder { .number("(?:([01]{8})|(x{8}))?,?") // state .number("(?:L(x+))?") // odometer .any() + .number("([+-]ddd.d)?") // temperature .text(")").optional() .compile(); @@ -225,6 +226,10 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_ODOMETER, parser.nextLong(16)); } + if (parser.hasNext()) { + position.set(Position.PREFIX_TEMP + 1, parser.nextDouble()); + } + return position; } diff --git a/test/org/traccar/protocol/Tk103ProtocolDecoderTest.java b/test/org/traccar/protocol/Tk103ProtocolDecoderTest.java index b15d7894e..c1bf148bc 100644 --- a/test/org/traccar/protocol/Tk103ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Tk103ProtocolDecoderTest.java @@ -10,6 +10,12 @@ public class Tk103ProtocolDecoderTest extends ProtocolTest { Tk103ProtocolDecoder decoder = new Tk103ProtocolDecoder(new Tk103Protocol()); + verifyPosition(decoder, text( + "(088046338039BR00160727A3354.7768N03540.7258E000.0140832068.4700000000L00BEB0D4+017.7)")); + + verifyPosition(decoder, text( + "(088046338039BP05000088046338039160727A3354.7768N03540.7258E000.0140309065.1000000000L00BEB0D4+017.3)")); + verifyAttributes(decoder, text( "(013632651491,ZC20,180716,144222,6,392,65535,255")); |