diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2014-05-10 19:00:58 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2014-05-10 19:00:58 +1200 |
commit | 002f3d47cc4a31268dd2c0b018f70a0042268e0d (patch) | |
tree | a894196aa5428e141c2da616a1d41f020feff0fe | |
parent | 7ca0f09a4f07ece35e3294f9c22206205940440a (diff) | |
download | trackermap-server-002f3d47cc4a31268dd2c0b018f70a0042268e0d.tar.gz trackermap-server-002f3d47cc4a31268dd2c0b018f70a0042268e0d.tar.bz2 trackermap-server-002f3d47cc4a31268dd2c0b018f70a0042268e0d.zip |
Extend Meitrack protocol
-rw-r--r-- | src/org/traccar/protocol/MeitrackProtocolDecoder.java | 27 | ||||
-rw-r--r-- | test/org/traccar/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")); } |