From 06a746b44dae69b0c84a5302f92a1bcbe2dc827f Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Thu, 2 Jun 2016 13:47:51 +1200 Subject: Properly decode Telic info (fix #1735) --- src/org/traccar/protocol/TelicProtocolDecoder.java | 6 ++++-- test/org/traccar/protocol/TelicProtocolDecoderTest.java | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/org/traccar/protocol/TelicProtocolDecoder.java b/src/org/traccar/protocol/TelicProtocolDecoder.java index 812aeec0a..b8929fae5 100644 --- a/src/org/traccar/protocol/TelicProtocolDecoder.java +++ b/src/org/traccar/protocol/TelicProtocolDecoder.java @@ -51,7 +51,8 @@ public class TelicProtocolDecoder extends BaseProtocolDecoder { .number("(d+),") // course .number("(d+),") // satellites .expression("(?:[^,]*,){7}") - .number("(d+),") + .number("(d+),") // battery + .number("(d+),") // external .any() .compile(); @@ -94,7 +95,8 @@ public class TelicProtocolDecoder extends BaseProtocolDecoder { position.setCourse(parser.nextDouble()); position.set(Position.KEY_SATELLITES, parser.next()); - position.set(Position.KEY_BATTERY, parser.nextInt()); + position.set(Position.KEY_BATTERY, 3.4 + parser.nextInt() * 0.00345); + position.set(Position.KEY_POWER, 6.0 + parser.nextInt() * 0.125); return position; } diff --git a/test/org/traccar/protocol/TelicProtocolDecoderTest.java b/test/org/traccar/protocol/TelicProtocolDecoderTest.java index a922c390d..79ec0aa68 100644 --- a/test/org/traccar/protocol/TelicProtocolDecoderTest.java +++ b/test/org/traccar/protocol/TelicProtocolDecoderTest.java @@ -10,6 +10,12 @@ public class TelicProtocolDecoderTest extends ProtocolTest { TelicProtocolDecoder decoder = new TelicProtocolDecoder(new TelicProtocol()); + verifyPosition(decoder, text( + "003097061325,210216112630,0,210216001405,246985,594078,3,0,283,12,,,23,4418669,,0010,00,117,0,0,0108")); + + verifyPosition(decoder, text( + "592078222222,010100030200,0,240516133500,222222,222222,3,0,0,5,,,37,324,,1010,00,48,0,0,0406")); + verifyPosition(decoder, text( "002017297899,220216111100,0,220216111059,014306446,46626713,3,7,137,7,,,448,266643,,0000,00,0,206,0,0407")); -- cgit v1.2.3