diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2019-04-17 23:22:40 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2019-04-17 23:22:40 -0700 |
commit | b81ad0b7a0ef5a5c9d68bbd13b9f46f746c419da (patch) | |
tree | 832a4ac419eacca9ae053d2cdaf42de7d579aba4 /src/main | |
parent | 1def70dc531b5ce7d1fd5e00b530f1c91c128840 (diff) | |
download | trackermap-server-b81ad0b7a0ef5a5c9d68bbd13b9f46f746c419da.tar.gz trackermap-server-b81ad0b7a0ef5a5c9d68bbd13b9f46f746c419da.tar.bz2 trackermap-server-b81ad0b7a0ef5a5c9d68bbd13b9f46f746c419da.zip |
Decode missing attributes
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/org/traccar/protocol/ItsProtocolDecoder.java | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/src/main/java/org/traccar/protocol/ItsProtocolDecoder.java b/src/main/java/org/traccar/protocol/ItsProtocolDecoder.java index e452ce01b..306e2a1f7 100644 --- a/src/main/java/org/traccar/protocol/ItsProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/ItsProtocolDecoder.java @@ -23,6 +23,8 @@ import org.traccar.Protocol; import org.traccar.helper.Parser; import org.traccar.helper.PatternBuilder; import org.traccar.helper.UnitsConverter; +import org.traccar.model.CellTower; +import org.traccar.model.Network; import org.traccar.model.Position; import java.net.SocketAddress; @@ -43,7 +45,7 @@ public class ItsProtocolDecoder extends BaseProtocolDecoder { .expression("[^,]+,") // firmware version .expression("(..),") // status .number("(d+),") // event - .expression("[LH],") // history + .expression("([LH]),") // history .or() .expression("([^,]+),") // type .groupEnd() @@ -72,10 +74,10 @@ public class ItsProtocolDecoder extends BaseProtocolDecoder { .number("([01]),") // charging .number("(d+.?d*),") // power .number("(d+.?d*),") // battery - .number("[01],") // emergency + .number("([01]),") // emergency .expression("[CO]?,") // tamper - .number("(?:x+,){5}") // main cell - .number("(?:-?x+,){12}") // other cells + .number("((?:x+,){5}") // main cell + .number("(?:-?x+,){12})") // other cells .number("([01]{4}),") // inputs .number("([01]{2}),") // outputs .groupBegin() @@ -130,6 +132,7 @@ public class ItsProtocolDecoder extends BaseProtocolDecoder { String status = parser.next(); Integer event = parser.nextInt(); + boolean history = "H".equals(parser.next()); String type = parser.next(); DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next()); @@ -147,6 +150,9 @@ public class ItsProtocolDecoder extends BaseProtocolDecoder { if (event != null) { position.set(Position.KEY_EVENT, event); } + if (history) { + position.set(Position.KEY_ARCHIVE, true); + } if (parser.hasNext()) { status = parser.next(); @@ -171,12 +177,30 @@ public class ItsProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_SATELLITES, parser.nextInt()); } - if (parser.hasNext(7)) { + if (parser.hasNext(8)) { position.setAltitude(parser.nextDouble()); position.set(Position.KEY_IGNITION, parser.nextInt() > 0); position.set(Position.KEY_CHARGE, parser.nextInt() > 0); position.set(Position.KEY_POWER, parser.nextDouble()); position.set(Position.KEY_BATTERY, parser.nextDouble()); + + position.set("emergency", parser.nextInt() > 0); + + String[] cells = parser.next().split(","); + int mcc = Integer.parseInt(cells[1]); + int mnc = Integer.parseInt(cells[2]); + int lac = Integer.parseInt(cells[3], 16); + int cid = Integer.parseInt(cells[4], 16); + Network network = new Network(CellTower.from(mcc, mnc, lac, cid, Integer.parseInt(cells[0]))); + for (int i = 0; i < 4; i++) { + lac = Integer.parseInt(cells[5 + 3 * i + 1], 16); + cid = Integer.parseInt(cells[5 + 3 * i + 2], 16); + if (lac > 0 && cid > 0) { + network.addCellTower(CellTower.from(mcc, mnc, lac, cid)); + } + } + position.setNetwork(network); + position.set(Position.KEY_INPUT, parser.nextBinInt()); position.set(Position.KEY_OUTPUT, parser.nextBinInt()); } |