diff options
-rw-r--r-- | src/org/traccar/protocol/OkoProtocolDecoder.java | 12 | ||||
-rw-r--r-- | test/org/traccar/protocol/OkoProtocolDecoderTest.java | 6 |
2 files changed, 12 insertions, 6 deletions
diff --git a/src/org/traccar/protocol/OkoProtocolDecoder.java b/src/org/traccar/protocol/OkoProtocolDecoder.java index 312127283..e86acf0b8 100644 --- a/src/org/traccar/protocol/OkoProtocolDecoder.java +++ b/src/org/traccar/protocol/OkoProtocolDecoder.java @@ -35,14 +35,14 @@ public class OkoProtocolDecoder extends BaseProtocolDecoder { private static final Pattern PATTERN = new PatternBuilder() .text("{") .number("(d{15}),").optional() // imei - .number("(dd)(dd)(dd).(ddd),") // time + .number("(dd)(dd)(dd).d+,") // time .expression("([AV]),") // validity .number("(dd)(dd.d+),") // latitude .expression("([NS]),") .number("(ddd)(dd.d+),") // longitude .expression("([EW]),") - .number("(d+.?d*),") // speed - .number("(d+.?d*),") // course + .number("(d+.?d*)?,") // speed + .number("(d+.?d*)?,") // course .number("(dd)(dd)(dd),") // date (ddmmyy) .number("(d+),") // satellites .number("(d+.d+),") // adc @@ -77,13 +77,13 @@ public class OkoProtocolDecoder extends BaseProtocolDecoder { position.setDeviceId(deviceSession.getDeviceId()); DateBuilder dateBuilder = new DateBuilder() - .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt(), parser.nextInt()); + .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt()); position.setValid(parser.next().equals("A")); position.setLatitude(parser.nextCoordinate()); position.setLongitude(parser.nextCoordinate()); - position.setSpeed(parser.nextDouble()); - position.setCourse(parser.nextDouble()); + position.setSpeed(parser.nextDouble(0)); + position.setCourse(parser.nextDouble(0)); dateBuilder.setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt()); position.setTime(dateBuilder.getDate()); diff --git a/test/org/traccar/protocol/OkoProtocolDecoderTest.java b/test/org/traccar/protocol/OkoProtocolDecoderTest.java index a13839d5b..7e913ca2b 100644 --- a/test/org/traccar/protocol/OkoProtocolDecoderTest.java +++ b/test/org/traccar/protocol/OkoProtocolDecoderTest.java @@ -11,6 +11,12 @@ public class OkoProtocolDecoderTest extends ProtocolTest { OkoProtocolDecoder decoder = new OkoProtocolDecoder(new OkoProtocol()); verifyPosition(decoder, text( + "{861694033681089,045403.00,A,4924.14181,N,03207.43787,E,0.080,,151117,07,0.00,01,24.8,1,02,5n4}")); + + verifyPosition(decoder, text( + "{045411.00,A,4924.14243,N,03207.43754,E,0.172,,151117,07,0.00,F9,28.1,2,C2,5n4}")); + + verifyPosition(decoder, text( "{861001001016415,115031.000,A,4804.101180,N,02255.227002,E,4.121,111.0,211215,6,0.00,F7,13.6,1,00")); verifyPosition(decoder, text( |