aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-03-17 16:59:51 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-03-17 16:59:51 +1300
commit8432b3660b7cc40c8734cc00817f176589d9d18e (patch)
treec3cba32d001839577a505b96b199b1667c3cedee /src
parent5adbbcff629056c0d811c9fd22e6a6af82c65ba9 (diff)
downloadtrackermap-server-8432b3660b7cc40c8734cc00817f176589d9d18e.tar.gz
trackermap-server-8432b3660b7cc40c8734cc00817f176589d9d18e.tar.bz2
trackermap-server-8432b3660b7cc40c8734cc00817f176589d9d18e.zip
Extend Meitrack decoder
Diffstat (limited to 'src')
-rw-r--r--src/org/traccar/protocol/MeitrackProtocolDecoder.java28
1 files changed, 25 insertions, 3 deletions
diff --git a/src/org/traccar/protocol/MeitrackProtocolDecoder.java b/src/org/traccar/protocol/MeitrackProtocolDecoder.java
index 2d8fa9511..cdeef155b 100644
--- a/src/org/traccar/protocol/MeitrackProtocolDecoder.java
+++ b/src/org/traccar/protocol/MeitrackProtocolDecoder.java
@@ -69,7 +69,11 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
"(\\p{XDigit}+)?\\|" + // ADC3
"(\\p{XDigit}+)\\|" + // Battery
"(\\p{XDigit}+)," + // Power
- ".*(\r\n)?");
+ "(?:([^,]+)?," + // Event Specific
+ "[^,]*," + // Reserved
+ "\\d*," + // Protocol
+ "(\\p{XDigit}{4})?)?" + // Fuel
+ ".*\\*\\p{XDigit}{2}(?:\r\n)?");
private Position decodeRegularMessage(Channel channel, ChannelBuffer buf) {
@@ -96,7 +100,8 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
}
// Event
- extendedInfo.set("event", parser.group(index++));
+ int event = Integer.valueOf(parser.group(index++));
+ extendedInfo.set("event", event);
// Coordinates
position.setLatitude(Double.valueOf(parser.group(index++)));
@@ -155,7 +160,24 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
}
extendedInfo.set("battery", Integer.parseInt(parser.group(index++), 16));
extendedInfo.set("power", Integer.parseInt(parser.group(index++), 16));
-
+
+ // Event specific
+ String data = parser.group(index++);
+ if (data != null && !data.isEmpty()) {
+ switch (event) {
+ case 37:
+ extendedInfo.set("rfid", data);
+ break;
+ }
+ }
+
+ // Fuel
+ String fuel = parser.group(index++);
+ if (fuel != null) {
+ extendedInfo.set("fuel",
+ Integer.parseInt(fuel.substring(0, 2), 16) + Integer.parseInt(fuel.substring(2), 16) * 0.01);
+ }
+
// Extended info
position.setExtendedInfo(extendedInfo.toString());