aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol
diff options
context:
space:
mode:
authorVitaly Litvak <vitavaque@gmail.com>2016-10-02 08:17:43 +0300
committerVitaly Litvak <vitavaque@gmail.com>2016-10-02 08:17:43 +0300
commit9cc1cbd2b21afcd40091069d2f0a58565db18c15 (patch)
tree5393357116c24bc217a604e31e4a5fe1730b41c7 /src/org/traccar/protocol
parentb5a09475b90b044cf0b5b0f64d8709dd7e92c460 (diff)
downloadtraccar-server-9cc1cbd2b21afcd40091069d2f0a58565db18c15.tar.gz
traccar-server-9cc1cbd2b21afcd40091069d2f0a58565db18c15.tar.bz2
traccar-server-9cc1cbd2b21afcd40091069d2f0a58565db18c15.zip
Moved 'xor' checksum method to the utility class.
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r--src/org/traccar/protocol/Jt600ProtocolDecoder.java12
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));