diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2017-01-06 08:34:32 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2017-01-06 07:34:32 +1300 |
commit | 681057b88e91c5c64c1f6b8780676d5172ea7c6f (patch) | |
tree | 6c123dd6e0646935f624748c27c4db5d27a4d71a | |
parent | e87eddaf0b50fd95260b1b31e05f961c1aee0f4d (diff) | |
download | trackermap-server-681057b88e91c5c64c1f6b8780676d5172ea7c6f.tar.gz trackermap-server-681057b88e91c5c64c1f6b8780676d5172ea7c6f.tar.bz2 trackermap-server-681057b88e91c5c64c1f6b8780676d5172ea7c6f.zip |
Extend eelink protocol decoder
-rw-r--r-- | src/org/traccar/protocol/EelinkProtocolDecoder.java | 24 | ||||
-rw-r--r-- | test/org/traccar/protocol/EelinkProtocolDecoderTest.java | 3 |
2 files changed, 23 insertions, 4 deletions
diff --git a/src/org/traccar/protocol/EelinkProtocolDecoder.java b/src/org/traccar/protocol/EelinkProtocolDecoder.java index b1634042d..4b77b1ff6 100644 --- a/src/org/traccar/protocol/EelinkProtocolDecoder.java +++ b/src/org/traccar/protocol/EelinkProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2014 - 2016 Anton Tananaev (anton@traccar.org) + * Copyright 2014 - 2017 Anton Tananaev (anton@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -116,11 +116,27 @@ public class EelinkProtocolDecoder extends BaseProtocolDecoder { position.setValid((buf.readUnsignedByte() & 0x01) != 0); if (type == MSG_ALARM) { - position.set(Position.KEY_ALARM, buf.readUnsignedByte()); + position.set(Position.KEY_ALARM, decodeAlarm(buf.readUnsignedByte())); } - if (type == MSG_STATE) { - position.set(Position.KEY_STATUS, decodeAlarm(buf.readUnsignedByte())); + if (buf.readableBytes() >= 2 * 5) { + + int status = buf.readUnsignedShort(); + if (BitUtil.check(status, 1)) { + position.set(Position.KEY_IGNITION, BitUtil.check(status, 2)); + } + if (BitUtil.check(status, 7)) { + position.set(Position.KEY_CHARGE, BitUtil.check(status, 8)); + } + position.set(Position.KEY_STATUS, status); + + position.set(Position.KEY_BATTERY, buf.readUnsignedShort() + "mV"); + + buf.readUnsignedShort(); // signal strength + + position.set(Position.PREFIX_ADC + 1, buf.readUnsignedShort()); + position.set(Position.PREFIX_ADC + 2, buf.readUnsignedShort()); + } return position; diff --git a/test/org/traccar/protocol/EelinkProtocolDecoderTest.java b/test/org/traccar/protocol/EelinkProtocolDecoderTest.java index c1e913415..fd21d4713 100644 --- a/test/org/traccar/protocol/EelinkProtocolDecoderTest.java +++ b/test/org/traccar/protocol/EelinkProtocolDecoderTest.java @@ -14,6 +14,9 @@ public class EelinkProtocolDecoderTest extends ProtocolTest { "676701000c007b03525440717505180104")); verifyPosition(decoder, binary( + "676702002509f65868507603a1e92e03cf90fe000000019f000117ee00111e0120631145003101510000")); + + verifyPosition(decoder, binary( "676712001e0092579714d60201f90001785003a301cd1a006a118504f2000000000000")); verifyPosition(decoder, binary( |