From 89a8132cdcd4a409adaf8eae6a18c97a640ab738 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 23 Mar 2019 12:05:35 -0700 Subject: Support eeLink OBD data --- .../traccar/protocol/EelinkProtocolDecoder.java | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src/org/traccar') 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); -- cgit v1.2.3