diff options
Diffstat (limited to 'src/org')
-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); } |