diff options
author | Stefan Clark <stefanclark@gmail.com> | 2022-07-28 22:37:15 +0100 |
---|---|---|
committer | Stefan Clark <stefanclark@gmail.com> | 2022-07-28 22:37:15 +0100 |
commit | 42e88c2bf95962f1274a8bbb6e8fc09af95f627f (patch) | |
tree | 40fc4b9ef9de16e634e706895c27a46f934d7cac /src/main/java/org/traccar/protocol/Xexun2ProtocolDecoder.java | |
parent | de2219565e4a61aa0d64b03650ec36ef6d17de93 (diff) | |
download | trackermap-server-42e88c2bf95962f1274a8bbb6e8fc09af95f627f.tar.gz trackermap-server-42e88c2bf95962f1274a8bbb6e8fc09af95f627f.tar.bz2 trackermap-server-42e88c2bf95962f1274a8bbb6e8fc09af95f627f.zip |
Added udp() to Checksum helper and Updated Xexun2 procotol
Diffstat (limited to 'src/main/java/org/traccar/protocol/Xexun2ProtocolDecoder.java')
-rw-r--r-- | src/main/java/org/traccar/protocol/Xexun2ProtocolDecoder.java | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/main/java/org/traccar/protocol/Xexun2ProtocolDecoder.java b/src/main/java/org/traccar/protocol/Xexun2ProtocolDecoder.java index 8deb2328b..f0158e6ce 100644 --- a/src/main/java/org/traccar/protocol/Xexun2ProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/Xexun2ProtocolDecoder.java @@ -24,6 +24,7 @@ import org.traccar.session.DeviceSession; import org.traccar.NetworkMessage; import org.traccar.Protocol; import org.traccar.helper.BitUtil; +import org.traccar.helper.Checksum; import org.traccar.helper.UnitsConverter; import org.traccar.model.CellTower; import org.traccar.model.Network; @@ -97,13 +98,17 @@ public class Xexun2ProtocolDecoder extends BaseProtocolDecoder { return null; } + int payloadSize = buf.readUnsignedShort() & 0x03ff; + int checksum = buf.readUnsignedShort(); // checksum + + if (checksum != Checksum.udp(buf.nioBuffer(buf.readerIndex(), payloadSize))) { + return null; + } + if (type != Xexun2ProtocolEncoder.MSG_COMMAND) { sendResponse(channel, type, index, imei); } - buf.readUnsignedShort(); // attributes - buf.readUnsignedShort(); // checksum - if (type == MSG_POSITION) { List<Integer> lengths = new ArrayList<>(); List<Position> positions = new ArrayList<>(); |