aboutsummaryrefslogtreecommitdiff
path: root/src/org
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-04-07 18:25:18 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2015-04-07 18:25:18 +1200
commit2e709a88706cee2861fa53ac4dc4c5f76762e8b2 (patch)
tree0892cfb9f5accb2b6b09f8b766530350ea12af9c /src/org
parent0549b3ffd07d10d48f35434034a01d1504585df5 (diff)
downloadtrackermap-server-2e709a88706cee2861fa53ac4dc4c5f76762e8b2.tar.gz
trackermap-server-2e709a88706cee2861fa53ac4dc4c5f76762e8b2.tar.bz2
trackermap-server-2e709a88706cee2861fa53ac4dc4c5f76762e8b2.zip
Add TK110 support to GPS103
Diffstat (limited to 'src/org')
-rw-r--r--src/org/traccar/protocol/Gps103ProtocolDecoder.java34
1 files changed, 22 insertions, 12 deletions
diff --git a/src/org/traccar/protocol/Gps103ProtocolDecoder.java b/src/org/traccar/protocol/Gps103ProtocolDecoder.java
index 2069634d6..90b170cff 100644
--- a/src/org/traccar/protocol/Gps103ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gps103ProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 - 2014 Anton Tananaev (anton.tananaev@gmail.com)
+ * Copyright 2012 - 2015 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.
@@ -45,7 +45,8 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder {
"(\\d{2}):?(\\d{2})(?:\\d{2})?," + // Local Time
"[^,]*," +
"[FL]," + // F - full / L - low
- "(\\d{2})(\\d{2})(\\d{2})\\.(\\d+)," + // Time UTC (HHMMSS.SSS)
+ "(?:(\\d{2})(\\d{2})(\\d{2})\\.(\\d+)|" + // Time UTC (HHMMSS.SSS)
+ "(?:\\d{1,5}\\.\\d+))," +
"([AV])," + // Validity
"(\\d+)(\\d{2}\\.\\d+)," + // Latitude (DDMM.MMMM)
"([NS])," +
@@ -117,23 +118,32 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder {
int localHours = Integer.valueOf(parser.group(index++));
int localMinutes = Integer.valueOf(parser.group(index++));
- int utcHours = Integer.valueOf(parser.group(index++));
- int utcMinutes = Integer.valueOf(parser.group(index++));
+ String utcHours = parser.group(index++);
+ String utcMinutes = parser.group(index++);
// Time
time.set(Calendar.HOUR_OF_DAY, localHours);
time.set(Calendar.MINUTE, localMinutes);
- time.set(Calendar.SECOND, Integer.valueOf(parser.group(index++)));
- time.set(Calendar.MILLISECOND, Integer.valueOf(parser.group(index++)));
+ String seconds = parser.group(index++);
+ if (seconds != null) {
+ time.set(Calendar.SECOND, Integer.valueOf(seconds));
+ }
+ String milliseconds = parser.group(index++);
+ if (milliseconds != null) {
+ time.set(Calendar.MILLISECOND, Integer.valueOf(milliseconds));
+ }
// Timezone calculation
- int deltaMinutes = (localHours - utcHours) * 60 + localMinutes - utcMinutes;
- if (deltaMinutes <= -12 * 60) {
- deltaMinutes += 24 * 60;
- } else if (deltaMinutes > 12 * 60) {
- deltaMinutes -= 24 * 60;
+ if (utcHours != null && utcMinutes != null) {
+ int deltaMinutes = (localHours - Integer.valueOf(utcHours)) * 60;
+ deltaMinutes += localMinutes - Integer.valueOf(utcMinutes);
+ if (deltaMinutes <= -12 * 60) {
+ deltaMinutes += 24 * 60;
+ } else if (deltaMinutes > 12 * 60) {
+ deltaMinutes -= 24 * 60;
+ }
+ time.add(Calendar.MINUTE, -deltaMinutes);
}
- time.add(Calendar.MINUTE, -deltaMinutes);
position.setTime(time.getTime());
// Validity