aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-02-01 21:35:24 -0800
committerAnton Tananaev <anton.tananaev@gmail.com>2020-02-01 21:35:24 -0800
commit230227fde27da2db785d97c6894160b256ad6c10 (patch)
treeb2964a90204026feeeb846651a1789af78040c7b /src/main/java
parentfdf16e5ee51cf7537920d04e1fd4bffbdbd5fa42 (diff)
downloadtrackermap-server-230227fde27da2db785d97c6894160b256ad6c10.tar.gz
trackermap-server-230227fde27da2db785d97c6894160b256ad6c10.tar.bz2
trackermap-server-230227fde27da2db785d97c6894160b256ad6c10.zip
Decode device time
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/traccar/protocol/TopinProtocolDecoder.java14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/main/java/org/traccar/protocol/TopinProtocolDecoder.java b/src/main/java/org/traccar/protocol/TopinProtocolDecoder.java
index 0f22bc7fd..eee0e9ae8 100644
--- a/src/main/java/org/traccar/protocol/TopinProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/TopinProtocolDecoder.java
@@ -23,6 +23,8 @@ import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.NetworkMessage;
import org.traccar.Protocol;
+import org.traccar.helper.BcdUtil;
+import org.traccar.helper.DateBuilder;
import org.traccar.model.CellTower;
import org.traccar.model.Network;
import org.traccar.model.Position;
@@ -136,9 +138,17 @@ public class TopinProtocolDecoder extends BaseProtocolDecoder {
Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
- getLastLocation(position, null);
-
ByteBuf time = buf.readSlice(6);
+ DateBuilder dateBuilder = new DateBuilder()
+ .setYear(BcdUtil.readInteger(time, 2))
+ .setMonth(BcdUtil.readInteger(time, 2))
+ .setDay(BcdUtil.readInteger(time, 2))
+ .setHour(BcdUtil.readInteger(time, 2))
+ .setMinute(BcdUtil.readInteger(time, 2))
+ .setSecond(BcdUtil.readInteger(time, 2));
+ time.resetReaderIndex();
+
+ getLastLocation(position, dateBuilder.getDate());
Network network = new Network();
for (int i = 0; i < length; i++) {