diff options
author | Leonhard Heizinger <leonhard.heizinger@ur.de> | 2019-04-10 09:54:54 +0200 |
---|---|---|
committer | Leonhard Heizinger <leonhard.heizinger@ur.de> | 2019-04-10 09:54:54 +0200 |
commit | 25cbe0ed501319dbb23cc260817a797df5be9fb6 (patch) | |
tree | a544dd74eafd889627613ec5668e8d479116f5b1 /src | |
parent | 22436a2434faa8912c8a352e65306d0dc0669b5c (diff) | |
parent | d701e4cd549e99c594a7ddf41359b59f34ad2cff (diff) | |
download | traccar-server-25cbe0ed501319dbb23cc260817a797df5be9fb6.tar.gz traccar-server-25cbe0ed501319dbb23cc260817a797df5be9fb6.tar.bz2 traccar-server-25cbe0ed501319dbb23cc260817a797df5be9fb6.zip |
Merge branch 'master' of https://github.com/he-leon/traccar
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/traccar/protocol/Tk103ProtocolDecoder.java | 22 | ||||
-rw-r--r-- | src/test/java/org/traccar/protocol/Tk103ProtocolDecoderTest.java | 5 |
2 files changed, 21 insertions, 6 deletions
diff --git a/src/main/java/org/traccar/protocol/Tk103ProtocolDecoder.java b/src/main/java/org/traccar/protocol/Tk103ProtocolDecoder.java index 9e28b5051..feedb2c5e 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 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2012 - 2019 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. @@ -44,7 +44,11 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder { private static final Pattern PATTERN = new PatternBuilder() .text("(").optional() - .number("(d+)(,)?") // device id + .groupBegin() + .expression("(.{12})") // device id + .or() + .expression("(.+),") // device id + .groupEnd() .expression("(.{4}),?") // command .number("(d*)") .number("(dd)(dd)(dd),?") // date (mmddyy if comma-delimited, otherwise yyddmm) @@ -371,7 +375,17 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder { return null; } - DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next()); + String id = null; + boolean alternative = false; + if (parser.hasNext()) { + id = parser.next(); + } + if (parser.hasNext()) { + id = parser.next(); + alternative = true; + } + + DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, id); if (deviceSession == null) { return null; } @@ -379,8 +393,6 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder { Position position = new Position(getProtocolName()); position.setDeviceId(deviceSession.getDeviceId()); - boolean alternative = parser.next() != null; - decodeType(position, parser.next(), parser.next()); DateBuilder dateBuilder = new DateBuilder(); diff --git a/src/test/java/org/traccar/protocol/Tk103ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Tk103ProtocolDecoderTest.java index db636893b..4e654239d 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( + "(BALLESTEROS3BR00190408A4113.5700N00140.3100E000.0162431000.0001000000L00000000)")); + + verifyPosition(decoder, text( "(094625928000BR00190213A1156.0431S07705.6145W000.000023521.40000000007L00000314T113)")); verifyPosition(decoder, text( @@ -32,7 +35,7 @@ public class Tk103ProtocolDecoderTest extends ProtocolTest { verifyPosition(decoder, text( "(864768011069660,ZC17,250517,A,3211.7118N,03452.8086E,0.68,115525,208.19,64.50,9)")); - verifyNull(decoder, text( + verifyPosition(decoder, text( "(357593060760397BP02,G,2,170304A6015.7466N01101.8460E001.609445591.048,7)")); verifyPosition(decoder, text( |