diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-01-23 10:09:58 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2016-01-23 10:09:58 +1300 |
commit | 2e24e0e311606d7b12b9e36f113dd218e54d67bb (patch) | |
tree | 5e8397d6b40c01989cc333fd9633f633da61fe84 /src/org/traccar/protocol/Gl200ProtocolDecoder.java | |
parent | 6ebe7202420731f51cd40f15879ce40bdd1926b6 (diff) | |
download | trackermap-server-2e24e0e311606d7b12b9e36f113dd218e54d67bb.tar.gz trackermap-server-2e24e0e311606d7b12b9e36f113dd218e54d67bb.tar.bz2 trackermap-server-2e24e0e311606d7b12b9e36f113dd218e54d67bb.zip |
Use send time if earlier than GPS time
Diffstat (limited to 'src/org/traccar/protocol/Gl200ProtocolDecoder.java')
-rw-r--r-- | src/org/traccar/protocol/Gl200ProtocolDecoder.java | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/org/traccar/protocol/Gl200ProtocolDecoder.java b/src/org/traccar/protocol/Gl200ProtocolDecoder.java index 42786d4fe..a2681e10d 100644 --- a/src/org/traccar/protocol/Gl200ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gl200ProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 - 2015 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2012 - 2016 Anton Tananaev (anton.tananaev@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -124,8 +124,14 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder { .number("(d+.d)?,") // odometer .number("(d{1,3})?,") // battery .groupEnd("?") - .any().text(",") - .number("(xxxx)") + .groupBegin() + .any() + .number("(dddd)(dd)(dd)") // date + .number("(dd)(dd)(dd)") // time + .or() + .any() + .groupEnd() + .number(",(xxxx)") .text("$").optional() .compile(); @@ -227,6 +233,15 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder { position.set(Event.KEY_ODOMETER, parser.next()); position.set(Event.KEY_BATTERY, parser.next()); + if (parser.hasNext(6)) { + DateBuilder dateBuilder = new DateBuilder() + .setDate(parser.nextInt(), parser.nextInt(), parser.nextInt()) + .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt()); + if (!position.getOutdated() && position.getFixTime().after(dateBuilder.getDate())) { + position.setTime(dateBuilder.getDate()); + } + } + if (Context.getConfig().getBoolean(getProtocolName() + ".ack") && channel != null) { channel.write("+SACK:" + parser.next() + "$", remoteAddress); } |