diff options
Diffstat (limited to 'src/main/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()); } |