aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-07-25 12:36:50 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2015-07-25 12:36:50 +1200
commitf449d805a01e709b06c4b06e6dcb35d1651f73ad (patch)
tree5a214746f6b772f8ccd5cf688cbaa56ec3cc4283
parent04bb90567fc6dbd63ba09d93390aad61deb82edb (diff)
downloadtraccar-server-f449d805a01e709b06c4b06e6dcb35d1651f73ad.tar.gz
traccar-server-f449d805a01e709b06c4b06e6dcb35d1651f73ad.tar.bz2
traccar-server-f449d805a01e709b06c4b06e6dcb35d1651f73ad.zip
Parse extra TZone infomation
-rw-r--r--src/org/traccar/model/Event.java1
-rw-r--r--src/org/traccar/protocol/TzoneProtocolDecoder.java96
2 files changed, 96 insertions, 1 deletions
diff --git a/src/org/traccar/model/Event.java b/src/org/traccar/model/Event.java
index b42a776ae..caee7133b 100644
--- a/src/org/traccar/model/Event.java
+++ b/src/org/traccar/model/Event.java
@@ -51,6 +51,7 @@ public abstract class Event {
}
}
+ // Words separated by dashes (word-second-third)
public static final String KEY_INDEX = "index";
public static final String KEY_HDOP = "hdop";
public static final String KEY_SATELLITES = "sat";
diff --git a/src/org/traccar/protocol/TzoneProtocolDecoder.java b/src/org/traccar/protocol/TzoneProtocolDecoder.java
index f67c9684f..ed463c109 100644
--- a/src/org/traccar/protocol/TzoneProtocolDecoder.java
+++ b/src/org/traccar/protocol/TzoneProtocolDecoder.java
@@ -41,7 +41,9 @@ public class TzoneProtocolDecoder extends BaseProtocolDecoder {
buf.skipBytes(2); // header
buf.readUnsignedShort(); // length
- buf.readUnsignedShort(); // type
+ if (buf.readUnsignedShort() != 0x2424) {
+ return null;
+ }
buf.readUnsignedShort(); // model
buf.readUnsignedInt(); // firmware
@@ -55,6 +57,8 @@ public class TzoneProtocolDecoder extends BaseProtocolDecoder {
Position position = new Position();
position.setProtocol(getProtocolName());
position.setDeviceId(getDeviceId());
+
+ // GPS info
int blockLength = buf.readUnsignedShort();
int blockEnd = buf.readerIndex() + blockLength;
@@ -89,6 +93,96 @@ public class TzoneProtocolDecoder extends BaseProtocolDecoder {
position.setValid(BitUtil.check(flags, 11));
buf.readerIndex(blockEnd);
+
+ // LBS info
+
+ blockLength = buf.readUnsignedShort();
+ blockEnd = buf.readerIndex() + blockLength;
+
+ if (blockLength > 0) {
+
+ position.set(Event.KEY_LAC, buf.readUnsignedShort());
+ position.set(Event.KEY_CELL, buf.readUnsignedShort());
+
+ }
+
+ buf.readerIndex(blockEnd);
+
+ // Status info
+
+ blockLength = buf.readUnsignedShort();
+ blockEnd = buf.readerIndex() + blockLength;
+
+ if (blockLength > 0) {
+
+ position.set(Event.KEY_ALARM, buf.readUnsignedByte());
+ buf.readUnsignedByte(); // terminal info
+ position.set(Event.PREFIX_IO + 1, buf.readUnsignedShort());
+ position.set(Event.KEY_GSM, buf.readUnsignedByte());
+ buf.readUnsignedByte(); // GSM status
+ position.set(Event.KEY_BATTERY, buf.readUnsignedShort());
+ position.set(Event.KEY_POWER, buf.readUnsignedShort());
+ position.set(Event.PREFIX_ADC + 1, buf.readUnsignedShort());
+ position.set(Event.PREFIX_ADC + 2, buf.readUnsignedShort());
+ position.set(Event.PREFIX_TEMP + 1, buf.readUnsignedShort());
+
+ }
+
+ buf.readerIndex(blockEnd);
+
+ // Cards
+
+ int index = 1;
+ for (int i = 0; i < 4; i++) {
+
+ blockLength = buf.readUnsignedShort();
+ blockEnd = buf.readerIndex() + blockLength;
+
+ if (blockLength > 0) {
+
+ int count = buf.readUnsignedByte();
+ for (int j = 0; j < count; j++) {
+
+ int length = buf.readUnsignedByte();
+
+ boolean odd = length % 2 != 0;
+
+ String num = ChannelBufferTools.readHexString(buf, odd ? length + 1 : length);
+
+ if (odd) {
+ num = num.substring(1);
+ }
+
+ position.set("card" + index, num);
+
+ }
+ }
+
+ buf.readerIndex(blockEnd);
+
+ }
+
+ // Temperature
+
+ buf.skipBytes(buf.readUnsignedShort());
+
+ // Lock
+
+ buf.skipBytes(buf.readUnsignedShort());
+
+ // Passengers
+
+ blockLength = buf.readUnsignedShort();
+ blockEnd = buf.readerIndex() + blockLength;
+
+ if (blockLength > 0) {
+
+ position.set("passengers-on", buf.readUnsignedMedium());
+ position.set("passengers-off", buf.readUnsignedMedium());
+
+ }
+
+ buf.readerIndex(blockEnd);
return position;
}