aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2021-07-15 22:21:29 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2021-07-15 22:21:29 -0700
commit1989e592651c892a63106bbf79d97ac8e89f6b88 (patch)
tree36cc0edba9814d17f412ca1f818f6d3f780c57cd /src/main/java/org
parentea7b68003bce6603e6ad6227d022bca2867b64f3 (diff)
downloadtrackermap-server-1989e592651c892a63106bbf79d97ac8e89f6b88.tar.gz
trackermap-server-1989e592651c892a63106bbf79d97ac8e89f6b88.tar.bz2
trackermap-server-1989e592651c892a63106bbf79d97ac8e89f6b88.zip
Implement JT808 responses
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java
index 675a08aef..37d7ae718 100644
--- a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java
@@ -34,8 +34,10 @@ import org.traccar.model.Position;
import java.net.SocketAddress;
import java.nio.charset.StandardCharsets;
+import java.util.Calendar;
import java.util.LinkedList;
import java.util.List;
+import java.util.TimeZone;
public class HuabaoProtocolDecoder extends BaseProtocolDecoder {
@@ -55,6 +57,8 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder {
public static final int MSG_LOCATION_REPORT_BLIND = 0x5502;
public static final int MSG_LOCATION_BATCH = 0x0704;
public static final int MSG_OIL_CONTROL = 0XA006;
+ public static final int MSG_TIME_SYNC_REQUEST = 0x0109;
+ public static final int MSG_TIME_SYNC_RESPONSE = 0x8109;
public static final int RESULT_SUCCESS = 0;
@@ -192,8 +196,25 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder {
} else if (type == MSG_LOCATION_BATCH) {
+ sendGeneralResponse(channel, remoteAddress, id, type, index);
+
return decodeLocationBatch(deviceSession, buf);
+ } else if (type == MSG_TIME_SYNC_REQUEST) {
+
+ if (channel != null) {
+ Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
+ ByteBuf response = Unpooled.buffer();
+ response.writeShort(calendar.get(Calendar.YEAR));
+ response.writeByte(calendar.get(Calendar.MONTH) + 1);
+ response.writeByte(calendar.get(Calendar.DAY_OF_MONTH));
+ response.writeByte(calendar.get(Calendar.HOUR_OF_DAY));
+ response.writeByte(calendar.get(Calendar.MINUTE));
+ response.writeByte(calendar.get(Calendar.SECOND));
+ channel.writeAndFlush(new NetworkMessage(
+ formatMessage(MSG_TERMINAL_REGISTER_RESPONSE, id, false, response), remoteAddress));
+ }
+
}
return null;