aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/org/traccar/model/Position.java1
-rw-r--r--src/org/traccar/protocol/GoSafeProtocolDecoder.java5
-rw-r--r--src/org/traccar/protocol/KhdProtocolDecoder.java40
3 files changed, 33 insertions, 13 deletions
diff --git a/src/org/traccar/model/Position.java b/src/org/traccar/model/Position.java
index 3cae4e34b..18e7f7f46 100644
--- a/src/org/traccar/model/Position.java
+++ b/src/org/traccar/model/Position.java
@@ -22,6 +22,7 @@ public class Position extends Message {
public static final String KEY_ORIGINAL = "raw";
public static final String KEY_INDEX = "index";
public static final String KEY_HDOP = "hdop";
+ public static final String KEY_VDOP = "vdop";
public static final String KEY_SATELLITES = "sat"; // in use
public static final String KEY_SATELLITES_VISIBLE = "satVisible";
public static final String KEY_RSSI = "rssi";
diff --git a/src/org/traccar/protocol/GoSafeProtocolDecoder.java b/src/org/traccar/protocol/GoSafeProtocolDecoder.java
index 94d12e989..96f745917 100644
--- a/src/org/traccar/protocol/GoSafeProtocolDecoder.java
+++ b/src/org/traccar/protocol/GoSafeProtocolDecoder.java
@@ -64,7 +64,7 @@ public class GoSafeProtocolDecoder extends BaseProtocolDecoder {
.number("(d+);") // course
.number("(d+);") // altitude
.number("(d+.d+)") // hdop
- .number("(?:;d+.d+)?") // vdop
+ .number(";(d+.d+)").optional() // vdop
.expression(",?")
.groupEnd()
.groupBegin()
@@ -154,7 +154,8 @@ public class GoSafeProtocolDecoder extends BaseProtocolDecoder {
position.setCourse(parser.nextDouble());
position.setAltitude(parser.nextDouble());
- position.set(Position.KEY_HDOP, parser.next());
+ position.set(Position.KEY_HDOP, parser.nextDouble());
+ position.set(Position.KEY_VDOP, parser.nextDouble());
if (parser.hasNext(5)) {
position.setNetwork(new Network(CellTower.from(
diff --git a/src/org/traccar/protocol/KhdProtocolDecoder.java b/src/org/traccar/protocol/KhdProtocolDecoder.java
index 0c3d8ee51..1c88a8b9d 100644
--- a/src/org/traccar/protocol/KhdProtocolDecoder.java
+++ b/src/org/traccar/protocol/KhdProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 Anton Tananaev (anton@traccar.org)
+ * Copyright 2014 - 2017 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -93,24 +93,42 @@ public class KhdProtocolDecoder extends BaseProtocolDecoder {
position.setLongitude(BcdUtil.readCoordinate(buf));
position.setSpeed(UnitsConverter.knotsFromKph(BcdUtil.readInteger(buf, 4)));
position.setCourse(BcdUtil.readInteger(buf, 4));
+ position.setValid((buf.readUnsignedByte() & 0x80) != 0);
- int flags = buf.readUnsignedByte();
- position.setValid((flags & 0x80) != 0);
+ if (type != MSG_ALARM) {
- if (type == MSG_ALARM) {
+ position.set(Position.KEY_ODOMETER, buf.readUnsignedMedium());
+ position.set(Position.KEY_STATUS, buf.readUnsignedInt());
+ position.set(Position.KEY_HDOP, buf.readUnsignedByte());
+ position.set(Position.KEY_VDOP, buf.readUnsignedByte());
+ position.set(Position.KEY_SATELLITES, buf.readUnsignedByte());
- buf.skipBytes(2);
+ buf.skipBytes(5); // other location data
- } else {
+ if (type == MSG_PERIPHERAL) {
- position.set(Position.KEY_ODOMETER, buf.readUnsignedMedium());
+ buf.readUnsignedShort(); // data length
- buf.skipBytes(4); // status
- buf.skipBytes(8); // other
+ int dataType = buf.readUnsignedByte();
- }
+ buf.readUnsignedByte(); // content length
- // parse extra data
+ switch (dataType) {
+ case 0x01:
+ position.set(Position.KEY_FUEL,
+ buf.readUnsignedByte() * 100 + buf.readUnsignedByte());
+ break;
+ case 0x02:
+ position.set(Position.PREFIX_TEMP + 1,
+ buf.readUnsignedByte() * 100 + buf.readUnsignedByte());
+ break;
+ default:
+ break;
+ }
+
+ }
+
+ }
return position;