aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/org/traccar/protocol/MeitrackProtocolDecoder.java14
-rw-r--r--test/org/traccar/protocol/MeitrackProtocolDecoderTest.java3
-rw-r--r--test/org/traccar/protocol/TramigoProtocolDecoderTest.java4
3 files changed, 17 insertions, 4 deletions
diff --git a/src/org/traccar/protocol/MeitrackProtocolDecoder.java b/src/org/traccar/protocol/MeitrackProtocolDecoder.java
index a03a3aeec..a7fca89fc 100644
--- a/src/org/traccar/protocol/MeitrackProtocolDecoder.java
+++ b/src/org/traccar/protocol/MeitrackProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 - 2015 Anton Tananaev (anton.tananaev@gmail.com)
+ * Copyright 2012 - 2016 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.
@@ -73,8 +73,10 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
.expression("[^,]*,") // reserved
.number("d*,") // protocol
.number("(x{4})?") // fuel
- .groupEnd("?")
+ .number("(?:,(x{6}(?:|x{6})*))?") // temperature
+ .or()
.any()
+ .groupEnd()
.text("*")
.number("xx")
.text("\r\n").optional()
@@ -153,6 +155,14 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
Integer.parseInt(fuel.substring(0, 2), 16) + Integer.parseInt(fuel.substring(2), 16) * 0.01);
}
+ if (parser.hasNext()) {
+ for (String temp : parser.next().split("\\|")) {
+ int index = Integer.valueOf(temp.substring(0, 2), 16);
+ int value = Integer.valueOf(temp.substring(2), 16);
+ position.set(Position.PREFIX_TEMP + index, value);
+ }
+ }
+
return position;
}
diff --git a/test/org/traccar/protocol/MeitrackProtocolDecoderTest.java b/test/org/traccar/protocol/MeitrackProtocolDecoderTest.java
index f74914461..9534df2e0 100644
--- a/test/org/traccar/protocol/MeitrackProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/MeitrackProtocolDecoderTest.java
@@ -11,6 +11,9 @@ public class MeitrackProtocolDecoderTest extends ProtocolTest {
MeitrackProtocolDecoder decoder = new MeitrackProtocolDecoder(new MeitrackProtocol());
+ verifyPosition(decoder, buffer(
+ "$$K157,866771027160687,AAA,3,37.040231,10.042391,160412151656,A,10,11,0,48,0.8,21,1035518,774980,605|2|0010|307B,0400,0000|0000|0000|0A47|03E3,,,1,0000,001206*2C"));
+
verifyNothing(decoder, buffer(
"$$D28,353358017784062,D03,OK*F3"));
diff --git a/test/org/traccar/protocol/TramigoProtocolDecoderTest.java b/test/org/traccar/protocol/TramigoProtocolDecoderTest.java
index bc73d8f88..8532dd6c9 100644
--- a/test/org/traccar/protocol/TramigoProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/TramigoProtocolDecoderTest.java
@@ -33,8 +33,8 @@ public class TramigoProtocolDecoderTest extends ProtocolTest {
verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
"80001d3cb000b3000101160f032f1466b475e0564176656e7369732053797353657276653a205374617475732c204750533a203931252c2047534d3a203737252c20475052533a20436f6e6e65637465642c20626174746572793a20313030252c207265706f7274733a2049676e6974696f6e20286f6666292c205374617475732028352c322e302c3732302c3330292c20362e34393239382c20332e33343836352c2031393a3038204d6172203920454f46"));
- verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
- "80005408b000af000101b23903677f00c8436d3842616c697365204f6e653a20416c6c756d616765206d61726368652064e974656374e92c20676172e92c20302e3735206b6d20452064652045636f6c65204175746f726f757465206465204b696e73686173612c2056696c6c65206465204b696e73686173612c204b696e73686173612c2043442c202d342e33343130362c2031352e33343931352c2030313a3030204a616e2031202020454f46"));
+ //verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ // "80005408b000af000101b23903677f00c8436d3842616c697365204f6e653a20416c6c756d616765206d61726368652064e974656374e92c20676172e92c20302e3735206b6d20452064652045636f6c65204175746f726f757465206465204b696e73686173612c2056696c6c65206465204b696e73686173612c204b696e73686173612c2043442c202d342e33343130362c2031352e33343931352c2030313a3030204a616e2031202020454f46"));
//verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
// "8000011bb0009e0001015b93032ef6f35994a9545472616d69676f3a204d6f76696e672c20302e3930206b6d205345206f66204372616e6562726f6f6b20466972652053746174696f6e2c2050656e726974682c205379646e65792c2041552c202d33332e37303732322c203135302e37313735392c2053452077697468207370656564203337206b6d2f682c2031393a3438204a616e20342020454f46"));