diff options
Diffstat (limited to 'src/org/traccar/protocol/TotemProtocolDecoder.java')
-rw-r--r-- | src/org/traccar/protocol/TotemProtocolDecoder.java | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/src/org/traccar/protocol/TotemProtocolDecoder.java b/src/org/traccar/protocol/TotemProtocolDecoder.java index 7140190da..86ee09d95 100644 --- a/src/org/traccar/protocol/TotemProtocolDecoder.java +++ b/src/org/traccar/protocol/TotemProtocolDecoder.java @@ -50,9 +50,9 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder { .number("(dd)(dd)(dd)") // date .expression("[^*]*").text("*") .number("xx|") // checksum - .number("d+.d+|") // pdop + .number("(d+.d+)|") // pdop .number("(d+.d+)|") // hdop - .number("d+.d+|") // vdop + .number("(d+.d+)|") // vdop .number("(d+)|") // io status .number("d+|") // time .number("d") // charged @@ -151,7 +151,7 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder { .number("(xxxx)") // lac .number("(xxxx)") // cid .number("(dd)") // satellites - .number("(dd)") // gsm + .number("(dd)") // gsm (rssi) .number("(ddd)") // course .number("(ddd)") // speed .number("(dd.d)") // hdop @@ -218,11 +218,11 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_ALARM, decodeAlarm(Short.parseShort(parser.next(), 16))); } DateBuilder dateBuilder = new DateBuilder(); - int year = 0; + int year = 0, month = 0, day = 0; if (pattern == PATTERN2) { - dateBuilder.setDay(parser.nextInt()).setMonth(parser.nextInt()); - year = parser.nextInt(); - dateBuilder.setYear(year); + day = parser.nextInt(); + month = parser.nextInt(); + year = parser.nextInt(); } dateBuilder.setTime(parser.nextInt(), parser.nextInt(), parser.nextInt()); @@ -233,16 +233,24 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder { position.setCourse(parser.nextDouble()); if (pattern == PATTERN1) { - dateBuilder.setDay(parser.nextInt()).setMonth(parser.nextInt()); - year = parser.nextInt(); - dateBuilder.setYear(year); + day = parser.nextInt(); + month = parser.nextInt(); + year = parser.nextInt(); } if (year == 0) { return null; // ignore invalid data } + dateBuilder.setDate(year, month, day); position.setTime(dateBuilder.getDate()); - position.set(Position.KEY_HDOP, parser.next()); + if (pattern == PATTERN1) { + position.set("pdop", parser.next()); + position.set(Position.KEY_HDOP, parser.next()); + position.set("vdop", parser.next()); + } else if (pattern == PATTERN2) { + position.set(Position.KEY_HDOP, parser.next()); + } + position.set(Position.PREFIX_IO + 1, parser.next()); position.set(Position.KEY_BATTERY, parser.next()); position.set(Position.KEY_POWER, parser.nextDouble()); @@ -279,19 +287,15 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder { position.setValid(parser.next().equals("A")); position.set(Position.KEY_SATELLITES, parser.next()); - position.setCourse(parser.nextDouble()); position.setSpeed(parser.nextDouble()); - position.set("pdop", parser.next()); - position.set(Position.KEY_ODOMETER, parser.next()); position.setLatitude(parser.nextCoordinate()); position.setLongitude(parser.nextCoordinate()); } else if (pattern == PATTERN4) { - position.set(Position.KEY_STATUS, parser.next()); DateBuilder dateBuilder = new DateBuilder() @@ -309,22 +313,19 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder { position.set(Position.PREFIX_TEMP + 1, parser.next()); position.set(Position.PREFIX_TEMP + 2, parser.next()); - position.setNetwork(new Network( - CellTower.fromLacCid(parser.nextInt(16), parser.nextInt(16)))); - + CellTower cellTower = CellTower.fromLacCid(parser.nextInt(16), parser.nextInt(16)); position.set(Position.KEY_SATELLITES, parser.nextInt()); - position.set(Position.KEY_RSSI, parser.nextInt()); + cellTower.setSignalStrength(parser.nextInt()); + position.setNetwork(new Network(cellTower)); position.setCourse(parser.nextDouble()); position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble())); - position.set(Position.KEY_HDOP, parser.nextDouble()); position.set(Position.KEY_ODOMETER, parser.nextInt() * 1000); position.setValid(true); position.setLatitude(parser.nextCoordinate()); position.setLongitude(parser.nextCoordinate()); - } if (channel != null) { channel.write("ACK OK\r\n"); |