aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-10-01 14:45:47 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-10-01 14:45:47 +1300
commite84f02c3bffda311e86fab584d7c40702b5223be (patch)
treec0d67aeac4c4ae9e2d1d7134edf8e5a1df87717c /src/org/traccar/protocol
parent7c75b21d70faf046035a5cee14ea0b05c9d208f6 (diff)
downloadtrackermap-server-e84f02c3bffda311e86fab584d7c40702b5223be.tar.gz
trackermap-server-e84f02c3bffda311e86fab584d7c40702b5223be.tar.bz2
trackermap-server-e84f02c3bffda311e86fab584d7c40702b5223be.zip
Improve Meiligao device identification
Diffstat (limited to 'src/org/traccar/protocol')
-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());