aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-03-17 22:28:02 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2017-03-17 22:28:02 +1300
commitb2a61d29b0c4304613d5618e9953ec3721aee842 (patch)
tree7734588ce8bf8db07694a8456692fa8d58a769e2
parent73667548d1d83cdfbd6b4a76e0321698cad0fd4b (diff)
downloadtrackermap-server-b2a61d29b0c4304613d5618e9953ec3721aee842.tar.gz
trackermap-server-b2a61d29b0c4304613d5618e9953ec3721aee842.tar.bz2
trackermap-server-b2a61d29b0c4304613d5618e9953ec3721aee842.zip
Decode additional H02 parameters
-rw-r--r--src/org/traccar/protocol/H02ProtocolDecoder.java24
-rw-r--r--test/org/traccar/protocol/H02ProtocolDecoderTest.java6
2 files changed, 29 insertions, 1 deletions
diff --git a/src/org/traccar/protocol/H02ProtocolDecoder.java b/src/org/traccar/protocol/H02ProtocolDecoder.java
index 6ab997b86..5291107ee 100644
--- a/src/org/traccar/protocol/H02ProtocolDecoder.java
+++ b/src/org/traccar/protocol/H02ProtocolDecoder.java
@@ -142,6 +142,7 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder {
position.setCourse((buf.readUnsignedByte() & 0x0f) * 100.0 + BcdUtil.readInteger(buf, 2));
processStatus(position, buf.readUnsignedInt());
+
return position;
}
@@ -170,7 +171,18 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder {
.number("(?:(dd)(dd)(dd))?") // date (ddmmyy)
.any()
.number(",(x{8})") // status
- .expression("(?:#|,.*)")
+ .groupBegin()
+ .number(",(d+),") // odometer
+ .number("(-?d+),") // temperature
+ .number("(d+.d+),") // fuel
+ .number("(-?d+),") // altitude
+ .number("(x+),") // lac
+ .number("(x+)#") // cid
+ .or()
+ .expression(",.*")
+ .or()
+ .text("#")
+ .groupEnd()
.compile();
private static final Pattern PATTERN_NBR = new PatternBuilder()
@@ -240,6 +252,16 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder {
processStatus(position, parser.nextLong(16));
+ if (parser.hasNext(6)) {
+ position.set(Position.KEY_ODOMETER, parser.nextInt());
+ position.set(Position.PREFIX_TEMP + 1, parser.nextInt());
+ position.set(Position.KEY_FUEL_LEVEL, parser.nextDouble());
+
+ position.setAltitude(parser.nextInt());
+
+ position.setNetwork(new Network(CellTower.fromLacCid(parser.nextInt(16), parser.nextInt(16))));
+ }
+
return position;
}
diff --git a/test/org/traccar/protocol/H02ProtocolDecoderTest.java b/test/org/traccar/protocol/H02ProtocolDecoderTest.java
index 27b41f4e8..ad3a2e589 100644
--- a/test/org/traccar/protocol/H02ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/H02ProtocolDecoderTest.java
@@ -10,6 +10,12 @@ public class H02ProtocolDecoderTest extends ProtocolTest {
H02ProtocolDecoder decoder = new H02ProtocolDecoder(new H02Protocol());
+ verifyPosition(decoder, binary(
+ "2421305109380127171003170520046500100286297e003085ffffdfffff03440069129344006400001151415a20"));
+
+ verifyPosition(decoder, buffer(
+ "*HQ,2130510938,V1,012632,A,0520.0663,N,10028.6324,E,0.286,023,100317,FFFFDFFF,69129336,0,100.0,18,5141,5A20#"));
+
verifyPosition(decoder, buffer(
"*HQ,4210209006,V1,201812,A,2608.9437,N,08016.2521,W,000.80,000,150317,EFE7F9FF,310,260,0,0,6#"));