aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2019-04-14 13:44:38 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2019-04-14 13:44:38 -0700
commit142fe572e6cb3c44b79844464b9efdaf501755a9 (patch)
tree14ab9d09ffba0c06e3a11f5c1a1846487dd7ce75 /src
parentb595ec1bede3e30447b49bb7340f88c9b3a3f97f (diff)
downloadtraccar-server-142fe572e6cb3c44b79844464b9efdaf501755a9.tar.gz
traccar-server-142fe572e6cb3c44b79844464b9efdaf501755a9.tar.bz2
traccar-server-142fe572e6cb3c44b79844464b9efdaf501755a9.zip
Decode Nyitech OBD data
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/protocol/NyitechProtocolDecoder.java53
1 files changed, 50 insertions, 3 deletions
diff --git a/src/main/java/org/traccar/protocol/NyitechProtocolDecoder.java b/src/main/java/org/traccar/protocol/NyitechProtocolDecoder.java
index e145205f7..62b41a2ea 100644
--- a/src/main/java/org/traccar/protocol/NyitechProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/NyitechProtocolDecoder.java
@@ -22,6 +22,7 @@ import org.traccar.DeviceSession;
import org.traccar.Protocol;
import org.traccar.helper.BitUtil;
import org.traccar.helper.DateBuilder;
+import org.traccar.helper.ObdDecoder;
import org.traccar.helper.UnitsConverter;
import org.traccar.model.Position;
@@ -102,20 +103,66 @@ public class NyitechProtocolDecoder extends BaseProtocolDecoder {
position.setDeviceId(deviceSession.getDeviceId());
if (type == MSG_COMPREHENSIVE_LIVE || type == MSG_COMPREHENSIVE_HISTORY) {
+
buf.skipBytes(6); // time
- buf.skipBytes(3); // data
+ boolean includeLocation = buf.readUnsignedByte() > 0;
+ boolean includeObd = buf.readUnsignedByte() > 0;
+ buf.readUnsignedByte(); // include sensor
+
+ if (includeLocation) {
+ decodeLocation(position, buf);
+ } else {
+ getLastLocation(position, null);
+ }
+
+ if (includeObd) {
+ int count = buf.readUnsignedByte();
+ for (int i = 0; i < count; i++) {
+ int pid = buf.readUnsignedShortLE();
+ int length = buf.readUnsignedByte();
+ switch (length) {
+ case 1:
+ position.add(ObdDecoder.decodeData(pid, buf.readByte(), true));
+ break;
+ case 2:
+ position.add(ObdDecoder.decodeData(pid, buf.readShortLE(), true));
+ break;
+ case 4:
+ position.add(ObdDecoder.decodeData(pid, buf.readIntLE(), true));
+ break;
+ default:
+ buf.skipBytes(length);
+ break;
+ }
+ }
+ }
+
+ position.set(Position.KEY_FUEL_USED, buf.readUnsignedInt() * 0.01);
+ position.set(Position.KEY_ODOMETER_TRIP, buf.readUnsignedInt());
+
+
} else if (type == MSG_ALARM) {
+
buf.readUnsignedShortLE(); // random number
buf.readUnsignedByte(); // tag
position.set(Position.KEY_ALARM, decodeAlarm(buf.readUnsignedByte()));
buf.readUnsignedShortLE(); // threshold
buf.readUnsignedShortLE(); // value
buf.skipBytes(6); // time
+
+ decodeLocation(position, buf);
+
} else if (type == MSG_FIXED) {
+
buf.skipBytes(6); // time
- }
- decodeLocation(position, buf);
+ decodeLocation(position, buf);
+
+ } else {
+
+ decodeLocation(position, buf);
+
+ }
return position;
}