aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-01-19 12:09:29 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2016-01-19 12:09:29 +1300
commit625048edc94a4356145b61713861c6b48535a220 (patch)
tree69de05db3a86c770e5a6be1c5dd4e7643dcf25e6 /src/org/traccar/protocol
parent1edf8f7a5390ea8cbbe9a87036166630cfea57f6 (diff)
downloadtraccar-server-625048edc94a4356145b61713861c6b48535a220.tar.gz
traccar-server-625048edc94a4356145b61713861c6b48535a220.tar.bz2
traccar-server-625048edc94a4356145b61713861c6b48535a220.zip
Start implementing new GoSafe format
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r--src/org/traccar/protocol/GoSafeProtocolDecoder.java22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/org/traccar/protocol/GoSafeProtocolDecoder.java b/src/org/traccar/protocol/GoSafeProtocolDecoder.java
index 2fb7522d3..810aee3e0 100644
--- a/src/org/traccar/protocol/GoSafeProtocolDecoder.java
+++ b/src/org/traccar/protocol/GoSafeProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton.tananaev@gmail.com)
+ * Copyright 2015 - 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.
@@ -41,11 +41,12 @@ public class GoSafeProtocolDecoder extends BaseProtocolDecoder {
.number("(d+),") // imei
.number("(dd)(dd)(dd)") // time
.number("(dd)(dd)(dd),") // date
+ .optional(2)
.expression("(.*)#?") // data
.compile();
private static final Pattern PATTERN_ITEM = new PatternBuilder()
- .number("(x+)?,") // event
+ .number("(x+)?,").optional() // event
.groupBegin()
.text("SYS:")
.expression("[^,]*,")
@@ -105,7 +106,10 @@ public class GoSafeProtocolDecoder extends BaseProtocolDecoder {
Position position = new Position();
position.setProtocol(getProtocolName());
position.setDeviceId(getDeviceId());
- position.setTime(time);
+
+ if (time != null) {
+ position.setTime(time);
+ }
position.set(Event.KEY_EVENT, parser.next());
@@ -153,14 +157,18 @@ public class GoSafeProtocolDecoder extends BaseProtocolDecoder {
return null;
}
- DateBuilder dateBuilder = new DateBuilder()
- .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt())
- .setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ Date time = null;
+ if (parser.hasNext(6)) {
+ DateBuilder dateBuilder = new DateBuilder()
+ .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt())
+ .setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ time = dateBuilder.getDate();
+ }
List<Position> positions = new LinkedList<>();
Parser itemParser = new Parser(PATTERN_ITEM, parser.next());
while (itemParser.find()) {
- positions.add(decodePosition(itemParser, dateBuilder.getDate()));
+ positions.add(decodePosition(itemParser, time));
}
return positions;