diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2018-02-14 07:23:50 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2018-02-14 07:23:50 +1300 |
commit | ad5c4cb2031ff706c6416c6d24d1f5f421633f73 (patch) | |
tree | 154ea7a68ec5dbc0116c5636e5af0386e11d60db /src/org | |
parent | 6d259427bc72f1e48662a60542832cc73945e800 (diff) | |
download | trackermap-server-ad5c4cb2031ff706c6416c6d24d1f5f421633f73.tar.gz trackermap-server-ad5c4cb2031ff706c6416c6d24d1f5f421633f73.tar.bz2 trackermap-server-ad5c4cb2031ff706c6416c6d24d1f5f421633f73.zip |
Support IVT-100 and TL3000 protocols
Diffstat (limited to 'src/org')
-rw-r--r-- | src/org/traccar/protocol/Ivt401ProtocolDecoder.java | 62 |
1 files changed, 55 insertions, 7 deletions
diff --git a/src/org/traccar/protocol/Ivt401ProtocolDecoder.java b/src/org/traccar/protocol/Ivt401ProtocolDecoder.java index 936965707..6e11a763c 100644 --- a/src/org/traccar/protocol/Ivt401ProtocolDecoder.java +++ b/src/org/traccar/protocol/Ivt401ProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2017 Anton Tananaev (anton@traccar.org) + * Copyright 2017 - 2018 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. @@ -43,7 +43,7 @@ public class Ivt401ProtocolDecoder extends BaseProtocolDecoder { .number("(d+),") // speed .number("(d+),") // course .number("(-?d+.?d*),") // altitude - .number("(d+),") // satellites + .number("d+,") // satellites or battery status .number("(d),") // gps status .number("(d+),") // rssi .number("(d+),") // input @@ -51,6 +51,13 @@ public class Ivt401ProtocolDecoder extends BaseProtocolDecoder { .number("(d+.d+),") // adc .number("(d+.d+),") // power .number("(d+.d+),") // battery + .number("(-?d+.?d*),") // pcb temp + .expression("([^,]+),") // temp + .number("(d+),") // movement + .number("(d+.d+),") // acceleration + .number("(-?d+),") // tilt + .number("(d+),") // trip + .number("(d+),") // odometer .any() .compile(); @@ -78,17 +85,58 @@ public class Ivt401ProtocolDecoder extends BaseProtocolDecoder { position.setSpeed(UnitsConverter.knotsFromKph(parser.nextInt())); position.setCourse(parser.nextInt()); position.setAltitude(parser.nextDouble()); - - position.set(Position.KEY_SATELLITES, parser.nextInt()); - position.setValid(parser.nextInt() > 0); position.set(Position.KEY_RSSI, parser.nextInt()); - position.set(Position.KEY_INPUT, parser.nextBinInt()); - position.set(Position.KEY_OUTPUT, parser.nextBinInt()); + + String input = parser.next(); + for (int i = 0; i < input.length(); i++) { + int value = Character.getNumericValue(input.charAt(i)); + if (value < 2) { + position.set(Position.PREFIX_IN + (i + 1), value > 0); + } + } + + String output = parser.next(); + for (int i = 0; i < output.length(); i++) { + position.set(Position.PREFIX_OUT + (i + 1), Character.getNumericValue(output.charAt(i)) > 0); + } + position.set(Position.PREFIX_ADC + 1, parser.nextDouble()); position.set(Position.KEY_POWER, parser.nextDouble()); position.set(Position.KEY_BATTERY, parser.nextDouble()); + position.set(Position.KEY_DEVICE_TEMP, parser.nextDouble()); + + String temp = parser.next(); + if (temp.startsWith("M")) { + int index = 1; + int startIndex = 1; + int endIndex; + while (startIndex < temp.length()) { + endIndex = temp.indexOf('-', startIndex + 1); + if (endIndex < 0) { + endIndex = temp.indexOf('+', startIndex + 1); + } + if (endIndex < 0) { + endIndex = temp.length(); + } + if (endIndex > 0) { + double value = Double.parseDouble(temp.substring(startIndex, endIndex)); + position.set(Position.PREFIX_TEMP + index++, value); + } + startIndex = endIndex; + } + } else { + position.set(Position.PREFIX_TEMP + 1, Double.parseDouble(temp)); + } + + position.set(Position.KEY_MOTION, parser.nextInt() > 0); + position.set(Position.KEY_ACCELERATION, parser.nextDouble()); + + parser.nextInt(); // tilt + parser.nextInt(); // trip state + + position.set(Position.KEY_ODOMETER, parser.nextLong()); return position; } |