aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/protocol/MeiligaoProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/MeiligaoProtocolDecoder.java19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
index 43142744c..c660107ca 100644
--- a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
+++ b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
@@ -80,7 +80,7 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder {
private static final int MSG_RFID = 0x9966;
- private String getImei(ChannelBuffer buf) {
+ private boolean identify(ChannelBuffer buf, Channel channel) {
String id = "";
for (int i = 0; i < 7; i++) {
@@ -98,12 +98,17 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder {
}
if (id.length() == 14) {
- id += Crc.luhnChecksum(Long.valueOf(id)); // IMEI checksum
- }
- if (id.length() > 15) {
- id = id.substring(0, 15);
+ // 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 id;
+
+ return identify(id, channel);
}
private static void sendResponse(
@@ -189,7 +194,7 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder {
}
// Get device by id
- if (!identify(getImei(id), channel)) {
+ if (!identify(id, channel)) {
return null;
}
position.setDeviceId(getDeviceId());