From ae6630ed4a88eabc71abd7252edbf6c6c127996a Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 27 Mar 2017 05:23:18 +1300 Subject: Add support for WLINK router --- .../traccar/protocol/HomtecsProtocolDecoder.java | 26 ++++++++++++++++------ 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'src/org') diff --git a/src/org/traccar/protocol/HomtecsProtocolDecoder.java b/src/org/traccar/protocol/HomtecsProtocolDecoder.java index 2557e1ac7..375fa27b8 100644 --- a/src/org/traccar/protocol/HomtecsProtocolDecoder.java +++ b/src/org/traccar/protocol/HomtecsProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Anton Tananaev (anton@traccar.org) + * Copyright 2016 - 2017 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. @@ -32,7 +32,9 @@ public class HomtecsProtocolDecoder extends BaseProtocolDecoder { } private static final Pattern PATTERN = new PatternBuilder() - .expression("([^,]+),") // id + .expression("([^_]+)") // id + .text("_R") + .number("(x{8}),") // mac ending .number("(dd)(dd)(dd),") // date (yymmdd) .number("(dd)(dd)(dd).d+,") // time (hhmmss) .number("(d+),") // satellites @@ -42,7 +44,9 @@ public class HomtecsProtocolDecoder extends BaseProtocolDecoder { .expression("([EW]),") .number("(d+.?d*)?,") // speed .number("(d+.?d*)?,") // course - .any() + .number("(d),") // fix status + .number("(d+.?d*)?,") // hdop + .number("(d+.?d*)?") // altitude .compile(); @Override @@ -54,18 +58,20 @@ public class HomtecsProtocolDecoder extends BaseProtocolDecoder { return null; } - Position position = new Position(); - position.setProtocol(getProtocolName()); + String id = parser.next(); + String mac = parser.next(); - DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next()); + DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, id, id + "_R" + mac); if (deviceSession == null) { return null; } + + Position position = new Position(); + position.setProtocol(getProtocolName()); position.setDeviceId(deviceSession.getDeviceId()); position.setTime(parser.nextDateTime(Parser.DateTimeFormat.YMD_HMS)); - position.setValid(true); position.set(Position.KEY_SATELLITES, parser.nextInt()); position.setLatitude(parser.nextCoordinate()); @@ -73,6 +79,12 @@ public class HomtecsProtocolDecoder extends BaseProtocolDecoder { position.setSpeed(parser.nextDouble()); position.setCourse(parser.nextDouble()); + position.setValid(parser.nextInt() > 0); + + position.set(Position.KEY_HDOP, parser.nextDouble()); + + position.setAltitude(parser.nextDouble()); + return position; } -- cgit v1.2.3