aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-03-22 13:52:26 -0700
committerAnton Tananaev <anton@traccar.org>2022-03-22 13:52:26 -0700
commitf5033ee29a955796fb4c911f83e3d8253c98e62e (patch)
tree1e7728dbc05d118e3247e5267a600d28d76368ec /src
parenta9e3ac7b143e848398fda8f8fb06709d334b6212 (diff)
downloadtrackermap-server-f5033ee29a955796fb4c911f83e3d8253c98e62e.tar.gz
trackermap-server-f5033ee29a955796fb4c911f83e3d8253c98e62e.tar.bz2
trackermap-server-f5033ee29a955796fb4c911f83e3d8253c98e62e.zip
Handle Wialon missing data
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/protocol/WialonProtocolDecoder.java14
-rw-r--r--src/test/java/org/traccar/protocol/WialonProtocolDecoderTest.java3
2 files changed, 12 insertions, 5 deletions
diff --git a/src/main/java/org/traccar/protocol/WialonProtocolDecoder.java b/src/main/java/org/traccar/protocol/WialonProtocolDecoder.java
index 80299ff08..19d9dd6c8 100644
--- a/src/main/java/org/traccar/protocol/WialonProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/WialonProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 - 2021 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2022 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -47,13 +47,13 @@ public class WialonProtocolDecoder extends BaseProtocolDecoder {
.compile();
private static final Pattern PATTERN = new PatternBuilder()
- .number("(dd)(dd)(dd);") // date (ddmmyy)
- .number("(dd)(dd)(dd);") // time (hhmmss)
+ .number("(?:NA|(dd)(dd)(dd));") // date (ddmmyy)
+ .number("(?:NA|(dd)(dd)(dd));") // time (hhmmss)
.number("(?:NA|(dd)(dd.d+));") // latitude
.expression("(?:NA|([NS]));")
.number("(?:NA|(ddd)(dd.d+));") // longitude
.expression("(?:NA|([EW]));")
- .number("(d+.?d*)?;") // speed
+ .number("(?:NA|(d+.?d*))?;") // speed
.number("(?:NA|(d+.?d*))?;") // course
.number("(?:NA|(-?d+.?d*));") // altitude
.number("(?:NA|(d+))") // satellites
@@ -95,7 +95,11 @@ public class WialonProtocolDecoder extends BaseProtocolDecoder {
Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
- position.setTime(parser.nextDateTime(Parser.DateTimeFormat.DMY_HMS));
+ if (parser.hasNext(6)) {
+ position.setTime(parser.nextDateTime(Parser.DateTimeFormat.DMY_HMS));
+ } else {
+ position.setTime(new Date());
+ }
if (parser.hasNext(9)) {
position.setLatitude(parser.nextCoordinate());
diff --git a/src/test/java/org/traccar/protocol/WialonProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/WialonProtocolDecoderTest.java
index 7387f5325..12724c32f 100644
--- a/src/test/java/org/traccar/protocol/WialonProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/WialonProtocolDecoderTest.java
@@ -14,6 +14,9 @@ public class WialonProtocolDecoderTest extends ProtocolTest {
"#L#2.0;42001300083;;CE45"));
verifyAttributes(decoder, text(
+ "#D#NA;NA;5429.681944502211763;N;02654.60403650999069;E;NA;NA;NA;NA;NA;NA;NA;1.0;NA;m1:1:9196679,d1:1:15397,t1:1:20,b1:1:162,fuel1:2:21588.0,pv1:2:35.98,finish:1:1;0x9b0"));
+
+ verifyAttributes(decoder, text(
"#D#120319;112003;NA;NA;NA;NA;0.000;NA;NA;0;NA;NA;NA;NA;NA;101_521347:1:521246,101_158:1:510,101_521055:1:510,101_521055_2.9:1:509,101_521056:1:3;626B"));
verifyNull(decoder, text(