aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-06-17 20:56:05 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2020-06-17 20:56:05 -0700
commitf43c8f976e9dc22847ce7afd827f587e47c89d73 (patch)
treed7bde1ee91fbd691441b3cda281ff64bcc7c7f29
parent65a39217ea14ef266a042c284189ac13a43b20c5 (diff)
downloadtrackermap-server-f43c8f976e9dc22847ce7afd827f587e47c89d73.tar.gz
trackermap-server-f43c8f976e9dc22847ce7afd827f587e47c89d73.tar.bz2
trackermap-server-f43c8f976e9dc22847ce7afd827f587e47c89d73.zip
Handle spaces in TK103 protocol
-rw-r--r--src/main/java/org/traccar/protocol/Tk103ProtocolDecoder.java18
-rw-r--r--src/test/java/org/traccar/protocol/Tk103ProtocolDecoderTest.java3
2 files changed, 12 insertions, 9 deletions
diff --git a/src/main/java/org/traccar/protocol/Tk103ProtocolDecoder.java b/src/main/java/org/traccar/protocol/Tk103ProtocolDecoder.java
index feedb2c5e..524d264fb 100644
--- a/src/main/java/org/traccar/protocol/Tk103ProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/Tk103ProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 - 2019 Anton Tananaev (anton@traccar.org)
+ * Copyright 2012 - 2020 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.
@@ -53,14 +53,14 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder {
.number("(d*)")
.number("(dd)(dd)(dd),?") // date (mmddyy if comma-delimited, otherwise yyddmm)
.expression("([AV]),?") // validity
- .number("(d+)(dd.d+)") // latitude
+ .number(" *(d+)(dd.d+)") // latitude
.expression("([NS]),?")
- .number("(d+)(dd.d+)") // longitude
+ .number(" *(d+)(dd.d+)") // longitude
.expression("([EW]),?")
- .number("(d+.d)(?:d*,)?") // speed
+ .number(" *(d+.d)(?:d*,)?") // speed
.number("(dd)(dd)(dd),?") // time (hhmmss)
.groupBegin()
- .number("(?:([d.]{6})|(dd)),?") // course
+ .number("(?:([ d.]{6})|(dd)),?") // course
.number("([01])") // charge
.number("([01])") // ignition
.number("(x)") // io
@@ -237,9 +237,9 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder {
getLastLocation(position, parser.nextDateTime(Parser.DateTimeFormat.DMY_HMS));
- int batterylevel = parser.nextInt(0);
- if (batterylevel != 255) {
- position.set(Position.KEY_BATTERY_LEVEL, decodeBattery(batterylevel));
+ int batteryLevel = parser.nextInt(0);
+ if (batteryLevel != 255) {
+ position.set(Position.KEY_BATTERY_LEVEL, decodeBattery(batteryLevel));
}
int battery = parser.nextInt(0);
@@ -343,7 +343,7 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder {
}
-@Override
+ @Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
diff --git a/src/test/java/org/traccar/protocol/Tk103ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Tk103ProtocolDecoderTest.java
index 4e654239d..f27a3e0c7 100644
--- a/src/test/java/org/traccar/protocol/Tk103ProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/Tk103ProtocolDecoderTest.java
@@ -12,6 +12,9 @@ public class Tk103ProtocolDecoderTest extends ProtocolTest {
Tk103ProtocolDecoder decoder = new Tk103ProtocolDecoder(null);
verifyPosition(decoder, text(
+ "(027023361470BR00200617A4000.5775N 8415.4076W 46.0173725 87.3101000000L00000000)"));
+
+ verifyPosition(decoder, text(
"(BALLESTEROS3BR00190408A4113.5700N00140.3100E000.0162431000.0001000000L00000000)"));
verifyPosition(decoder, text(