aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org
diff options
context:
space:
mode:
authorFluxpy <31820005+Fluxpy@users.noreply.github.com>2020-06-23 22:02:26 +0200
committerGitHub <noreply@github.com>2020-06-23 13:02:26 -0700
commit20b015a02baca01e244d12a717967238aae4ff82 (patch)
tree34d510a88a51bd5773d0a12e0271c20da9e177d8 /src/main/java/org
parentadd1194484bc24ff335818e1a878942cc22f7ff3 (diff)
downloadtraccar-server-20b015a02baca01e244d12a717967238aae4ff82.tar.gz
traccar-server-20b015a02baca01e244d12a717967238aae4ff82.tar.bz2
traccar-server-20b015a02baca01e244d12a717967238aae4ff82.zip
Added TOPIN Update Time + Status Response (#4548)
* added timeupdate to topin protocol * fixed status response topin protocol * fixed variable naming and writeShort recomendation from pull request comments * fixed typo, removed comment * added og comment Co-authored-by: Felix Huppert <felix@zeilen-sprung.de>
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/traccar/protocol/TopinProtocolDecoder.java33
1 files changed, 27 insertions, 6 deletions
diff --git a/src/main/java/org/traccar/protocol/TopinProtocolDecoder.java b/src/main/java/org/traccar/protocol/TopinProtocolDecoder.java
index eee0e9ae8..d4adba4e6 100644
--- a/src/main/java/org/traccar/protocol/TopinProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/TopinProtocolDecoder.java
@@ -30,7 +30,9 @@ import org.traccar.model.Network;
import org.traccar.model.Position;
import org.traccar.model.WifiAccessPoint;
+import java.math.BigInteger;
import java.net.SocketAddress;
+import java.util.Calendar;
import java.util.TimeZone;
public class TopinProtocolDecoder extends BaseProtocolDecoder {
@@ -44,6 +46,7 @@ public class TopinProtocolDecoder extends BaseProtocolDecoder {
public static final int MSG_GPS_OFFLINE = 0x11;
public static final int MSG_STATUS = 0x13;
public static final int MSG_WIFI_OFFLINE = 0x17;
+ public static final int MSG_TIME_UPDATE = 0x30;
public static final int MSG_WIFI = 0x69;
private void sendResponse(Channel channel, int length, int type, ByteBuf content) {
@@ -60,6 +63,21 @@ public class TopinProtocolDecoder extends BaseProtocolDecoder {
}
}
+ private void updateTime(Channel channel, int type) {
+ ByteBuf dateBuffer = Unpooled.buffer();
+
+ Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
+
+ dateBuffer.writeShort(calendar.get(Calendar.YEAR));
+ dateBuffer.writeByte(calendar.get(Calendar.MONTH)+1);
+ dateBuffer.writeByte(calendar.get(Calendar.DAY_OF_MONTH));
+ dateBuffer.writeByte(calendar.get(Calendar.HOUR_OF_DAY));
+ dateBuffer.writeByte(calendar.get(Calendar.MINUTE));
+ dateBuffer.writeByte(calendar.get(Calendar.SECOND));
+
+ sendResponse(channel, dateBuffer.readableBytes(), type, dateBuffer);
+ }
+
@Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
@@ -78,6 +96,9 @@ public class TopinProtocolDecoder extends BaseProtocolDecoder {
ByteBuf content = Unpooled.buffer();
content.writeByte(deviceSession != null ? 0x01 : 0x44);
sendResponse(channel, length, type, content);
+
+ updateTime(channel, MSG_TIME_UPDATE);
+
return null;
} else {
deviceSession = getDeviceSession(channel, remoteAddress);
@@ -101,6 +122,12 @@ public class TopinProtocolDecoder extends BaseProtocolDecoder {
return position;
+ } else if (type == MSG_TIME_UPDATE) {
+
+ updateTime(channel, type);
+
+ return null;
+
} else if (type == MSG_STATUS) {
Position position = new Position(getProtocolName());
@@ -122,13 +149,7 @@ public class TopinProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_VERSION_FW, firmware);
ByteBuf content = Unpooled.buffer();
- content.writeByte(battery);
- content.writeByte(firmware);
- content.writeByte(timezone);
content.writeByte(interval);
- if (length >= 7) {
- content.writeByte(signal);
- }
sendResponse(channel, length, type, content);
return position;