diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2019-08-18 21:12:22 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2019-08-18 21:12:22 -0700 |
commit | 44ff8dfdfe6342354077a21e22f2cf7444f84c1b (patch) | |
tree | e662bd620354295ca614f6b5ef3cb4d86d1c7b0b | |
parent | 4f0e955b7bfec804dd64ded8c3801bbc9f9a3445 (diff) | |
download | traccar-server-44ff8dfdfe6342354077a21e22f2cf7444f84c1b.tar.gz traccar-server-44ff8dfdfe6342354077a21e22f2cf7444f84c1b.tar.bz2 traccar-server-44ff8dfdfe6342354077a21e22f2cf7444f84c1b.zip |
Decode additional attributes
-rw-r--r-- | src/main/java/org/traccar/protocol/T800xProtocolDecoder.java | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/src/main/java/org/traccar/protocol/T800xProtocolDecoder.java b/src/main/java/org/traccar/protocol/T800xProtocolDecoder.java index 4351a14bf..9b146ec90 100644 --- a/src/main/java/org/traccar/protocol/T800xProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/T800xProtocolDecoder.java @@ -31,6 +31,7 @@ import org.traccar.model.CellTower; import org.traccar.model.Network; import org.traccar.model.Position; +import java.math.BigInteger; import java.net.SocketAddress; import java.nio.charset.StandardCharsets; import java.util.Date; @@ -265,14 +266,39 @@ public class T800xProtocolDecoder extends BaseProtocolDecoder { if (header == 0x2727) { - buf.skipBytes(5); // acceleration + byte[] accelerationBytes = new byte[5]; + buf.readBytes(accelerationBytes); + long acceleration = new BigInteger(accelerationBytes).longValue(); + double accelerationZ = BitUtil.between(acceleration, 8, 15) + BitUtil.between(acceleration, 4, 8) * 0.1; + if (!BitUtil.check(acceleration, 15)) { + accelerationZ = -accelerationZ; + } + double accelerationY = BitUtil.between(acceleration, 20, 27) + BitUtil.between(acceleration, 16, 20) * 0.1; + if (!BitUtil.check(acceleration, 27)) { + accelerationY = -accelerationY; + } + double accelerationX = BitUtil.between(acceleration, 28, 32) + BitUtil.between(acceleration, 32, 39) * 0.1; + if (!BitUtil.check(acceleration, 39)) { + accelerationX = -accelerationX; + } + position.set(Position.KEY_G_SENSOR, "[" + accelerationX + "," + accelerationY + "," + accelerationZ + "]"); + position.set(Position.KEY_BATTERY_LEVEL, BcdUtil.readInteger(buf, 2)); position.set(Position.KEY_DEVICE_TEMP, (int) buf.readByte()); position.set("lightSensor", BcdUtil.readInteger(buf, 2) * 0.1); position.set(Position.KEY_BATTERY, BcdUtil.readInteger(buf, 2) * 0.1); position.set("solarPanel", BcdUtil.readInteger(buf, 2) * 0.1); position.set(Position.KEY_ODOMETER, buf.readUnsignedInt()); - position.set(Position.KEY_IGNITION, BitUtil.check(buf.readUnsignedShort(), 2)); + + int inputStatus = buf.readUnsignedShort(); + position.set(Position.KEY_IGNITION, BitUtil.check(inputStatus, 2)); + position.set(Position.KEY_RSSI, BitUtil.between(inputStatus, 4, 11)); + + buf.readUnsignedShort(); // ignition on upload interval + buf.readUnsignedInt(); // ignition off upload interval + buf.readUnsignedByte(); // angle upload interval + buf.readUnsignedShort(); // distance upload interval + buf.readUnsignedByte(); // heartbeat } else if (buf.readableBytes() >= 2) { |