diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2017-09-08 07:30:17 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2017-09-08 07:30:17 +1200 |
commit | e84d1addacd76c05416c31b9e10b6a1618e41c9d (patch) | |
tree | c90ec20591ec15e317231aee4a9e290956f204c0 /src/org | |
parent | 179373c6b3d619922a5daf98220ffe831f56fba2 (diff) | |
download | traccar-server-e84d1addacd76c05416c31b9e10b6a1618e41c9d.tar.gz traccar-server-e84d1addacd76c05416c31b9e10b6a1618e41c9d.tar.bz2 traccar-server-e84d1addacd76c05416c31b9e10b6a1618e41c9d.zip |
Improve H02 protocol decoder
Diffstat (limited to 'src/org')
-rw-r--r-- | src/org/traccar/protocol/H02ProtocolDecoder.java | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/src/org/traccar/protocol/H02ProtocolDecoder.java b/src/org/traccar/protocol/H02ProtocolDecoder.java index 091d97cdd..69e53ec27 100644 --- a/src/org/traccar/protocol/H02ProtocolDecoder.java +++ b/src/org/traccar/protocol/H02ProtocolDecoder.java @@ -150,9 +150,20 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder { .text("*") .expression("..,") // manufacturer .number("(d+),") // imei - .expression("[^,]+,") + .groupBegin() + .text("VP1,") + .expression("[ABV],") + .or() + .groupBegin() + .text("V1,") + .or() + .text("V4,") .any() + .or() + .text("V19,") + .groupEnd() .number("(?:(dd)(dd)(dd))?,") // time (hhmmss) + .groupEnd() .expression("([AV])?,") // validity .groupBegin() .number("-(d+)-(d+.d+),") // latitude @@ -169,25 +180,28 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder { .number("(d+.?d*),") // speed .number("(d+.?d*)?,") // course .number("(?:(dd)(dd)(dd))?") // date (ddmmyy) - .any() - .number(",(x{8})") // status + .groupBegin() + .expression(",[^,]*,") + .expression("[^,]*,") + .expression("[^,]*") // sim info + .groupEnd("?") + .groupBegin() + .number(",(x{8})") .groupBegin() .number(",(d+),") // odometer .number("(-?d+),") // temperature .number("(d+.d+),") // fuel .number("(-?d+),") // altitude .number("(x+),") // lac - .number("(x+)#") // cid + .number("(x+)") // cid .or() - .number(",(d+),") - .number("(d+),") - .number("(d+),") - .number("(d+)#") + .text(",") + .expression("(.*)") // data .or() - .expression(",.*") + .groupEnd() .or() - .text("#") .groupEnd() + .text("#") .compile(); private static final Pattern PATTERN_NBR = new PatternBuilder() @@ -289,7 +303,9 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder { position.setTime(new Date()); } - processStatus(position, parser.nextLong(16, 0)); + if (parser.hasNext()) { + processStatus(position, parser.nextLong(16, 0)); + } if (parser.hasNext(6)) { position.set(Position.KEY_ODOMETER, parser.nextInt(0)); @@ -302,8 +318,9 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder { } if (parser.hasNext(4)) { - for (int i = 1; i <= 4; i++) { - position.set(Position.PREFIX_IO + i, parser.nextInt(0)); + String[] values = parser.next().split(","); + for (int i = 0; i < values.length; i++) { + position.set(Position.PREFIX_IO + (i + 1), values[i].trim()); } } |