aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/org/traccar/protocol/EelinkProtocolDecoder.java37
1 files changed, 26 insertions, 11 deletions
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());
+ }
}