diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2019-06-02 12:19:27 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2019-06-02 12:19:27 -0700 |
commit | 86822bb4b96637a9db32c3299dfee5614cfceda8 (patch) | |
tree | 770652a6d40751d7607c74d2aa721e3fc7c47b8f /src/main/java/org/traccar/protocol/ItsProtocolDecoder.java | |
parent | aa421b17d86b70f80f84c4d7c086a1e56bb80059 (diff) | |
download | trackermap-server-86822bb4b96637a9db32c3299dfee5614cfceda8.tar.gz trackermap-server-86822bb4b96637a9db32c3299dfee5614cfceda8.tar.bz2 trackermap-server-86822bb4b96637a9db32c3299dfee5614cfceda8.zip |
Implement GYPSEE protocol
Diffstat (limited to 'src/main/java/org/traccar/protocol/ItsProtocolDecoder.java')
-rw-r--r-- | src/main/java/org/traccar/protocol/ItsProtocolDecoder.java | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/src/main/java/org/traccar/protocol/ItsProtocolDecoder.java b/src/main/java/org/traccar/protocol/ItsProtocolDecoder.java index 8c1b9b480..d76d9c92e 100644 --- a/src/main/java/org/traccar/protocol/ItsProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/ItsProtocolDecoder.java @@ -44,7 +44,7 @@ public class ItsProtocolDecoder extends BaseProtocolDecoder { .expression("[^,]+,") // vendor .expression("[^,]+,") // firmware version .expression("(..),") // status - .number("(d+),") // event + .number("(d+),").optional() // event .expression("([LH]),") // history .or() .expression("([^,]+),") // type @@ -56,7 +56,7 @@ public class ItsProtocolDecoder extends BaseProtocolDecoder { .expression("[^,]*,") // vehicle registration .number("([01]),").optional() // valid .groupEnd() - .number("(dd),?(dd),?(dddd),") // date (ddmmyyyy) + .number("(dd),?(dd),?(d{2,4}),") // date (ddmmyyyy) .number("(dd),?(dd),?(dd),") // time (hhmmss) .expression("([01AV]),").optional() // valid .number("(d+.d+),([NS]),") // latitude @@ -69,16 +69,15 @@ public class ItsProtocolDecoder extends BaseProtocolDecoder { .number("(d+.?d*),") // altitude .number("d+.?d*,") // pdop .number("d+.?d*,") // hdop - .expression("[^,]*,") + .expression("[^,]*,") // operator .number("([01]),") // ignition .number("([01]),") // charging .number("(d+.?d*),") // power .number("(d+.?d*),") // battery .number("([01]),") // emergency .expression("[CO]?,") // tamper - .number("((?:x+,){5}") // main cell - .number("(?:-?x+,){12})") // other cells - .number("([01]{4}),") // inputs + .expression("(.*),") // cells + .number("([012]{4}),") // inputs .number("([01]{2}),") // outputs .groupBegin() .number("d+,") // index @@ -202,16 +201,22 @@ public class ItsProtocolDecoder extends BaseProtocolDecoder { 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)); + if (!cells[5].startsWith("(")) { + 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()); + String input = parser.next(); + if (input.charAt(input.length() - 1) == '2') { + input = input.substring(0, input.length() - 1) + '0'; + } + position.set(Position.KEY_INPUT, Integer.parseInt(input, 2)); position.set(Position.KEY_OUTPUT, parser.nextBinInt()); } |