From 2e24e0e311606d7b12b9e36f113dd218e54d67bb Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 23 Jan 2016 10:09:58 +1300 Subject: Use send time if earlier than GPS time --- src/org/traccar/protocol/Gl200ProtocolDecoder.java | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src/org') 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); } -- cgit v1.2.3