aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/org/traccar/helper/Crc.java2
-rw-r--r--src/org/traccar/protocol/MeiligaoProtocolDecoder.java5
-rw-r--r--test/org/traccar/helper/CrcTest.java1
3 files changed, 3 insertions, 5 deletions
diff --git a/src/org/traccar/helper/Crc.java b/src/org/traccar/helper/Crc.java
index 418ec3132..522a25403 100644
--- a/src/org/traccar/helper/Crc.java
+++ b/src/org/traccar/helper/Crc.java
@@ -172,7 +172,7 @@ public class Crc {
remain /= 10;
}
- return 10 - (checksum % 10);
+ return (10 - (checksum % 10)) % 10;
}
}
diff --git a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
index c660107ca..faf3a5baf 100644
--- a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
+++ b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
@@ -98,14 +98,11 @@ 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 + Crc.luhnChecksum(Long.valueOf(id)), channel, null, false)) {
return true;
}
- } else if (id.length() > 15) {
- if (identify(id.substring(0, 15), channel, null, false)) {
- return true;
- }
}
return identify(id, channel);
diff --git a/test/org/traccar/helper/CrcTest.java b/test/org/traccar/helper/CrcTest.java
index 46e7dfc79..7bd4a0482 100644
--- a/test/org/traccar/helper/CrcTest.java
+++ b/test/org/traccar/helper/CrcTest.java
@@ -9,6 +9,7 @@ public class CrcTest {
public void testLuhnChecksum() {
Assert.assertEquals(7, Crc.luhnChecksum(12345678901234L));
+ Assert.assertEquals(0, Crc.luhnChecksum(63070019470771L));
}