From 9cc1c29ec08cdc4369b010ac17b270bf3c3d7ead Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 2 Nov 2020 20:47:48 -0800 Subject: Alternative smart crutches format --- .../traccar/protocol/FutureWayProtocolDecoder.java | 40 +++++++++++++++++----- 1 file changed, 31 insertions(+), 9 deletions(-) (limited to 'src/main') diff --git a/src/main/java/org/traccar/protocol/FutureWayProtocolDecoder.java b/src/main/java/org/traccar/protocol/FutureWayProtocolDecoder.java index 4b0f46e34..c2f3781d9 100644 --- a/src/main/java/org/traccar/protocol/FutureWayProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/FutureWayProtocolDecoder.java @@ -43,8 +43,13 @@ public class FutureWayProtocolDecoder extends BaseProtocolDecoder { .expression("([AV]),") // validity .number("(dd)(dd)(dd)") // date (yymmdd) .number("(dd)(dd)(dd),") // time (hhmmss) + .groupBegin() + .number("(dd)(dd.d+)([NS]),") // latitude + .number("(ddd)(dd.d+)([EW]),") // longitude + .or() .number("(d+.d+)([NS]),") // latitude .number("(d+.d+)([EW]),") // longitude + .groupEnd() .number("(d+.d+),") // speed .number("(d+.d+)") // course .compile(); @@ -90,27 +95,44 @@ public class FutureWayProtocolDecoder extends BaseProtocolDecoder { position.setValid(parser.next().equals("A")); position.setTime(parser.nextDateTime()); - position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_HEM)); - position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_HEM)); + + if (parser.hasNext(6)) { + position.setLatitude(parser.nextCoordinate()); + position.setLongitude(parser.nextCoordinate()); + } + + if (parser.hasNext(4)) { + position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_HEM)); + position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_HEM)); + } + position.setSpeed(parser.nextDouble()); position.setCourse(parser.nextDouble()); } else if (line.startsWith("WIFI")) { - for (String item : line.substring(line.indexOf(',') + 1).split("&")) { - String[] values = item.split("\\|"); - network.addWifiAccessPoint( - WifiAccessPoint.from(values[1].replace('-', ':'), Integer.parseInt(values[2]))); + if (line.contains(",")) { + for (String item : line.substring(line.indexOf(',') + 1).split("&")) { + String[] values = item.split("\\|"); + network.addWifiAccessPoint( + WifiAccessPoint.from(values[1].replace('-', ':'), Integer.parseInt(values[2]))); + } } } else if (line.startsWith("LBS")) { String[] values = line.substring("LBS:".length()).split(","); + int lac, cid; + if (Integer.parseInt(values[2]) > 65535) { + cid = Integer.parseInt(values[2]); + lac = Integer.parseInt(values[3]); + } else { + lac = Integer.parseInt(values[2]); + cid = Integer.parseInt(values[3]); + } network.addCellTower(CellTower.from( Integer.parseInt(values[0]), - Integer.parseInt(values[1]), - Integer.parseInt(values[3]), - Integer.parseInt(values[2]))); + Integer.parseInt(values[1]), lac, cid)); } -- cgit v1.2.3