aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstefanclark <stefanclark@users.noreply.github.com>2022-07-21 22:30:46 +0100
committerGitHub <noreply@github.com>2022-07-21 22:30:46 +0100
commitc85bcf1966e690d8af56d0eff51dbae5c025340e (patch)
treefe92684867e2d23fe98195ee420a67462b65ccd9
parentdf974772a6cab1f1bdbad4c6b19e150c2ca3ccf6 (diff)
downloadtrackermap-server-c85bcf1966e690d8af56d0eff51dbae5c025340e.tar.gz
trackermap-server-c85bcf1966e690d8af56d0eff51dbae5c025340e.tar.bz2
trackermap-server-c85bcf1966e690d8af56d0eff51dbae5c025340e.zip
Update Xexun2ProtocolDecoder.java
-rw-r--r--src/main/java/org/traccar/protocol/Xexun2ProtocolDecoder.java30
1 files changed, 19 insertions, 11 deletions
diff --git a/src/main/java/org/traccar/protocol/Xexun2ProtocolDecoder.java b/src/main/java/org/traccar/protocol/Xexun2ProtocolDecoder.java
index 47d86aeb1..3f37d7cac 100644
--- a/src/main/java/org/traccar/protocol/Xexun2ProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/Xexun2ProtocolDecoder.java
@@ -178,17 +178,25 @@ public class Xexun2ProtocolDecoder extends BaseProtocolDecoder {
position.setLatitude(convertCoordinate(buf.readDouble()));
}
if (BitUtil.check(positionMask, 7)) {
- buf.skipBytes(2); // length = 30
- buf.skipBytes(1); // marker = 'G'
- buf.skipBytes(2); // length = 27
- position.setLongitude(convertCoordinate(buf.readDouble()));
- position.setLatitude(convertCoordinate(buf.readDouble()));
- position.setValid(buf.readUnsignedByte() > 0); // 0=invalid,1=normal,2=sub-meter,3=differential
- position.set(Position.KEY_SATELLITES, buf.readUnsignedByte());
- buf.skipBytes(1); // SNR
- position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedShort() * 0.1));
- position.setCourse(buf.readUnsignedShort() * 0.1);
- position.setAltitude(buf.readFloat());
+ if (buf.readUnsignedShort() > 0) {
+ if (buf.readByte() != 'G') {
+ buf.skipBytes(buf.readUnsignedShort());
+ } else {
+ int gpsDataLen = buf.readUnsignedShort();
+ if (gpsDataLen != 27) {
+ buf.skipBytes(gpsDataLen);
+ } else {
+ position.setLongitude(convertCoordinate(buf.readDouble()));
+ position.setLatitude(convertCoordinate(buf.readDouble()));
+ position.setValid(buf.readUnsignedByte() > 0);
+ position.set(Position.KEY_SATELLITES, buf.readUnsignedByte());
+ buf.readUnsignedByte(1); // satellite signal to noise ratio
+ position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedShort() * 0.1));
+ position.setCourse(buf.readUnsignedShort() * 0.1);
+ position.setAltitude(buf.readFloat());
+ }
+ }
+ }
}
}
if (BitUtil.check(mask, 3)) {