aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-03-25 20:27:43 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2017-03-25 20:27:43 +1300
commit511a7adb8bb39d1523b2f366c2288b2d0cb8b9a9 (patch)
tree4dec908eabbee8c5dc6ad50562b96f37ed10282b
parentf940d94548f45de9ece8195028abf4bafb979135 (diff)
downloadtrackermap-server-511a7adb8bb39d1523b2f366c2288b2d0cb8b9a9.tar.gz
trackermap-server-511a7adb8bb39d1523b2f366c2288b2d0cb8b9a9.tar.bz2
trackermap-server-511a7adb8bb39d1523b2f366c2288b2d0cb8b9a9.zip
Adjustments to Telic decoder
-rw-r--r--src/org/traccar/protocol/TelicProtocolDecoder.java13
-rw-r--r--test/org/traccar/protocol/TelicProtocolDecoderTest.java6
2 files changed, 14 insertions, 5 deletions
diff --git a/src/org/traccar/protocol/TelicProtocolDecoder.java b/src/org/traccar/protocol/TelicProtocolDecoder.java
index f6be15cce..bbd4b0574 100644
--- a/src/org/traccar/protocol/TelicProtocolDecoder.java
+++ b/src/org/traccar/protocol/TelicProtocolDecoder.java
@@ -50,11 +50,11 @@ public class TelicProtocolDecoder extends BaseProtocolDecoder {
.number("(d),") // validity
.number("(d+),") // speed
.number("(d+),") // course
- .number("(d+),") // satellites
+ .number("(d+)?,") // satellites
.expression("(?:[^,]*,){7}")
.number("(d+),") // battery
.expression("[^,]*,")
- .number("(d+),") // external
+ .number("(d+)") // external
.any()
.compile();
@@ -125,9 +125,12 @@ public class TelicProtocolDecoder extends BaseProtocolDecoder {
position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
position.setCourse(parser.nextDouble());
- position.set(Position.KEY_SATELLITES, parser.next());
- position.set(Position.KEY_BATTERY, 3.4 + parser.nextInt() * 0.00345);
- position.set(Position.KEY_POWER, 6.0 + parser.nextInt() * 0.125);
+ if (parser.hasNext()) {
+ position.set(Position.KEY_SATELLITES, parser.nextInt());
+ }
+
+ position.set(Position.KEY_BATTERY, parser.nextInt());
+ position.set(Position.KEY_POWER, parser.nextInt());
return position;
}
diff --git a/test/org/traccar/protocol/TelicProtocolDecoderTest.java b/test/org/traccar/protocol/TelicProtocolDecoderTest.java
index f473bc8d5..6c3c30fea 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(
+ "232027997498,230317083900,0,230317083900,260105,444112,3,22,259,,,,111,61110817,226,01,00,255,218,00000000000000"));
+
+ verifyPosition(decoder, text(
+ "072027997498,230317082635,0,230317082635,260332,444265,3,28,165,,,,124,61107582,226,01,00,255,219,00000000000000"));
+
verifyNothing(decoder, text(
"0026203393|226|10|002004010"));