aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/org/traccar/protocol/HomtecsProtocolDecoder.java26
-rw-r--r--test/org/traccar/protocol/HomtecsProtocolDecoderTest.java6
2 files changed, 25 insertions, 7 deletions
diff --git a/src/org/traccar/protocol/HomtecsProtocolDecoder.java b/src/org/traccar/protocol/HomtecsProtocolDecoder.java
index 2557e1ac7..375fa27b8 100644
--- a/src/org/traccar/protocol/HomtecsProtocolDecoder.java
+++ b/src/org/traccar/protocol/HomtecsProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,7 +32,9 @@ public class HomtecsProtocolDecoder extends BaseProtocolDecoder {
}
private static final Pattern PATTERN = new PatternBuilder()
- .expression("([^,]+),") // id
+ .expression("([^_]+)") // id
+ .text("_R")
+ .number("(x{8}),") // mac ending
.number("(dd)(dd)(dd),") // date (yymmdd)
.number("(dd)(dd)(dd).d+,") // time (hhmmss)
.number("(d+),") // satellites
@@ -42,7 +44,9 @@ public class HomtecsProtocolDecoder extends BaseProtocolDecoder {
.expression("([EW]),")
.number("(d+.?d*)?,") // speed
.number("(d+.?d*)?,") // course
- .any()
+ .number("(d),") // fix status
+ .number("(d+.?d*)?,") // hdop
+ .number("(d+.?d*)?") // altitude
.compile();
@Override
@@ -54,18 +58,20 @@ public class HomtecsProtocolDecoder extends BaseProtocolDecoder {
return null;
}
- Position position = new Position();
- position.setProtocol(getProtocolName());
+ String id = parser.next();
+ String mac = parser.next();
- DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next());
+ DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, id, id + "_R" + mac);
if (deviceSession == null) {
return null;
}
+
+ Position position = new Position();
+ position.setProtocol(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
position.setTime(parser.nextDateTime(Parser.DateTimeFormat.YMD_HMS));
- position.setValid(true);
position.set(Position.KEY_SATELLITES, parser.nextInt());
position.setLatitude(parser.nextCoordinate());
@@ -73,6 +79,12 @@ public class HomtecsProtocolDecoder extends BaseProtocolDecoder {
position.setSpeed(parser.nextDouble());
position.setCourse(parser.nextDouble());
+ position.setValid(parser.nextInt() > 0);
+
+ position.set(Position.KEY_HDOP, parser.nextDouble());
+
+ position.setAltitude(parser.nextDouble());
+
return position;
}
diff --git a/test/org/traccar/protocol/HomtecsProtocolDecoderTest.java b/test/org/traccar/protocol/HomtecsProtocolDecoderTest.java
index 5b70453e0..7852fb0e3 100644
--- a/test/org/traccar/protocol/HomtecsProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/HomtecsProtocolDecoderTest.java
@@ -10,6 +10,12 @@ public class HomtecsProtocolDecoderTest extends ProtocolTest {
HomtecsProtocolDecoder decoder = new HomtecsProtocolDecoder(new HomtecsProtocol());
+ verifyNothing(decoder, text(
+ "MDS0001_R6d1821f7,170323,143601.00,04,,,,,,,,,"));
+
+ verifyPosition(decoder, text(
+ "MDS0001_R6d1821f7,170323,143621.00,06,5105.29914,N,11400.52675,W,0.223,198.41,1,2.12,1042.3"));
+
verifyPosition(decoder, text(
"strommabus939_R01272028,160217,191003.00,06,5540.12292,N,01237.49814,E,0.391,,1,1.27,1.2"));