aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2019-04-17 19:27:01 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2019-04-17 19:27:01 -0700
commit1def70dc531b5ce7d1fd5e00b530f1c91c128840 (patch)
tree4c39a08dd1b8e0f866c9833c2b9a73d7af2d2735
parent385d0a34044065ab9d31ff793b8dfe6dc486f424 (diff)
downloadtrackermap-server-1def70dc531b5ce7d1fd5e00b530f1c91c128840.tar.gz
trackermap-server-1def70dc531b5ce7d1fd5e00b530f1c91c128840.tar.bz2
trackermap-server-1def70dc531b5ce7d1fd5e00b530f1c91c128840.zip
Support additional attributes
-rw-r--r--src/main/java/org/traccar/protocol/BoxProtocolDecoder.java13
-rw-r--r--src/test/java/org/traccar/protocol/BoxProtocolDecoderTest.java6
2 files changed, 18 insertions, 1 deletions
diff --git a/src/main/java/org/traccar/protocol/BoxProtocolDecoder.java b/src/main/java/org/traccar/protocol/BoxProtocolDecoder.java
index 3635c29e5..853fa8f81 100644
--- a/src/main/java/org/traccar/protocol/BoxProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/BoxProtocolDecoder.java
@@ -47,7 +47,10 @@ public class BoxProtocolDecoder extends BaseProtocolDecoder {
.number("(d+.?d*),") // distance
.number("(d+),") // event
.number("(d+)") // status
- .any()
+ .groupBegin()
+ .text(";")
+ .expression("(.+)")
+ .groupEnd("?")
.compile();
@Override
@@ -99,6 +102,14 @@ public class BoxProtocolDecoder extends BaseProtocolDecoder {
position.setValid(!BitUtil.check(status, 2));
position.set(Position.KEY_STATUS, status);
+ if (parser.hasNext()) {
+ String[] data = parser.next().split(";");
+ for (String item : data) {
+ int valueIndex = item.indexOf(',');
+ position.set(item.substring(0, valueIndex).toLowerCase(), item.substring(valueIndex + 1));
+ }
+ }
+
return position;
}
diff --git a/src/test/java/org/traccar/protocol/BoxProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/BoxProtocolDecoderTest.java
index d661a10f2..f7197a05d 100644
--- a/src/test/java/org/traccar/protocol/BoxProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/BoxProtocolDecoderTest.java
@@ -18,6 +18,12 @@ public class BoxProtocolDecoderTest extends ProtocolTest {
"H,BT,N878123,080415081234,D63E6DD9,6D6E6DC2,8944100300825505377"));
verifyPosition(decoder, text(
+ "L,190416090826,G,21.46701,39.18655,0,280,86.62,53,21;A,0;D,0;T0,34.2;I,0"));
+
+ verifyPosition(decoder, text(
+ "L,190416090926,G,21.46701,39.18655,0,280,86.62,7,20;A,0;D,0;T0,34.2;I,0;END,106,222,190416080509"));
+
+ verifyPosition(decoder, text(
"L,190227043304,G,25.68773,48.59788,71,53,261.42,1,23;A,0.03;D,0.06;I,0"));
verifyPosition(decoder, text(