aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2021-02-27 15:06:14 -0800
committerAnton Tananaev <anton.tananaev@gmail.com>2021-02-27 15:06:14 -0800
commitfb8fcb940ee0faedecff130554ae62971f5ccb85 (patch)
treeec34a66d4342d76779774432396826f17a937977
parent1499b12fa782a57dbaef294ddd16ba61d2193cc7 (diff)
downloadtrackermap-server-fb8fcb940ee0faedecff130554ae62971f5ccb85.tar.gz
trackermap-server-fb8fcb940ee0faedecff130554ae62971f5ccb85.tar.bz2
trackermap-server-fb8fcb940ee0faedecff130554ae62971f5ccb85.zip
Update Topin protocol
-rw-r--r--src/main/java/org/traccar/protocol/TopinProtocolDecoder.java18
-rw-r--r--src/test/java/org/traccar/protocol/TopinProtocolDecoderTest.java3
2 files changed, 20 insertions, 1 deletions
diff --git a/src/main/java/org/traccar/protocol/TopinProtocolDecoder.java b/src/main/java/org/traccar/protocol/TopinProtocolDecoder.java
index 4042e348c..fe8de3710 100644
--- a/src/main/java/org/traccar/protocol/TopinProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/TopinProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2019 - 2020 Anton Tananaev (anton@traccar.org)
+ * Copyright 2019 - 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.
@@ -24,6 +24,7 @@ import org.traccar.DeviceSession;
import org.traccar.NetworkMessage;
import org.traccar.Protocol;
import org.traccar.helper.BcdUtil;
+import org.traccar.helper.BitUtil;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.UnitsConverter;
import org.traccar.model.CellTower;
@@ -151,6 +152,21 @@ public class TopinProtocolDecoder extends BaseProtocolDecoder {
Gt06ProtocolDecoder.decodeGps(position, buf, false, TimeZone.getTimeZone("UTC"));
+ if (buf.readableBytes() >= 5) {
+ position.setAltitude(buf.readShort());
+
+ int alarms = buf.readUnsignedByte();
+ if (BitUtil.check(alarms, 0)) {
+ position.set(Position.KEY_ALARM, Position.ALARM_VIBRATION);
+ }
+ if (BitUtil.check(alarms, 1)) {
+ position.set(Position.KEY_ALARM, Position.ALARM_OVERSPEED);
+ }
+ if (BitUtil.check(alarms, 4)) {
+ position.set(Position.KEY_ALARM, Position.ALARM_LOW_POWER);
+ }
+ }
+
ByteBuf content = Unpooled.buffer();
content.writeBytes(time);
sendResponse(channel, length, type, content);
diff --git a/src/test/java/org/traccar/protocol/TopinProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/TopinProtocolDecoderTest.java
index 8320b1388..191d27b8a 100644
--- a/src/test/java/org/traccar/protocol/TopinProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/TopinProtocolDecoderTest.java
@@ -17,6 +17,9 @@ public class TopinProtocolDecoderTest extends ProtocolTest {
"78780d0103593390754169634d0d0a"));
verifyPosition(decoder, binary(
+ "78781510120B05030D2498038077200BE2078F0034000102030D0A"));
+
+ verifyPosition(decoder, binary(
"7878200813081A0733211608C8D1710DED1D1608DFFB710E06D51039050100286489000D0A"));
verifyPosition(decoder, binary(