aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-03-29 04:58:23 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2017-03-29 04:58:23 +1300
commit9879e67c1f522fe6940b7a3ca5fde5c93875dcfb (patch)
tree11f2a64b612191a1cfa3ee294b113aa11d9335b1
parentb7d5d53ead8eb8f7dbe6e04cdee76ea2c05c1dbe (diff)
downloadtraccar-server-9879e67c1f522fe6940b7a3ca5fde5c93875dcfb.tar.gz
traccar-server-9879e67c1f522fe6940b7a3ca5fde5c93875dcfb.tar.bz2
traccar-server-9879e67c1f522fe6940b7a3ca5fde5c93875dcfb.zip
Handle no power value from Telic
-rw-r--r--src/org/traccar/protocol/TelicProtocolDecoder.java9
-rw-r--r--test/org/traccar/protocol/TelicProtocolDecoderTest.java6
2 files changed, 13 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/TelicProtocolDecoder.java b/src/org/traccar/protocol/TelicProtocolDecoder.java
index bbd4b0574..8207e5956 100644
--- a/src/org/traccar/protocol/TelicProtocolDecoder.java
+++ b/src/org/traccar/protocol/TelicProtocolDecoder.java
@@ -54,7 +54,7 @@ public class TelicProtocolDecoder extends BaseProtocolDecoder {
.expression("(?:[^,]*,){7}")
.number("(d+),") // battery
.expression("[^,]*,")
- .number("(d+)") // external
+ .number("(d+)?") // external
.any()
.compile();
@@ -83,6 +83,8 @@ public class TelicProtocolDecoder extends BaseProtocolDecoder {
@Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
+ org.traccar.helper.PatternUtil.MatchResult matchResult =
+ org.traccar.helper.PatternUtil.checkPattern(PATTERN.pattern(), (String) msg);
Parser parser = new Parser(PATTERN, (String) msg);
if (!parser.matches()) {
@@ -130,7 +132,10 @@ public class TelicProtocolDecoder extends BaseProtocolDecoder {
}
position.set(Position.KEY_BATTERY, parser.nextInt());
- position.set(Position.KEY_POWER, parser.nextInt());
+
+ if (parser.hasNext()) {
+ 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 6c3c30fea..66ad3db79 100644
--- a/test/org/traccar/protocol/TelicProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/TelicProtocolDecoderTest.java
@@ -11,6 +11,12 @@ public class TelicProtocolDecoderTest extends ProtocolTest {
TelicProtocolDecoder decoder = new TelicProtocolDecoder(new TelicProtocol());
verifyPosition(decoder, text(
+ "092020621198,280317084155,0,280317084156,259762,444356,3,42,278,9,,,89,56793311,,0110,00,67,0,,0400"));
+
+ verifyPosition(decoder, text(
+ "502091227598,280317084149,0,280317084149,261756,444358,3,33,286,9,,,77,3143031,,0010,00,171,240,0,0406"));
+
+ verifyPosition(decoder, text(
"232027997498,230317083900,0,230317083900,260105,444112,3,22,259,,,,111,61110817,226,01,00,255,218,00000000000000"));
verifyPosition(decoder, text(