diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2019-05-29 23:09:44 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2019-05-29 23:09:44 -0700 |
commit | 1455296728b0199eb27b74ffed8b99c9171eb84f (patch) | |
tree | 77477ab167a4145ce879247e6e9e528dd290d21d | |
parent | 76d5d3dbabb1c81c96dc24091ab05c8b8d1756f7 (diff) | |
download | trackermap-server-1455296728b0199eb27b74ffed8b99c9171eb84f.tar.gz trackermap-server-1455296728b0199eb27b74ffed8b99c9171eb84f.tar.bz2 trackermap-server-1455296728b0199eb27b74ffed8b99c9171eb84f.zip |
Update TopFlyTech protocol
-rw-r--r-- | src/main/java/org/traccar/protocol/T800xProtocolDecoder.java | 65 | ||||
-rw-r--r-- | src/test/java/org/traccar/protocol/T800xProtocolDecoderTest.java | 3 |
2 files changed, 42 insertions, 26 deletions
diff --git a/src/main/java/org/traccar/protocol/T800xProtocolDecoder.java b/src/main/java/org/traccar/protocol/T800xProtocolDecoder.java index 96fb7f96a..03c64cfd5 100644 --- a/src/main/java/org/traccar/protocol/T800xProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/T800xProtocolDecoder.java @@ -44,6 +44,7 @@ public class T800xProtocolDecoder extends BaseProtocolDecoder { public static final int MSG_GPS = 0x02; public static final int MSG_HEARTBEAT = 0x03; public static final int MSG_ALARM = 0x04; + public static final int MSG_NETWORK = 0x05; public static final int MSG_COMMAND = 0x81; private void sendResponse(Channel channel, short header, int type, int index, ByteBuf imei, int alarm) { @@ -144,44 +145,56 @@ public class T800xProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_INDEX, index); - buf.readUnsignedShort(); // acc on interval - buf.readUnsignedShort(); // acc off interval - buf.readUnsignedByte(); // angle compensation - buf.readUnsignedShort(); // distance compensation + if (header != 0x2727) { - position.set(Position.KEY_RSSI, BitUtil.to(buf.readUnsignedShort(), 7)); + buf.readUnsignedShort(); // acc on interval + buf.readUnsignedShort(); // acc off interval + buf.readUnsignedByte(); // angle compensation + buf.readUnsignedShort(); // distance compensation + + position.set(Position.KEY_RSSI, BitUtil.to(buf.readUnsignedShort(), 7)); + + } int status = buf.readUnsignedByte(); position.set(Position.KEY_SATELLITES, BitUtil.to(status, 5)); - buf.readUnsignedByte(); // gsensor manager status - buf.readUnsignedByte(); // other flags - buf.readUnsignedByte(); // heartbeat - buf.readUnsignedByte(); // relay status - buf.readUnsignedShort(); // drag alarm setting - - int io = buf.readUnsignedShort(); - position.set(Position.KEY_IGNITION, BitUtil.check(io, 14)); - position.set("ac", BitUtil.check(io, 13)); - for (int i = 0; i <= 2; i++) { - position.set(Position.PREFIX_OUT + (i + 1), BitUtil.check(io, 7 + i)); - } + if (header != 0x2727) { + + buf.readUnsignedByte(); // gsensor manager status + buf.readUnsignedByte(); // other flags + buf.readUnsignedByte(); // heartbeat + buf.readUnsignedByte(); // relay status + buf.readUnsignedShort(); // drag alarm setting + + int io = buf.readUnsignedShort(); + position.set(Position.KEY_IGNITION, BitUtil.check(io, 14)); + position.set("ac", BitUtil.check(io, 13)); + for (int i = 0; i <= 2; i++) { + position.set(Position.PREFIX_OUT + (i + 1), BitUtil.check(io, 7 + i)); + } + + position.set(Position.PREFIX_ADC + 1, buf.readUnsignedShort()); + position.set(Position.PREFIX_ADC + 2, buf.readUnsignedShort()); - position.set(Position.PREFIX_ADC + 1, buf.readUnsignedShort()); - position.set(Position.PREFIX_ADC + 2, buf.readUnsignedShort()); + } int alarm = buf.readUnsignedByte(); position.set(Position.KEY_ALARM, decodeAlarm(alarm)); - buf.readUnsignedByte(); // reserved + if (header != 0x2727) { - position.set(Position.KEY_ODOMETER, buf.readUnsignedInt()); + buf.readUnsignedByte(); // reserved + + position.set(Position.KEY_ODOMETER, buf.readUnsignedInt()); + + int battery = BcdUtil.readInteger(buf, 2); + if (battery == 0) { + battery = 100; + } + position.set(Position.KEY_BATTERY, battery); - int battery = BcdUtil.readInteger(buf, 2); - if (battery == 0) { - battery = 100; } - position.set(Position.KEY_BATTERY, battery); DateBuilder dateBuilder = new DateBuilder() .setYear(BcdUtil.readInteger(buf, 2)) @@ -219,7 +232,7 @@ public class T800xProtocolDecoder extends BaseProtocolDecoder { } - if (buf.readableBytes() >= 2) { + if (header != 0x2727 && buf.readableBytes() >= 2) { position.set(Position.KEY_POWER, BcdUtil.readInteger(buf, 4) * 0.01); } diff --git a/src/test/java/org/traccar/protocol/T800xProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/T800xProtocolDecoderTest.java index bfe06b5cd..2afc0ef6f 100644 --- a/src/test/java/org/traccar/protocol/T800xProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/T800xProtocolDecoderTest.java @@ -12,6 +12,9 @@ public class T800xProtocolDecoderTest extends ProtocolTest { T800xProtocolDecoder decoder = new T800xProtocolDecoder(null); verifyNull(decoder, binary( + "2727010017000108806168988888881016010207110111")); + + verifyNull(decoder, binary( "252501001504050880061689888888111111250350")); verifyAttribute(decoder, binary( |