diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2017-11-01 22:57:10 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2017-11-01 22:57:10 +1300 |
commit | c62dd84c7ad4061c0c6d8a521c63857ccde461ba (patch) | |
tree | b664b0a5b3ce57020aa1cf48dbd6400313d72bb5 /src/org/traccar | |
parent | e82169ab20c6762d522168bbc062acf54e516777 (diff) | |
download | trackermap-server-c62dd84c7ad4061c0c6d8a521c63857ccde461ba.tar.gz trackermap-server-c62dd84c7ad4061c0c6d8a521c63857ccde461ba.tar.bz2 trackermap-server-c62dd84c7ad4061c0c6d8a521c63857ccde461ba.zip |
Support iStartrek VT900 protocol
Diffstat (limited to 'src/org/traccar')
-rw-r--r-- | src/org/traccar/helper/Parser.java | 16 | ||||
-rw-r--r-- | src/org/traccar/protocol/MeiligaoProtocolDecoder.java | 37 |
2 files changed, 33 insertions, 20 deletions
diff --git a/src/org/traccar/helper/Parser.java b/src/org/traccar/helper/Parser.java index 582b497cf..1471ec237 100644 --- a/src/org/traccar/helper/Parser.java +++ b/src/org/traccar/helper/Parser.java @@ -109,6 +109,22 @@ public class Parser { } } + public Long nextLong() { + if (hasNext()) { + return Long.parseLong(next()); + } else { + return null; + } + } + + public Long nextHexLong() { + if (hasNext()) { + return Long.parseLong(next(), 16); + } else { + return null; + } + } + public long nextLong(long defaultValue) { return nextLong(10, defaultValue); } diff --git a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java index 0b63620b5..b0793037f 100644 --- a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java +++ b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java @@ -57,11 +57,19 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { .number("|(xxxx)?") // state .groupBegin() .number("|(xxxx),(xxxx)") // adc - .number("(?:,(xxxx),(xxxx),(xxxx),(xxxx),(xxxx),(xxxx))?") + .number(",(xxxx)").optional() + .number(",(xxxx)").optional() + .number(",(xxxx)").optional() + .number(",(xxxx)").optional() + .number(",(xxxx)").optional() + .number(",(xxxx)").optional() .groupBegin() - .number("|x{16}") // cell - .number("|(xx)") // gsm + .number("|x{16,20}") // cell + .number("|(xx)") // rssi .number("|(x{8})") // odometer + .groupBegin() + .number("|(xx)") // satellites + .groupEnd("?") .or() .number("|(x{9})") // odometer .groupBegin() @@ -245,25 +253,14 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_STATUS, parser.next()); for (int i = 1; i <= 8; i++) { - if (parser.hasNext()) { - position.set(Position.PREFIX_ADC + i, parser.nextHexInt(0)); - } + position.set(Position.PREFIX_ADC + i, parser.nextHexInt()); } - if (parser.hasNext()) { - position.set(Position.KEY_RSSI, parser.nextHexInt(0)); - } - - if (parser.hasNext()) { - position.set(Position.KEY_ODOMETER, parser.nextLong(16, 0)); - } - if (parser.hasNext()) { - position.set(Position.KEY_ODOMETER, parser.nextLong(16, 0)); - } - - if (parser.hasNext()) { - position.set(Position.KEY_DRIVER_UNIQUE_ID, String.valueOf(parser.nextHexInt(0))); - } + position.set(Position.KEY_RSSI, parser.nextHexInt()); + position.set(Position.KEY_ODOMETER, parser.nextHexLong()); + position.set(Position.KEY_SATELLITES, parser.nextHexInt()); + position.set(Position.KEY_ODOMETER, parser.nextHexLong()); + position.set(Position.KEY_DRIVER_UNIQUE_ID, parser.next()); return position; } |