From f43c8f976e9dc22847ce7afd827f587e47c89d73 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 17 Jun 2020 20:56:05 -0700 Subject: Handle spaces in TK103 protocol --- .../org/traccar/protocol/Tk103ProtocolDecoder.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/main/java/org/traccar') 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 { -- cgit v1.2.3