aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2021-06-05 10:25:57 -0700
committerGitHub <noreply@github.com>2021-06-05 10:25:57 -0700
commit7ce5bb1f5491b85ea1e6ffd095c68b8d02bb831e (patch)
tree16a7b7158d401bed056e061e16607a36ded1e96a /src/main/java
parent5d317c47b953d9304b2874616a4146648062651a (diff)
parent1ede0fefed4fb220cd5510b5d75ddd92455f90fa (diff)
downloadtrackermap-server-7ce5bb1f5491b85ea1e6ffd095c68b8d02bb831e.tar.gz
trackermap-server-7ce5bb1f5491b85ea1e6ffd095c68b8d02bb831e.tar.bz2
trackermap-server-7ce5bb1f5491b85ea1e6ffd095c68b8d02bb831e.zip
Merge pull request #4657 from PinCarBR/vt200_ignition
Add ignition status to Vt200 Protocol
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/traccar/protocol/Vt200ProtocolDecoder.java47
1 files changed, 28 insertions, 19 deletions
diff --git a/src/main/java/org/traccar/protocol/Vt200ProtocolDecoder.java b/src/main/java/org/traccar/protocol/Vt200ProtocolDecoder.java
index b1564abd9..84ad09caa 100644
--- a/src/main/java/org/traccar/protocol/Vt200ProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/Vt200ProtocolDecoder.java
@@ -67,37 +67,46 @@ public class Vt200ProtocolDecoder extends BaseProtocolDecoder {
int type = buf.readUnsignedShort();
buf.readUnsignedShort(); // length
- if (type == 0x2086 || type == 0x2084 || type == 0x2082) {
+ if (type == 0x2086 || type == 0x2084 || type == 0x2082 || type == 0x3089) {
Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
- buf.readUnsignedByte(); // data type
+ if (type == 0x3089) {
+ position.set(Position.KEY_IGNITION, buf.readUnsignedByte() == 1);
+ } else {
+ buf.readUnsignedByte(); // data type
+ }
+
buf.readUnsignedShort(); // trip id
position.setTime(decodeDate(buf));
- position.setLatitude(decodeCoordinate(BcdUtil.readInteger(buf, 8)));
- position.setLongitude(decodeCoordinate(BcdUtil.readInteger(buf, 9)));
-
- int flags = buf.readUnsignedByte();
- position.setValid(BitUtil.check(flags, 0));
- if (!BitUtil.check(flags, 1)) {
- position.setLatitude(-position.getLatitude());
- }
- if (!BitUtil.check(flags, 2)) {
- position.setLongitude(-position.getLongitude());
+ if (buf.readableBytes() > 2) {
+ position.setLatitude(decodeCoordinate(BcdUtil.readInteger(buf, 8)));
+ position.setLongitude(decodeCoordinate(BcdUtil.readInteger(buf, 9)));
+
+ int flags = buf.readUnsignedByte();
+ position.setValid(BitUtil.check(flags, 0));
+ if (!BitUtil.check(flags, 1)) {
+ position.setLatitude(-position.getLatitude());
+ }
+ if (!BitUtil.check(flags, 2)) {
+ position.setLongitude(-position.getLongitude());
+ }
}
- position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedByte()));
- position.setCourse(buf.readUnsignedByte() * 2);
+ if (type != 0x3089) {
+ position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedByte()));
+ position.setCourse(buf.readUnsignedByte() * 2);
- position.set(Position.KEY_SATELLITES, buf.readUnsignedByte());
- position.set(Position.KEY_RSSI, buf.readUnsignedByte());
- position.set(Position.KEY_ODOMETER, buf.readUnsignedInt() * 1000);
- position.set(Position.KEY_STATUS, buf.readUnsignedInt());
+ position.set(Position.KEY_SATELLITES, buf.readUnsignedByte());
+ position.set(Position.KEY_RSSI, buf.readUnsignedByte());
+ position.set(Position.KEY_ODOMETER, buf.readUnsignedInt() * 1000);
+ position.set(Position.KEY_STATUS, buf.readUnsignedInt());
- // additional data
+ // additional data
+ }
return position;