aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol
diff options
context:
space:
mode:
authorRafaelMiquelino <rafaelmiquelino@gmail.com>2021-03-31 19:55:55 -0300
committerRafaelMiquelino <rafaelmiquelino@gmail.com>2021-03-31 19:55:55 -0300
commit9d2df94145fa68c17d1bc13297590a401f1917c9 (patch)
tree3b3e5f9dc315f18db67e378322f558b8bb84f20e /src/main/java/org/traccar/protocol
parent38f4c7ea61c58397ba42e527621bdece88fa472b (diff)
downloadtrackermap-server-9d2df94145fa68c17d1bc13297590a401f1917c9.tar.gz
trackermap-server-9d2df94145fa68c17d1bc13297590a401f1917c9.tar.bz2
trackermap-server-9d2df94145fa68c17d1bc13297590a401f1917c9.zip
Modify Vt200ProtocolDecoder
Add back removed test on previous commit. Remove duplication on common gps messages decoding.
Diffstat (limited to 'src/main/java/org/traccar/protocol')
-rw-r--r--src/main/java/org/traccar/protocol/Vt200ProtocolDecoder.java71
1 files changed, 27 insertions, 44 deletions
diff --git a/src/main/java/org/traccar/protocol/Vt200ProtocolDecoder.java b/src/main/java/org/traccar/protocol/Vt200ProtocolDecoder.java
index f60f6213d..22fc2cf18 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)));
+ if (buf.readableBytes() >= 9) {
+ 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());
+ 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;
@@ -142,32 +151,6 @@ public class Vt200ProtocolDecoder extends BaseProtocolDecoder {
return position;
- } else if (type == 0x3089) {
-
- Position position = new Position(getProtocolName());
- position.setDeviceId(deviceSession.getDeviceId());
-
- position.set(Position.KEY_IGNITION, buf.readUnsignedByte() == 1);
- buf.readUnsignedShort(); // trip id
-
- position.setTime(decodeDate(buf));
-
- if (buf.readableBytes() >= 9) {
- 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());
- }
- }
-
- return position;
-
}
return null;