aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2014-10-20 13:58:58 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2014-10-20 13:58:58 +1300
commit6984cc9c14cf8dd44b946dd1624601ce2c0edf30 (patch)
treecaa76d2872041d4da0db2b41a7faa8e514fa880c /src/org/traccar/protocol
parent13563221ad5aa99216a1e742c964fce49fed7187 (diff)
downloadtrackermap-server-6984cc9c14cf8dd44b946dd1624601ce2c0edf30.tar.gz
trackermap-server-6984cc9c14cf8dd44b946dd1624601ce2c0edf30.tar.bz2
trackermap-server-6984cc9c14cf8dd44b946dd1624601ce2c0edf30.zip
Improve GL200 decoder (fix #830)
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r--src/org/traccar/protocol/Gl200ProtocolDecoder.java45
1 files changed, 33 insertions, 12 deletions
diff --git a/src/org/traccar/protocol/Gl200ProtocolDecoder.java b/src/org/traccar/protocol/Gl200ProtocolDecoder.java
index 39fdcca78..942d6ef10 100644
--- a/src/org/traccar/protocol/Gl200ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gl200ProtocolDecoder.java
@@ -34,21 +34,21 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
}
private static final Pattern pattern = Pattern.compile(
- "\\+RESP:GT...," +
+ "\\+(?:RESP|BUFF):GT...," +
"[0-9a-fA-F]{6}," + // Protocol version
"(\\d{15}),.*," + // IMEI
"(\\d*)," + // GPS accuracy
- "(\\d+.\\d)," + // Speed
- "(\\d+)," + // Course
- "(-?\\d+\\.\\d)," + // Altitude
+ "(\\d+.\\d)?," + // Speed
+ "(\\d+)?," + // Course
+ "(-?\\d+\\.\\d)?," + // Altitude
"(-?\\d+\\.\\d+)," + // Longitude
"(-?\\d+\\.\\d+)," + // Latitude
"(\\d{4})(\\d{2})(\\d{2})" + // Date (YYYYMMDD)
"(\\d{2})(\\d{2})(\\d{2})," + // Time (HHMMSS)
- "(\\d{4})," + // MCC
- "(\\d{4})," + // MNC
- "(\\p{XDigit}{4})," + // LAC
- "(\\p{XDigit}{4})," + // Cell
+ "(\\d{4})?," + // MCC
+ "(\\d{4})?," + // MNC
+ "(\\p{XDigit}{4})?," + // LAC
+ "(\\p{XDigit}{4})?," + // Cell
"(?:.*,(\\d{1,3}),\\d{14},)?" + // Battery
".*");
@@ -83,10 +83,31 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
// Validity
position.setValid(Integer.valueOf(parser.group(index++)) < 20);
- // Position info
- position.setSpeed(Double.valueOf(parser.group(index++)));
- position.setCourse(Double.valueOf(parser.group(index++)));
- position.setAltitude(Double.valueOf(parser.group(index++)));
+ // Speed
+ String speed = parser.group(index++);
+ if (speed != null) {
+ position.setSpeed(Double.valueOf(speed));
+ } else {
+ position.setSpeed(0.0);
+ }
+
+ // Course
+ String course = parser.group(index++);
+ if (speed != null) {
+ position.setCourse(Double.valueOf(course));
+ } else {
+ position.setCourse(0.0);
+ }
+
+ // Altitude
+ String altitude = parser.group(index++);
+ if (speed != null) {
+ position.setAltitude(Double.valueOf(altitude));
+ } else {
+ position.setAltitude(0.0);
+ }
+
+ // Coordinates
position.setLongitude(Double.valueOf(parser.group(index++)));
position.setLatitude(Double.valueOf(parser.group(index++)));