Skip to content

Commit

Permalink
Update Totem IO decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
tananaev committed May 5, 2018
1 parent 8f57a25 commit 7d8f1c6
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/org/traccar/protocol/TotemProtocolDecoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -245,24 +245,26 @@ private boolean decode12(Position position, Parser parser, Pattern pattern) {

int io = parser.nextBinInt();
if (pattern == PATTERN1) {
if (BitUtil.check(io, 0)) {
position.set(Position.KEY_ALARM, Position.ALARM_SOS);
}
for (int i = 1; i <= 4; i++) {
position.set(Position.PREFIX_IN + i, BitUtil.check(io, 3 + i));
}
position.set(Position.KEY_ALARM, BitUtil.check(io, 0) ? Position.ALARM_SOS : null);
position.set(Position.PREFIX_IN + 3, BitUtil.check(io, 4));
position.set(Position.PREFIX_IN + 4, BitUtil.check(io, 5));
position.set(Position.PREFIX_IN + 1, BitUtil.check(io, 6));
position.set(Position.PREFIX_IN + 2, BitUtil.check(io, 7));
position.set(Position.PREFIX_OUT + 1, BitUtil.check(io, 8));
position.set(Position.PREFIX_OUT + 2, BitUtil.check(io, 9));
position.set(Position.KEY_BATTERY, parser.nextDouble(0) * 0.01);
} else {
position.set(Position.KEY_ANTENNA, BitUtil.check(io, 0));
position.set(Position.KEY_CHARGE, BitUtil.check(io, 1));
for (int i = 1; i <= 6; i++) {
position.set(Position.PREFIX_IN + i, BitUtil.check(io, 1 + i));
}
for (int i = 1; i <= 4; i++) {
position.set(Position.PREFIX_OUT + i, BitUtil.check(io, 7 + i));
}
position.set(Position.KEY_BATTERY, parser.nextDouble(0) * 0.1);
}
for (int i = 1; i <= 4; i++) {
position.set(Position.PREFIX_OUT + i, BitUtil.check(io, 7 + i));
}

position.set(Position.KEY_POWER, parser.nextDouble(0));
position.set(Position.PREFIX_ADC + 1, parser.next());

Expand Down

0 comments on commit 7d8f1c6

Please sign in to comment.