diff options
-rw-r--r-- | src/org/traccar/protocol/AquilaProtocolDecoder.java | 22 | ||||
-rw-r--r-- | test/org/traccar/protocol/AquilaProtocolDecoderTest.java | 3 |
2 files changed, 19 insertions, 6 deletions
diff --git a/src/org/traccar/protocol/AquilaProtocolDecoder.java b/src/org/traccar/protocol/AquilaProtocolDecoder.java index 638affdc3..d8081612d 100644 --- a/src/org/traccar/protocol/AquilaProtocolDecoder.java +++ b/src/org/traccar/protocol/AquilaProtocolDecoder.java @@ -42,6 +42,7 @@ public class AquilaProtocolDecoder extends BaseProtocolDecoder { .number("(dd)(dd)(dd)") // date (yymmdd) .number("(dd)(dd)(dd),") // time (hhmmss) .expression("([AV]),") // validity + .groupBegin() .number("(d+),") // gsm .number("(d+),") // speed .number("(d+),") // distance @@ -120,6 +121,10 @@ public class AquilaProtocolDecoder extends BaseProtocolDecoder { .number("(d+),") // external voltage .number("(d+),") // internal voltage .groupEnd() + .or() + .number("(d+),") // sensor id + .expression("([^,]+),") // sensor data + .groupEnd() .text("*") .number("xx") // checksum .compile(); @@ -150,11 +155,11 @@ public class AquilaProtocolDecoder extends BaseProtocolDecoder { position.setValid(parser.next().equals("A")); - position.set(Position.KEY_RSSI, parser.nextInt(0)); - - position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble(0))); - - position.set(Position.KEY_ODOMETER, parser.nextInt(0)); + if (parser.hasNext(3)) { + position.set(Position.KEY_RSSI, parser.nextInt(0)); + position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble(0))); + position.set(Position.KEY_ODOMETER, parser.nextInt(0)); + } if (parser.hasNext(9)) { @@ -186,7 +191,7 @@ public class AquilaProtocolDecoder extends BaseProtocolDecoder { String dtcs = parser.next(); position.set(Position.KEY_DTCS, dtcs.substring(1, dtcs.length() - 1).replace('|', ' ')); - } else { + } else if (parser.hasNext(10)) { position.setCourse(parser.nextInt(0)); @@ -200,6 +205,11 @@ public class AquilaProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_POWER, parser.nextInt(0)); position.set(Position.KEY_BATTERY, parser.nextInt(0)); + } else if (parser.hasNext(2)) { + + position.set("sensorId", parser.nextInt()); + position.set("sensorData", parser.next()); + } return position; diff --git a/test/org/traccar/protocol/AquilaProtocolDecoderTest.java b/test/org/traccar/protocol/AquilaProtocolDecoderTest.java index 8844dafd2..1148896c1 100644 --- a/test/org/traccar/protocol/AquilaProtocolDecoderTest.java +++ b/test/org/traccar/protocol/AquilaProtocolDecoderTest.java @@ -11,6 +11,9 @@ public class AquilaProtocolDecoderTest extends ProtocolTest { AquilaProtocolDecoder decoder = new AquilaProtocolDecoder(new AquilaProtocol()); verifyPosition(decoder, text( + "$$CLIENT_1ZF,170215089,20,18.462809,73.824188,170613182744,A,01,123456,*37")); + + verifyPosition(decoder, text( "$$CLIENT_1ZF,170215089,1,18.462809,73.824188,170613182744,A,19,0,0,256,4,4.860000,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,259,3731,*37")); verifyPosition(decoder, text( |