aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/WebDataHandler.java2
-rw-r--r--src/org/traccar/helper/Checksum.java14
-rw-r--r--src/org/traccar/protocol/AplicomProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/CityeasyProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/GpsGateProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/KhdProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/KhdProtocolEncoder.java2
-rw-r--r--src/org/traccar/protocol/LaipacProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/MeiligaoProtocolDecoder.java2
9 files changed, 15 insertions, 15 deletions
diff --git a/src/org/traccar/WebDataHandler.java b/src/org/traccar/WebDataHandler.java
index c6e120bbc..c64ca8334 100644
--- a/src/org/traccar/WebDataHandler.java
+++ b/src/org/traccar/WebDataHandler.java
@@ -53,7 +53,7 @@ public class WebDataHandler extends BaseDataHandler {
f.format("%1$td%1$tm%1$ty,,", calendar);
}
- s.append(Checksum.nmeaChecksum(s.toString()));
+ s.append(Checksum.nmea(s.toString()));
return s.toString();
}
diff --git a/src/org/traccar/helper/Checksum.java b/src/org/traccar/helper/Checksum.java
index 99d7e2ddb..cdf1bbf50 100644
--- a/src/org/traccar/helper/Checksum.java
+++ b/src/org/traccar/helper/Checksum.java
@@ -91,8 +91,8 @@ public class Checksum {
0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0
};
- private static final int CRC16_CCITT_START = 0xFFFF;
- private static final int CRC16_CCITT_XOROUT = 0xFFFF;
+ public static final int CRC16_CCITT = 0xFFFF;
+ public static final int CRC16_CCITT_XOROUT = 0xFFFF;
private static int crc16Unreflected(ByteBuffer buf, int crc_in, int[] table) {
int crc16 = crc_in;
@@ -111,11 +111,11 @@ public class Checksum {
}
public static int crc16Ccitt(ByteBuffer buf) {
- return crc16Reflected(buf, CRC16_CCITT_START, CRC16_CCITT_TABLE_REVERSE) ^ CRC16_CCITT_XOROUT;
+ return crc16Reflected(buf, 0xFFFF, CRC16_CCITT_TABLE_REVERSE) ^ 0xFFFF;
}
public static int crc16X25Ccitt(ByteBuffer buf) {
- return crc16Unreflected(buf, CRC16_CCITT_START, CRC16_CCITT_TABLE);
+ return crc16Unreflected(buf, 0xFFFF, CRC16_CCITT_TABLE);
}
public static int crc16Ccitt(ByteBuffer buf, int seed, int xorout) {
@@ -130,7 +130,7 @@ public class Checksum {
return (int) checksum.getValue();
}
- public static int xorChecksum(ByteBuffer buf) {
+ public static int xor(ByteBuffer buf) {
int checksum = 0;
while (buf.hasRemaining()) {
checksum ^= buf.get();
@@ -138,7 +138,7 @@ public class Checksum {
return checksum;
}
- public static String nmeaChecksum(String msg) {
+ public static String nmea(String msg) {
int checksum = 0;
byte bytes[] = msg.getBytes(Charset.defaultCharset());
for (int i = 1; i < msg.length(); i++) {
@@ -147,7 +147,7 @@ public class Checksum {
return String.format("*%02x", checksum).toUpperCase();
}
- public static long luhnChecksum(long imei) {
+ public static long luhn(long imei) {
long checksum = 0;
long remain = imei;
diff --git a/src/org/traccar/protocol/AplicomProtocolDecoder.java b/src/org/traccar/protocol/AplicomProtocolDecoder.java
index aa9dd57d1..c134a282e 100644
--- a/src/org/traccar/protocol/AplicomProtocolDecoder.java
+++ b/src/org/traccar/protocol/AplicomProtocolDecoder.java
@@ -40,7 +40,7 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder {
private static final long IMEI_BASE_TC65I_V11 = 0x14143B4000000L;
private static boolean validateImei(long imei) {
- return Checksum.luhnChecksum(imei / 10) == imei % 10;
+ return Checksum.luhn(imei / 10) == imei % 10;
}
private static long imeiFromUnitId(long unitId) {
diff --git a/src/org/traccar/protocol/CityeasyProtocolDecoder.java b/src/org/traccar/protocol/CityeasyProtocolDecoder.java
index 457ba9c5d..b08eb6c2d 100644
--- a/src/org/traccar/protocol/CityeasyProtocolDecoder.java
+++ b/src/org/traccar/protocol/CityeasyProtocolDecoder.java
@@ -72,7 +72,7 @@ public class CityeasyProtocolDecoder extends BaseProtocolDecoder {
String imei = ChannelBufferTools.readHexString(buf, 14);
if (!identify(imei, channel, null, false)) {
- if (!identify(imei + Checksum.luhnChecksum(Long.parseLong(imei)), channel)) {
+ if (!identify(imei + Checksum.luhn(Long.parseLong(imei)), channel)) {
return null;
}
}
diff --git a/src/org/traccar/protocol/GpsGateProtocolDecoder.java b/src/org/traccar/protocol/GpsGateProtocolDecoder.java
index 3994587bf..729a824cc 100644
--- a/src/org/traccar/protocol/GpsGateProtocolDecoder.java
+++ b/src/org/traccar/protocol/GpsGateProtocolDecoder.java
@@ -48,7 +48,7 @@ public class GpsGateProtocolDecoder extends BaseProtocolDecoder {
private void send(Channel channel, String message) {
if (channel != null) {
- channel.write(message + Checksum.nmeaChecksum(message) + "\r\n");
+ channel.write(message + Checksum.nmea(message) + "\r\n");
}
}
diff --git a/src/org/traccar/protocol/KhdProtocolDecoder.java b/src/org/traccar/protocol/KhdProtocolDecoder.java
index 3ad6761cd..9e3249a7a 100644
--- a/src/org/traccar/protocol/KhdProtocolDecoder.java
+++ b/src/org/traccar/protocol/KhdProtocolDecoder.java
@@ -136,7 +136,7 @@ public class KhdProtocolDecoder extends BaseProtocolDecoder {
response.writeByte(buf.readUnsignedByte());
response.writeByte(type);
response.writeByte(0); // reserved
- response.writeByte(Checksum.xorChecksum(response.toByteBuffer()));
+ response.writeByte(Checksum.xor(response.toByteBuffer()));
response.writeByte(0x0D); // ending
channel.write(response);
diff --git a/src/org/traccar/protocol/KhdProtocolEncoder.java b/src/org/traccar/protocol/KhdProtocolEncoder.java
index ca2407743..a33fa34c2 100644
--- a/src/org/traccar/protocol/KhdProtocolEncoder.java
+++ b/src/org/traccar/protocol/KhdProtocolEncoder.java
@@ -38,7 +38,7 @@ public class KhdProtocolEncoder extends BaseProtocolEncoder {
buf.writeInt(0); // terminal id
- buf.writeByte(Checksum.xorChecksum(buf.toByteBuffer()));
+ buf.writeByte(Checksum.xor(buf.toByteBuffer()));
buf.writeByte(0x0D); // ending
return buf;
diff --git a/src/org/traccar/protocol/LaipacProtocolDecoder.java b/src/org/traccar/protocol/LaipacProtocolDecoder.java
index 57dd797eb..825ec1eda 100644
--- a/src/org/traccar/protocol/LaipacProtocolDecoder.java
+++ b/src/org/traccar/protocol/LaipacProtocolDecoder.java
@@ -121,7 +121,7 @@ public class LaipacProtocolDecoder extends BaseProtocolDecoder {
if (type.equals("0") && Character.isLowerCase(status.charAt(0))) {
response = "$EAVACK,0," + checksum;
- response += Checksum.nmeaChecksum(response);
+ response += Checksum.nmea(response);
} else if (type.equals("S") || type.equals("T")) {
response = "$AVCFG,00000000,t*21";
} else if (type.equals("3")) {
diff --git a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
index 51587f3b5..bde28492f 100644
--- a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
+++ b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
@@ -100,7 +100,7 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder {
if (id.length() == 14) {
// Try to recreate full IMEI number
// Sometimes first digit is cut, so this won't work
- if (identify(id + Checksum.luhnChecksum(Long.valueOf(id)), channel, null, false)) {
+ if (identify(id + Checksum.luhn(Long.valueOf(id)), channel, null, false)) {
return true;
}
}