diff options
Diffstat (limited to 'src/org')
-rw-r--r-- | src/org/traccar/protocol/T800xProtocolDecoder.java | 9 | ||||
-rw-r--r-- | src/org/traccar/protocol/TotemProtocolDecoder.java | 20 |
2 files changed, 15 insertions, 14 deletions
diff --git a/src/org/traccar/protocol/T800xProtocolDecoder.java b/src/org/traccar/protocol/T800xProtocolDecoder.java index a6a647f22..7bc780c83 100644 --- a/src/org/traccar/protocol/T800xProtocolDecoder.java +++ b/src/org/traccar/protocol/T800xProtocolDecoder.java @@ -49,11 +49,10 @@ public class T800xProtocolDecoder extends BaseProtocolDecoder { return ChannelBuffers.wrappedBuffer(ByteOrder.LITTLE_ENDIAN, bytes).readFloat(); } - private void sendResponse(Channel channel, int type, ChannelBuffer imei) { + private void sendResponse(Channel channel, short header, int type, ChannelBuffer imei) { if (channel != null) { ChannelBuffer response = ChannelBuffers.directBuffer(15); - response.writeByte(0x23); - response.writeByte(0x23); // header + response.writeShort(header); response.writeByte(type); response.writeShort(response.capacity()); // length response.writeShort(0x0001); // index @@ -87,7 +86,7 @@ public class T800xProtocolDecoder extends BaseProtocolDecoder { ChannelBuffer buf = (ChannelBuffer) msg; - buf.skipBytes(2); + short header = buf.readShort(); int type = buf.readUnsignedByte(); buf.readUnsignedShort(); // length int index = buf.readUnsignedShort(); @@ -100,7 +99,7 @@ public class T800xProtocolDecoder extends BaseProtocolDecoder { } if (type == MSG_LOGIN || type == MSG_ALARM || type == MSG_HEARTBEAT) { - sendResponse(channel, type, imei); + sendResponse(channel, header, type, imei); } if (type == MSG_GPS || type == MSG_ALARM) { diff --git a/src/org/traccar/protocol/TotemProtocolDecoder.java b/src/org/traccar/protocol/TotemProtocolDecoder.java index 06a1fbc41..d8943abd5 100644 --- a/src/org/traccar/protocol/TotemProtocolDecoder.java +++ b/src/org/traccar/protocol/TotemProtocolDecoder.java @@ -245,12 +245,13 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder { 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)); @@ -258,11 +259,12 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder { 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()); |