diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2019-08-25 16:52:58 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2019-08-25 16:52:58 -0700 |
commit | 9f0531ee394ff9f3722d3238964e0d12c83e739e (patch) | |
tree | 73c220258a015515f66f4a071ec1d8dd396f152c | |
parent | 523f4b0c7d1b849f57347e45e6ebbec4c4d0baf3 (diff) | |
download | trackermap-server-9f0531ee394ff9f3722d3238964e0d12c83e739e.tar.gz trackermap-server-9f0531ee394ff9f3722d3238964e0d12c83e739e.tar.bz2 trackermap-server-9f0531ee394ff9f3722d3238964e0d12c83e739e.zip |
Support CT10 model
-rw-r--r-- | src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java | 81 | ||||
-rw-r--r-- | src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java | 3 |
2 files changed, 84 insertions, 0 deletions
diff --git a/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java index eeb0ae9f2..dc7a95955 100644 --- a/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java @@ -81,6 +81,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { public static final int MSG_X1_PHOTO_INFO = 0x35; public static final int MSG_X1_PHOTO_DATA = 0x36; public static final int MSG_WIFI_2 = 0x69; + public static final int MSG_GPS_MODULAR = 0x70; public static final int MSG_COMMAND_0 = 0x80; public static final int MSG_COMMAND_1 = 0x81; public static final int MSG_COMMAND_2 = 0x82; @@ -955,6 +956,10 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { return position; + } else if (type == MSG_GPS_MODULAR) { + + return decodeExtendedModular(channel, buf, deviceSession, type); + } else { return decodeExtendedOther(channel, buf, deviceSession, type); @@ -964,6 +969,82 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { return null; } + private Object decodeExtendedModular(Channel channel, ByteBuf buf, DeviceSession deviceSession, int type) { + + Position position = new Position(getProtocolName()); + position.setDeviceId(deviceSession.getDeviceId()); + + while (buf.readableBytes() > 6) { + int moduleType = buf.readUnsignedShort(); + int moduleLength = buf.readUnsignedShort(); + switch (moduleType) { + case 0x18: + position.set(Position.KEY_BATTERY, buf.readUnsignedShort() * 0.01); + break; + case 0x28: + position.set(Position.KEY_HDOP, buf.readUnsignedByte() * 0.1); + break; + case 0x29: + position.set(Position.KEY_INDEX, buf.readUnsignedInt()); + break; + case 0x2a: + position.set(Position.KEY_INPUT, buf.readUnsignedByte()); + break; + case 0x2b: + int event = buf.readUnsignedByte(); + switch (event) { + case 0x11: + position.set(Position.KEY_ALARM, Position.ALARM_LOW_BATTERY); + break; + case 0x12: + position.set(Position.KEY_ALARM, Position.ALARM_LOW_POWER); + break; + case 0x13: + position.set(Position.KEY_ALARM, Position.ALARM_POWER_CUT); + break; + case 0x14: + position.set(Position.KEY_ALARM, Position.ALARM_REMOVING); + break; + default: + break; + } + position.set(Position.KEY_EVENT, event); + break; + case 0x2e: + position.set(Position.KEY_ODOMETER, buf.readUnsignedIntLE()); + break; + case 0x33: + position.setTime(new Date(buf.readUnsignedInt() * 1000)); + position.set(Position.KEY_SATELLITES, buf.readUnsignedByte()); + position.setAltitude(buf.readShort()); + + double latitude = buf.readUnsignedInt() / 60.0 / 30000.0; + double longitude = buf.readUnsignedInt() / 60.0 / 30000.0; + position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedByte())); + + int flags = buf.readUnsignedShort(); + position.setCourse(BitUtil.to(flags, 10)); + position.setValid(BitUtil.check(flags, 12)); + + if (!BitUtil.check(flags, 10)) { + latitude = -latitude; + } + if (BitUtil.check(flags, 11)) { + longitude = -longitude; + } + + position.setLatitude(latitude); + position.setLongitude(longitude); + break; + default: + buf.skipBytes(moduleLength); + break; + } + } + + return position; + } + private Object decodeExtendedOther(Channel channel, ByteBuf buf, DeviceSession deviceSession, int type) { Position position = null; diff --git a/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java index 09270faff..caa354e54 100644 --- a/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java @@ -17,6 +17,9 @@ public class Gt06ProtocolDecoderTest extends ProtocolTest { verifyNull(decoder, binary( "78780D01086471700328358100093F040D0A")); + verifyPosition(decoder, binary( + "797900a87000000001020035000100003300125d62bf3a0800e804b5994308814a87001d5d00340006115d62bf29000011000a012e02620000000000000001000803537601000129800002000803102608593397620003000a8901260852293397626600180002017d002b000116002c00045d6278ea0009000108000a00010b002800010b002e00040000f0c1002a00010000290004000000be0030000a000100b4000a00b402d00006c5490d0a")); + verifyAttribute(decoder, binary( "797900149b03023539303042343843454238410300139ba40d0a"), Position.KEY_DRIVER_UNIQUE_ID, "5900B48CEB"); |