aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2021-01-04 22:30:19 -0800
committerAnton Tananaev <anton.tananaev@gmail.com>2021-01-04 22:30:19 -0800
commitbca343a9704aa0040467599f9196eff08e674bc7 (patch)
tree4336648efb6e23ea607bd4a27e08354ff0f70afd /src/main/java
parenteaca872f70921c63030d4758d52cf4fe2df2bfac (diff)
downloadtrackermap-server-bca343a9704aa0040467599f9196eff08e674bc7.tar.gz
trackermap-server-bca343a9704aa0040467599f9196eff08e674bc7.tar.bz2
trackermap-server-bca343a9704aa0040467599f9196eff08e674bc7.zip
Add events and fix speed
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/traccar/protocol/IotmProtocolDecoder.java23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/main/java/org/traccar/protocol/IotmProtocolDecoder.java b/src/main/java/org/traccar/protocol/IotmProtocolDecoder.java
index 88641081e..c5a9050e4 100644
--- a/src/main/java/org/traccar/protocol/IotmProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/IotmProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2020 Anton Tananaev (anton@traccar.org)
+ * Copyright 2020 - 2021 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,6 +28,7 @@ import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.NetworkMessage;
import org.traccar.Protocol;
+import org.traccar.helper.UnitsConverter;
import org.traccar.model.Position;
import java.net.SocketAddress;
@@ -144,10 +145,9 @@ public class IotmProtocolDecoder extends BaseProtocolDecoder {
while (buf.readableBytes() > 1) {
int type = buf.readUnsignedByte();
int length = buf.readUnsignedShortLE();
+ ByteBuf record = buf.readSlice(length);
if (type == 1) {
- ByteBuf record = buf.readSlice(length);
-
Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
position.setTime(new Date(record.readUnsignedIntLE() * 1000));
@@ -160,7 +160,7 @@ public class IotmProtocolDecoder extends BaseProtocolDecoder {
position.setValid(true);
position.setLatitude(record.readFloatLE());
position.setLongitude(record.readFloatLE());
- position.setSpeed(record.readUnsignedShortLE());
+ position.setSpeed(UnitsConverter.knotsFromKph(record.readUnsignedShortLE()));
position.set(Position.KEY_HDOP, record.readUnsignedByte());
position.set(Position.KEY_SATELLITES, record.readUnsignedByte());
@@ -181,8 +181,19 @@ public class IotmProtocolDecoder extends BaseProtocolDecoder {
positions.add(position);
- } else {
- buf.skipBytes(length);
+ } else if (type == 3) {
+
+ Position position = new Position(getProtocolName());
+ position.setDeviceId(deviceSession.getDeviceId());
+
+ getLastLocation(position, new Date(record.readUnsignedIntLE() * 1000));
+
+ record.readUnsignedByte(); // function identifier
+
+ position.set(Position.KEY_EVENT, record.readUnsignedByte());
+
+ positions.add(position);
+
}
}