aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2014-01-20 23:29:11 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2014-01-20 23:29:11 +1300
commitabbe79284a3c78125fc655329a0656428dcb2920 (patch)
tree55f4f0eebe5bca698fcd4541e01b544a14dca832 /src/org/traccar/protocol
parenta7dc44e7b2ebfd8ad70f274ce25727cc9d06118b (diff)
downloadtraccar-server-abbe79284a3c78125fc655329a0656428dcb2920.tar.gz
traccar-server-abbe79284a3c78125fc655329a0656428dcb2920.tar.bz2
traccar-server-abbe79284a3c78125fc655329a0656428dcb2920.zip
Extend meiligao id to IMEI
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r--src/org/traccar/protocol/MeiligaoProtocolDecoder.java15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
index b28b38dc8..7ad91a807 100644
--- a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
+++ b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 - 2013 Anton Tananaev (anton.tananaev@gmail.com)
+ * Copyright 2012 - 2014 Anton Tananaev (anton.tananaev@gmail.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -60,10 +60,7 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder {
"(?:\\|([0-9a-fA-F]+))?" + // Milage
".*"); // TODO: parse ADC
- /**
- * Parse device id
- */
- private String getId(ChannelBuffer buf) {
+ private String getImei(ChannelBuffer buf) {
String id = "";
for (int i = 0; i < 7; i++) {
@@ -80,7 +77,7 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder {
id += d2;
}
- return id;
+ return id + Crc.luhnChecksum(id);
}
@Override
@@ -135,11 +132,11 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder {
}
// Get device by id
- String id = getId(buf);
+ String imei = getImei(buf);
try {
- position.setDeviceId(getDataManager().getDeviceByImei(id).getId());
+ position.setDeviceId(getDataManager().getDeviceByImei(imei).getId());
} catch(Exception error) {
- Log.warning("Unknown device - " + id);
+ Log.warning("Unknown device - " + imei);
return null;
}