diff options
-rwxr-xr-x | src/org/traccar/protocol/AppelloProtocolDecoder.java | 18 | ||||
-rw-r--r-- | test/org/traccar/protocol/AppelloProtocolDecoderTest.java | 3 |
2 files changed, 16 insertions, 5 deletions
diff --git a/src/org/traccar/protocol/AppelloProtocolDecoder.java b/src/org/traccar/protocol/AppelloProtocolDecoder.java index f04623759..d422a5aa1 100755 --- a/src/org/traccar/protocol/AppelloProtocolDecoder.java +++ b/src/org/traccar/protocol/AppelloProtocolDecoder.java @@ -35,14 +35,18 @@ public class AppelloProtocolDecoder extends BaseProtocolDecoder { private static final Pattern PATTERN = new PatternBuilder() .text("FOLLOWIT,") // brand .number("(d+),") // imei + .groupBegin() .number("(dd)(dd)(dd)") // date .number("(dd)(dd)(dd).?d*,") // time + .or() + .text("UTCTIME,") + .groupEnd() .number("(-?d+.d+),") // latitude .number("(-?d+.d+),") // longitude .number("(d+),") // speed .number("(d+),") // course .number("(d+),") // satellites - .number("(d+),") // altitude + .number("(-?d+),") // altitude .expression("([FL]),") // gps state .any() .compile(); @@ -65,10 +69,14 @@ public class AppelloProtocolDecoder extends BaseProtocolDecoder { position.setProtocol(getProtocolName()); position.setDeviceId(getDeviceId()); - DateBuilder dateBuilder = new DateBuilder() - .setDate(parser.nextInt(), parser.nextInt(), parser.nextInt()) - .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt()); - position.setTime(dateBuilder.getDate()); + if (parser.hasNext(6)) { + DateBuilder dateBuilder = new DateBuilder() + .setDate(parser.nextInt(), parser.nextInt(), parser.nextInt()) + .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt()); + position.setTime(dateBuilder.getDate()); + } else { + getLastLocation(position, null); + } position.setLatitude(parser.nextDouble()); position.setLongitude(parser.nextDouble()); diff --git a/test/org/traccar/protocol/AppelloProtocolDecoderTest.java b/test/org/traccar/protocol/AppelloProtocolDecoderTest.java index 69fa9b52e..f83039265 100644 --- a/test/org/traccar/protocol/AppelloProtocolDecoderTest.java +++ b/test/org/traccar/protocol/AppelloProtocolDecoderTest.java @@ -9,6 +9,9 @@ public class AppelloProtocolDecoderTest extends ProtocolTest { public void testDecode() throws Exception { AppelloProtocolDecoder decoder = new AppelloProtocolDecoder(new AppelloProtocol()); + + verifyAttributes(decoder, text( + "FOLLOWIT,860719028336968,UTCTIME,-12.112660,-77.045189,0,0,3,-0,L,716,10,049C,2A47,23,,4.22,,53,999/00/00,,,,,,59826,")); verifyPosition(decoder, text( "FOLLOWIT,860719028336968,160211221959,-12.112660,-77.045258,1,0,6,116,F,716,17,4E85,050C,29,,4.22,,39,999/00/00,,,,,,46206,")); |