diff options
author | Anton Tananaev <anton@traccar.org> | 2022-07-14 08:09:16 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-07-14 08:09:16 -0700 |
commit | a9199ab710056dda371aa3dd25cffc225374c0d6 (patch) | |
tree | d2d0fa417439777cde54bd4acc05e13d0a278323 /src/main/java/org/traccar/protocol | |
parent | 92807c47464a840999716d2e732f569351deaea0 (diff) | |
download | trackermap-server-a9199ab710056dda371aa3dd25cffc225374c0d6.tar.gz trackermap-server-a9199ab710056dda371aa3dd25cffc225374c0d6.tar.bz2 trackermap-server-a9199ab710056dda371aa3dd25cffc225374c0d6.zip |
Support AT20 protocol format
Diffstat (limited to 'src/main/java/org/traccar/protocol')
-rw-r--r-- | src/main/java/org/traccar/protocol/TotemProtocolDecoder.java | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/main/java/org/traccar/protocol/TotemProtocolDecoder.java b/src/main/java/org/traccar/protocol/TotemProtocolDecoder.java index 4f520f360..9d0d794f8 100644 --- a/src/main/java/org/traccar/protocol/TotemProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/TotemProtocolDecoder.java @@ -140,8 +140,12 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder { .number("(x{8})") // status .number("(dd)(dd)(dd)") // date (yymmdd) .number("(dd)(dd)(dd)") // time (hhmmss) + .groupBegin() .number("(dd)") // battery .number("(dd)") // external power + .or() + .number("(ddd)") // battery + .groupEnd() .number("(dddd)") // adc 1 .groupBegin() .groupBegin() @@ -166,6 +170,7 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder { .number("(d{7})") // odometer .number("(dd)(dd.dddd)([NS])") // latitude .number("(ddd)(dd.dddd)([EW])") // longitude + .number("dddd").optional() // temperature .number("dddd") // serial number .number("xx") // checksum .any() @@ -379,8 +384,13 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder { position.setTime(parser.nextDateTime()); - position.set(Position.KEY_BATTERY, parser.nextDouble() * 0.1); - position.set(Position.KEY_POWER, parser.nextDouble()); + if (parser.hasNext(2)) { + position.set(Position.KEY_BATTERY, parser.nextDouble() * 0.1); + position.set(Position.KEY_POWER, parser.nextDouble()); + } + if (parser.hasNext()) { + position.set(Position.KEY_BATTERY, parser.nextDouble() * 0.01); + } position.set(Position.PREFIX_ADC + 1, parser.next()); position.set(Position.PREFIX_ADC + 2, parser.next()); |