diff options
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r-- | src/org/traccar/protocol/Jt600ProtocolDecoder.java | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/src/org/traccar/protocol/Jt600ProtocolDecoder.java b/src/org/traccar/protocol/Jt600ProtocolDecoder.java index 827d6fbb5..de4510d17 100644 --- a/src/org/traccar/protocol/Jt600ProtocolDecoder.java +++ b/src/org/traccar/protocol/Jt600ProtocolDecoder.java @@ -21,6 +21,7 @@ import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.DeviceSession; import org.traccar.helper.BcdUtil; +import org.traccar.helper.Checksum; import org.traccar.helper.DateBuilder; import org.traccar.helper.Parser; import org.traccar.helper.PatternBuilder; @@ -267,7 +268,7 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder { case "U02": case "U03": int checkSum = parser.nextInt(16); - int calculatedCheckSum = checkSum(sentence.substring(1, sentence.length() - 3)); + int calculatedCheckSum = Checksum.xor(sentence.substring(1, sentence.length() - 3)); if (checkSum == calculatedCheckSum) { sendResponse(channel, "(S39)"); return position; @@ -303,15 +304,6 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder { return null; } - private byte checkSum(String sentence) { - byte[] bytes = sentence.getBytes(StandardCharsets.US_ASCII); - byte sum = 0; - for (byte b : bytes) { - sum ^= b; - } - return sum; - } - private void sendResponse(Channel channel, String response) { if (channel != null) { channel.write(ChannelBuffers.copiedBuffer(response, StandardCharsets.US_ASCII)); |