aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2021-10-06 22:39:13 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2021-10-06 22:39:13 -0700
commit90d5b6ff470aea80679b05ba690fe0630f111dc7 (patch)
tree82c0fac513d1fede7d09448318aa413f49a84d4c /src
parent6f90e144603ee8e15fa98d4053806dbf13c3ee10 (diff)
downloadtraccar-server-90d5b6ff470aea80679b05ba690fe0630f111dc7.tar.gz
traccar-server-90d5b6ff470aea80679b05ba690fe0630f111dc7.tar.bz2
traccar-server-90d5b6ff470aea80679b05ba690fe0630f111dc7.zip
Support TT18 4G format
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/protocol/TzoneProtocolDecoder.java57
-rw-r--r--src/test/java/org/traccar/protocol/TzoneProtocolDecoderTest.java3
2 files changed, 46 insertions, 14 deletions
diff --git a/src/main/java/org/traccar/protocol/TzoneProtocolDecoder.java b/src/main/java/org/traccar/protocol/TzoneProtocolDecoder.java
index 4f6854098..4680e0a2f 100644
--- a/src/main/java/org/traccar/protocol/TzoneProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/TzoneProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2019 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 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.
@@ -21,6 +21,7 @@ import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.Protocol;
+import org.traccar.helper.BcdUtil;
import org.traccar.helper.BitUtil;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.UnitsConverter;
@@ -256,9 +257,28 @@ public class TzoneProtocolDecoder extends BaseProtocolDecoder {
int blockLength = buf.readUnsignedShort();
int blockEnd = buf.readerIndex() + blockLength;
- if (blockLength > 0 && (hardware == 0x10A || hardware == 0x10B || hardware == 0x406)) {
- position.setNetwork(new Network(
- CellTower.fromLacCid(buf.readUnsignedShort(), buf.readUnsignedShort())));
+ if (blockLength > 0) {
+ if (hardware == 0x10A || hardware == 0x10B || hardware == 0x406) {
+
+ position.setNetwork(new Network(
+ CellTower.fromLacCid(buf.readUnsignedShort(), buf.readUnsignedShort())));
+
+ } else if (hardware == 0x407) {
+
+ Network network = new Network();
+ int count = buf.readUnsignedByte();
+ for (int i = 0; i < count; i++) {
+ buf.readUnsignedByte(); // signal information
+
+ int mcc = BcdUtil.readInteger(buf, 4);
+ int mnc = BcdUtil.readInteger(buf, 4) % 1000;
+
+ network.addCellTower(CellTower.from(
+ mcc, mnc, buf.readUnsignedShort(), buf.readUnsignedInt()));
+ }
+ position.setNetwork(network);
+
+ }
}
buf.readerIndex(blockEnd);
@@ -272,21 +292,30 @@ public class TzoneProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_ALARM, decodeAlarm(buf.readUnsignedByte()));
position.set("terminalInfo", buf.readUnsignedByte());
- int status = buf.readUnsignedByte();
- position.set(Position.PREFIX_OUT + 1, BitUtil.check(status, 0));
- position.set(Position.PREFIX_OUT + 2, BitUtil.check(status, 1));
- status = buf.readUnsignedByte();
- position.set(Position.PREFIX_IN + 1, BitUtil.check(status, 4));
- if (BitUtil.check(status, 0)) {
- position.set(Position.KEY_ALARM, Position.ALARM_SOS);
+ if (hardware != 0x407) {
+ int status = buf.readUnsignedByte();
+ position.set(Position.PREFIX_OUT + 1, BitUtil.check(status, 0));
+ position.set(Position.PREFIX_OUT + 2, BitUtil.check(status, 1));
+ status = buf.readUnsignedByte();
+ position.set(Position.PREFIX_IN + 1, BitUtil.check(status, 4));
+ if (BitUtil.check(status, 0)) {
+ position.set(Position.KEY_ALARM, Position.ALARM_SOS);
+ }
}
position.set(Position.KEY_RSSI, buf.readUnsignedByte());
position.set("gsmStatus", buf.readUnsignedByte());
position.set(Position.KEY_BATTERY, buf.readUnsignedShort());
- position.set(Position.KEY_POWER, buf.readUnsignedShort());
- position.set(Position.PREFIX_ADC + 1, buf.readUnsignedShort());
- position.set(Position.PREFIX_ADC + 2, buf.readUnsignedShort());
+
+ if (hardware != 0x407) {
+ position.set(Position.KEY_POWER, buf.readUnsignedShort());
+ position.set(Position.PREFIX_ADC + 1, buf.readUnsignedShort());
+ position.set(Position.PREFIX_ADC + 2, buf.readUnsignedShort());
+ } else {
+ position.set(Position.PREFIX_TEMP + 1, buf.readUnsignedShort());
+ position.set("humidity", buf.readUnsignedShort());
+ position.set("lightSensor", buf.readUnsignedByte());
+ }
}
if (blockLength >= 15) {
diff --git a/src/test/java/org/traccar/protocol/TzoneProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/TzoneProtocolDecoderTest.java
index 0aeea0f1a..fba8f7db4 100644
--- a/src/test/java/org/traccar/protocol/TzoneProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/TzoneProtocolDecoderTest.java
@@ -11,6 +11,9 @@ public class TzoneProtocolDecoderTest extends ProtocolTest {
var decoder = new TzoneProtocolDecoder(null);
verifyAttributes(decoder, binary(
+ "545a004d24240407010d0000018032100000031515090c052c2100000022030a033400201347000056860a03340020134700002feb0a03340020134700007d96000baa10211f01810127022d000001ebe00d0a"));
+
+ verifyAttributes(decoder, binary(
"545A004B2424041302000000086706003324776413030C0A1A2900180513030C0A1A25080F7E1028CAC830000A000F0000000005000AA53201633D05046000010009AA201737019408973B0032B0260D0A"));
verifyAttributes(decoder, binary(