diff options
author | Anton Tananaev <anton@traccar.org> | 2024-02-17 07:13:09 -0800 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2024-02-17 07:13:09 -0800 |
commit | f632b15098776b35910834aabc35bb62737c6d78 (patch) | |
tree | 6509f75b7d629f636c1d80317c5e2b3488461293 /src/main/java/org/traccar/protocol | |
parent | 0c8b5c1ab1f83cc0fc6d2f17cdf808388b383e14 (diff) | |
download | trackermap-server-f632b15098776b35910834aabc35bb62737c6d78.tar.gz trackermap-server-f632b15098776b35910834aabc35bb62737c6d78.tar.bz2 trackermap-server-f632b15098776b35910834aabc35bb62737c6d78.zip |
Handle MT600 no location messages
Diffstat (limited to 'src/main/java/org/traccar/protocol')
-rw-r--r-- | src/main/java/org/traccar/protocol/Tlt2hProtocolDecoder.java | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/src/main/java/org/traccar/protocol/Tlt2hProtocolDecoder.java b/src/main/java/org/traccar/protocol/Tlt2hProtocolDecoder.java index 79488acc0..4b11cbc74 100644 --- a/src/main/java/org/traccar/protocol/Tlt2hProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/Tlt2hProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 - 2022 Anton Tananaev (anton@traccar.org) + * Copyright 2013 - 2024 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. @@ -63,8 +63,9 @@ public class Tlt2hProtocolDecoder extends BaseProtocolDecoder { .number("(x+)") // cell id .groupEnd("?") .text("$GPRMC,") - .number("(dd)(dd)(dd).d+,") // time (hhmmss.sss) + .number("(?:(dd)(dd)(dd).d+)?,") // time (hhmmss.sss) .expression("([AVL]),") // validity + .groupBegin() .number("(d+)(dd.d+),") // latitude .expression("([NS]),") .number("(d+)(dd.d+),") // longitude @@ -72,6 +73,7 @@ public class Tlt2hProtocolDecoder extends BaseProtocolDecoder { .number("(d+.?d*)?,") // speed .number("(d+.?d*)?,") // course .number("(dd)(dd)(dd)") // date (ddmmyy) + .groupEnd("?") .any() .compile(); @@ -190,17 +192,26 @@ public class Tlt2hProtocolDecoder extends BaseProtocolDecoder { position.setNetwork(network); } - DateBuilder dateBuilder = new DateBuilder() - .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt()); + DateBuilder dateBuilder = new DateBuilder(); + if (parser.hasNext(3)) { + dateBuilder.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(0)); - position.setCourse(parser.nextDouble(0)); - dateBuilder.setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt()); - position.setTime(dateBuilder.getDate()); + if (parser.hasNext()) { + + position.setLatitude(parser.nextCoordinate()); + position.setLongitude(parser.nextCoordinate()); + position.setSpeed(parser.nextDouble(0)); + position.setCourse(parser.nextDouble(0)); + + dateBuilder.setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt()); + position.setTime(dateBuilder.getDate()); + + } else { + getLastLocation(position, null); + } } else { continue; |