diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-10-02 20:38:03 +1300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-02 20:38:03 +1300 |
commit | 8862d4f45712f6bee956c27380800d89105034e8 (patch) | |
tree | 869b17f6563ab3495f5cc092371a24f5d74b4acb /src/org/traccar/helper/Checksum.java | |
parent | 8e265f9c030496f5672460379bcb3fc2d0d78a3b (diff) | |
parent | bb211eea5f62014c0700138e922cb1adcdc9d9dd (diff) | |
download | trackermap-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.java | 9 |
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)) { |