From 002f3d47cc4a31268dd2c0b018f70a0042268e0d Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 10 May 2014 19:00:58 +1200 Subject: Extend Meitrack protocol --- .../traccar/protocol/MeitrackProtocolDecoder.java | 27 +++++++++++++++++++--- .../protocol/MeitrackProtocolDecoderTest.java | 3 +++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/org/traccar/protocol/MeitrackProtocolDecoder.java b/src/org/traccar/protocol/MeitrackProtocolDecoder.java index ac72ea9d0..e2f31b207 100644 --- a/src/org/traccar/protocol/MeitrackProtocolDecoder.java +++ b/src/org/traccar/protocol/MeitrackProtocolDecoder.java @@ -37,7 +37,7 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder { "\\$\\$." + // Flag "\\d+," + // Length "(\\d+)," + // IMEI - "[0-9a-fA-F]{3}," + // Command + "\\p{XDigit}{3}," + // Command "(\\d+)," + // Event "(-?\\d+\\.\\d+)," + // Latitude "(-?\\d+\\.\\d+)," + // Longitude @@ -51,6 +51,14 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder { "(\\d+\\.?\\d*)," + // HDOP "(-?\\d+)," + // Altitude "(\\d+)," + // Milage + "(\\d+)," + // Runtime + "(\\d+\\|\\d+\\|\\p{XDigit}+\\|\\p{XDigit}+)," + // Cell + "(\\p{XDigit}+)," + // State + "(\\p{XDigit}+)\\|" + // ADC1 + "(\\p{XDigit}+)\\|" + // ADC2 + "(\\p{XDigit}+)?\\|" + // ADC3 + "(\\p{XDigit}+)\\|" + // Battery + "(\\p{XDigit}+)," + // Power ".*"); // TODO: parse other stuff @Override @@ -119,9 +127,22 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder { // Altitude position.setAltitude(Double.valueOf(parser.group(index++))); - // Milage + // Other extendedInfo.set("milage", parser.group(index++)); - + extendedInfo.set("runtime", parser.group(index++)); + extendedInfo.set("cell", parser.group(index++)); + extendedInfo.set("state", parser.group(index++)); + + // ADC + extendedInfo.set("adc1", Integer.parseInt(parser.group(index++), 16)); + extendedInfo.set("adc2", Integer.parseInt(parser.group(index++), 16)); + String adc3 = parser.group(index++); + if (adc3 != null) { + extendedInfo.set("adc3", Integer.parseInt(adc3, 16)); + } + extendedInfo.set("battery", Integer.parseInt(parser.group(index++), 16)); + extendedInfo.set("power", Integer.parseInt(parser.group(index++), 16)); + // Extended info position.setExtendedInfo(extendedInfo.toString()); diff --git a/test/org/traccar/protocol/MeitrackProtocolDecoderTest.java b/test/org/traccar/protocol/MeitrackProtocolDecoderTest.java index e59c2ad98..57a496798 100644 --- a/test/org/traccar/protocol/MeitrackProtocolDecoderTest.java +++ b/test/org/traccar/protocol/MeitrackProtocolDecoderTest.java @@ -38,6 +38,9 @@ public class MeitrackProtocolDecoderTest { verify(decoder.decode(null, null, "$$K146,013227004985762,AAA,35,28.618005,-81.246783,131101213828,A,9,22,0,209,1.1,23,80974,1187923,310|260|2A13|634E,0000,0000|0000|0000|09DA|0B34,,*51")); + + verify(decoder.decode(null, null, + "$$E150,013777001165479,AAA,35,10.296601,123.872115,140501161505,A,4,22,1,170,1.4,77,39097,393563,515|3|A0CC|ED96,0000,0008|0003|0000|09D5|0000,,,1,0009*1E")); } -- cgit v1.2.3