aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/org/traccar/protocol/EelinkProtocolDecoder.java32
-rw-r--r--test/org/traccar/protocol/EelinkProtocolDecoderTest.java3
2 files changed, 35 insertions, 0 deletions
diff --git a/src/org/traccar/protocol/EelinkProtocolDecoder.java b/src/org/traccar/protocol/EelinkProtocolDecoder.java
index fce176ec5..2a1db2e32 100644
--- a/src/org/traccar/protocol/EelinkProtocolDecoder.java
+++ b/src/org/traccar/protocol/EelinkProtocolDecoder.java
@@ -327,6 +327,34 @@ public class EelinkProtocolDecoder extends BaseProtocolDecoder {
return position;
}
+ private Position decodeObd(DeviceSession deviceSession, ByteBuf buf, int index) {
+
+ Position position = new Position(getProtocolName());
+ position.setDeviceId(deviceSession.getDeviceId());
+
+ getLastLocation(position, new Date(buf.readUnsignedInt() * 1000));
+
+ while (buf.readableBytes() > 0) {
+ int pid = buf.readUnsignedByte();
+ int value = buf.readInt();
+ switch (pid) {
+ case 0x89:
+ position.set(Position.KEY_FUEL_CONSUMPTION, value);
+ break;
+ case 0x8a:
+ position.set(Position.KEY_ODOMETER, value * 1000L);
+ break;
+ case 0x8b:
+ position.set(Position.KEY_FUEL_LEVEL, value / 10);
+ break;
+ default:
+ break;
+ }
+ }
+
+ return position;
+ }
+
@Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
@@ -395,6 +423,10 @@ public class EelinkProtocolDecoder extends BaseProtocolDecoder {
return position;
+ } else if (type == MSG_OBD) {
+
+ return decodeObd(deviceSession, buf, index);
+
} else if (type == MSG_DOWNLINK) {
return decodeResult(deviceSession, buf, index);
diff --git a/test/org/traccar/protocol/EelinkProtocolDecoderTest.java b/test/org/traccar/protocol/EelinkProtocolDecoderTest.java
index f8a16c46f..dedae479d 100644
--- a/test/org/traccar/protocol/EelinkProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/EelinkProtocolDecoderTest.java
@@ -14,6 +14,9 @@ public class EelinkProtocolDecoderTest extends ProtocolTest {
verifyNull(decoder, binary(
"454C0027E753035254407167747167670100180002035254407167747100200205020500010432000086BD"));
+ verifyAttributes(decoder, binary(
+ "676707006502df5c89fde800bc3fa8030302005555045b555555057a5555550b225555550c105c55550d115555550e7e5555550f4555555510017b5555112b5555551f01ed5555208005b0012100005555407ad000004237f5555589000000498a0000aef78b00000000"));
+
verifyAttribute(decoder, binary(
"676712003400e45c5b0ade02012e03702d87064546aa24066a1086018a0000002dc1a0ffffffff0afd074d000000000000000000000000fce0"),
Position.PREFIX_TEMP + 2, -50.0);