aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-10-18 15:14:21 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2018-10-18 15:14:21 +1300
commit0ef38f25be2c6931be8a4cc2e8fc6d3d351e122c (patch)
tree179be99c90195b639d66d447aca252626da2c43b
parent92fa5f43ccf7471c3afa7c18bbef868ba76afd35 (diff)
downloadtrackermap-server-0ef38f25be2c6931be8a4cc2e8fc6d3d351e122c.tar.gz
trackermap-server-0ef38f25be2c6931be8a4cc2e8fc6d3d351e122c.tar.bz2
trackermap-server-0ef38f25be2c6931be8a4cc2e8fc6d3d351e122c.zip
Implement AutoTrack response
-rw-r--r--src/org/traccar/protocol/AutoTrackProtocolDecoder.java20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/org/traccar/protocol/AutoTrackProtocolDecoder.java b/src/org/traccar/protocol/AutoTrackProtocolDecoder.java
index 43b273be5..fabf2ffda 100644
--- a/src/org/traccar/protocol/AutoTrackProtocolDecoder.java
+++ b/src/org/traccar/protocol/AutoTrackProtocolDecoder.java
@@ -42,8 +42,10 @@ public class AutoTrackProtocolDecoder extends BaseProtocolDecoder {
public static final int MSG_TELEMETRY_2 = 66;
public static final int MSG_TELEMETRY_3 = 67;
public static final int MSG_KEEP_ALIVE = 114;
+ public static final int MSG_TELEMETRY_CONFIRM = 123;
- private Position decodeTelemetry(DeviceSession deviceSession, ByteBuf buf) {
+ private Position decodeTelemetry(
+ Channel channel, SocketAddress remoteAddress, DeviceSession deviceSession, ByteBuf buf) {
Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
@@ -56,6 +58,7 @@ public class AutoTrackProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_FUEL_USED, buf.readUnsignedIntLE());
position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedShortLE()));
+ buf.readUnsignedShortLE(); // max speed
position.set(Position.KEY_INPUT, buf.readUnsignedShortLE());
buf.readUnsignedIntLE(); // di 3 count
@@ -70,10 +73,21 @@ public class AutoTrackProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_STATUS, buf.readUnsignedShortLE());
position.set(Position.KEY_EVENT, buf.readUnsignedShortLE());
position.set(Position.KEY_DRIVER_UNIQUE_ID, buf.readLongLE());
- position.set(Position.KEY_INDEX, buf.readUnsignedShortLE());
+
+ int index = buf.readUnsignedShortLE();
buf.readUnsignedShortLE(); // checksum
+ if (channel != null) {
+ ByteBuf response = Unpooled.buffer();
+ response.writeInt(0xF1F1F1F1); // sync
+ response.writeByte(MSG_TELEMETRY_CONFIRM);
+ response.writeShortLE(2); // length
+ response.writeShortLE(index);
+ response.writeShort(Checksum.crc16(Checksum.CRC16_XMODEM, response.nioBuffer()));
+ channel.writeAndFlush(new NetworkMessage(response, remoteAddress));
+ }
+
return position;
}
@@ -115,7 +129,7 @@ public class AutoTrackProtocolDecoder extends BaseProtocolDecoder {
if (deviceSession == null) {
return null;
}
- return decodeTelemetry(deviceSession, buf);
+ return decodeTelemetry(channel, remoteAddress, deviceSession, buf);
default:
return null;
}