aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/helper/Checksum.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-10-02 20:38:03 +1300
committerGitHub <noreply@github.com>2016-10-02 20:38:03 +1300
commit8862d4f45712f6bee956c27380800d89105034e8 (patch)
tree869b17f6563ab3495f5cc092371a24f5d74b4acb /src/org/traccar/helper/Checksum.java
parent8e265f9c030496f5672460379bcb3fc2d0d78a3b (diff)
parentbb211eea5f62014c0700138e922cb1adcdc9d9dd (diff)
downloadtrackermap-server-8862d4f45712f6bee956c27380800d89105034e8.tar.gz
trackermap-server-8862d4f45712f6bee956c27380800d89105034e8.tar.bz2
trackermap-server-8862d4f45712f6bee956c27380800d89105034e8.zip
Merge pull request #2387 from vitalidze/jt600c_checksum_replies
For JT600c - added checksum verification and replying for alarms/positions
Diffstat (limited to 'src/org/traccar/helper/Checksum.java')
-rw-r--r--src/org/traccar/helper/Checksum.java9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/org/traccar/helper/Checksum.java b/src/org/traccar/helper/Checksum.java
index 2a4b1191d..dde174545 100644
--- a/src/org/traccar/helper/Checksum.java
+++ b/src/org/traccar/helper/Checksum.java
@@ -194,6 +194,15 @@ public final class Checksum {
return checksum;
}
+ public static int xor(String string) {
+ byte[] bytes = string.getBytes(StandardCharsets.US_ASCII);
+ byte sum = 0;
+ for (byte b : bytes) {
+ sum ^= b;
+ }
+ return sum;
+ }
+
public static String nmea(String msg) {
int checksum = 0;
for (byte b : msg.getBytes(StandardCharsets.US_ASCII)) {