From ff949b7ee233cd343f1fb5bb5ef7db7f24991df0 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 29 Aug 2017 05:16:55 +1200 Subject: Fix eeLink status decoding --- .../traccar/protocol/EelinkProtocolDecoder.java | 37 +++++++++++++++------- 1 file changed, 26 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/org/traccar/protocol/EelinkProtocolDecoder.java b/src/org/traccar/protocol/EelinkProtocolDecoder.java index e16866977..11d111e54 100644 --- a/src/org/traccar/protocol/EelinkProtocolDecoder.java +++ b/src/org/traccar/protocol/EelinkProtocolDecoder.java @@ -131,22 +131,37 @@ public class EelinkProtocolDecoder extends BaseProtocolDecoder { position.setValid((buf.readUnsignedByte() & 0x01) != 0); - if (type == MSG_ALARM) { - position.set(Position.KEY_ALARM, decodeAlarm(buf.readUnsignedByte())); - } + if (type == MSG_GPS) { - if (buf.readableBytes() >= 2) { - decodeStatus(position, buf.readUnsignedShort()); - } + if (buf.readableBytes() >= 2) { + decodeStatus(position, buf.readUnsignedShort()); + } + + if (buf.readableBytes() >= 2 * 4) { + + position.set(Position.KEY_BATTERY, buf.readUnsignedShort() * 0.001); + + position.set(Position.KEY_RSSI, buf.readUnsignedShort()); - if (buf.readableBytes() >= 2 * 4) { + position.set(Position.PREFIX_ADC + 1, buf.readUnsignedShort()); + position.set(Position.PREFIX_ADC + 2, buf.readUnsignedShort()); - position.set(Position.KEY_BATTERY, buf.readUnsignedShort() * 0.001); + } + + } else if (type == MSG_ALARM) { + + position.set(Position.KEY_ALARM, decodeAlarm(buf.readUnsignedByte())); - position.set(Position.KEY_RSSI, buf.readUnsignedShort()); + } else if (type == MSG_STATE) { - position.set(Position.PREFIX_ADC + 1, buf.readUnsignedShort()); - position.set(Position.PREFIX_ADC + 2, buf.readUnsignedShort()); + int statusType = buf.readUnsignedByte(); + + position.set(Position.KEY_EVENT, statusType); + + if (statusType == 0x01 || statusType == 0x02 || statusType == 0x03) { + buf.readUnsignedInt(); // device time + decodeStatus(position, buf.readUnsignedShort()); + } } -- cgit v1.2.3