aboutsummaryrefslogtreecommitdiff
path: root/src/org
diff options
context:
space:
mode:
Diffstat (limited to 'src/org')
-rw-r--r--src/org/traccar/protocol/TzoneProtocolDecoder.java133
1 files changed, 91 insertions, 42 deletions
diff --git a/src/org/traccar/protocol/TzoneProtocolDecoder.java b/src/org/traccar/protocol/TzoneProtocolDecoder.java
index 6f6ff3878..1537c0107 100644
--- a/src/org/traccar/protocol/TzoneProtocolDecoder.java
+++ b/src/org/traccar/protocol/TzoneProtocolDecoder.java
@@ -57,6 +57,53 @@ public class TzoneProtocolDecoder extends BaseProtocolDecoder {
}
}
+ private boolean decodeGps(Position position, ByteBuf buf, int hardware) {
+
+ int blockLength = buf.readUnsignedShort();
+ int blockEnd = buf.readerIndex() + blockLength;
+
+ if (blockLength < 22) {
+ return false;
+ }
+
+ position.set(Position.KEY_SATELLITES, buf.readUnsignedByte());
+
+ double lat;
+ double lon;
+
+ if (hardware == 0x10A || hardware == 0x10B) {
+ lat = buf.readUnsignedInt() / 600000.0;
+ lon = buf.readUnsignedInt() / 600000.0;
+ } else {
+ lat = buf.readUnsignedInt() / 100000.0 / 60.0;
+ lon = buf.readUnsignedInt() / 100000.0 / 60.0;
+ }
+
+ position.setFixTime(new DateBuilder()
+ .setDate(buf.readUnsignedByte(), buf.readUnsignedByte(), buf.readUnsignedByte())
+ .setTime(buf.readUnsignedByte(), buf.readUnsignedByte(), buf.readUnsignedByte()).getDate());
+
+ position.setSpeed(buf.readUnsignedShort() * 0.01);
+
+ position.set(Position.KEY_ODOMETER, buf.readUnsignedMedium());
+
+ int flags = buf.readUnsignedShort();
+ position.setCourse(BitUtil.to(flags, 9));
+ if (!BitUtil.check(flags, 10)) {
+ lat = -lat;
+ }
+ position.setLatitude(lat);
+ if (BitUtil.check(flags, 9)) {
+ lon = -lon;
+ }
+ position.setLongitude(lon);
+ position.setValid(BitUtil.check(flags, 11));
+
+ buf.readerIndex(blockEnd);
+
+ return true;
+ }
+
private void decodeCards(Position position, ByteBuf buf) {
int index = 1;
@@ -108,6 +155,38 @@ public class TzoneProtocolDecoder extends BaseProtocolDecoder {
}
+ private void decodeTags(Position position, ByteBuf buf) {
+
+ int blockLength = buf.readUnsignedShort();
+ int blockEnd = buf.readerIndex() + blockLength;
+
+ if (blockLength > 0) {
+
+ buf.readUnsignedByte(); // tag type
+
+ int count = buf.readUnsignedByte();
+ int tagLength = buf.readUnsignedByte();
+
+ for (int i = 1; i <= count; i++) {
+ int tagEnd = buf.readerIndex() + tagLength;
+
+ buf.readUnsignedByte(); // status
+ buf.readUnsignedShortLE(); // battery voltage
+
+ position.set(Position.PREFIX_TEMP + i, (buf.readShortLE() & 0x3fff) * 0.1);
+
+ buf.readUnsignedByte(); // humidity
+ buf.readUnsignedByte(); // rssi
+
+ buf.readerIndex(tagEnd);
+ }
+
+ }
+
+ buf.readerIndex(blockEnd);
+
+ }
+
@Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
@@ -140,54 +219,18 @@ public class TzoneProtocolDecoder extends BaseProtocolDecoder {
// GPS info
- int blockLength = buf.readUnsignedShort();
- int blockEnd = buf.readerIndex() + blockLength;
-
- if (blockLength < 22) {
- return null;
- }
-
- position.set(Position.KEY_SATELLITES, buf.readUnsignedByte());
+ if (hardware == 0x406 || !decodeGps(position, buf, hardware)) {
- double lat;
- double lon;
+ getLastLocation(position, position.getDeviceTime());
- if (hardware == 0x10A || hardware == 0x10B) {
- lat = buf.readUnsignedInt() / 600000.0;
- lon = buf.readUnsignedInt() / 600000.0;
- } else {
- lat = buf.readUnsignedInt() / 100000.0 / 60.0;
- lon = buf.readUnsignedInt() / 100000.0 / 60.0;
}
- position.setFixTime(new DateBuilder()
- .setDate(buf.readUnsignedByte(), buf.readUnsignedByte(), buf.readUnsignedByte())
- .setTime(buf.readUnsignedByte(), buf.readUnsignedByte(), buf.readUnsignedByte()).getDate());
-
- position.setSpeed(buf.readUnsignedShort() * 0.01);
-
- position.set(Position.KEY_ODOMETER, buf.readUnsignedMedium());
-
- int flags = buf.readUnsignedShort();
- position.setCourse(BitUtil.to(flags, 9));
- if (!BitUtil.check(flags, 10)) {
- lat = -lat;
- }
- position.setLatitude(lat);
- if (BitUtil.check(flags, 9)) {
- lon = -lon;
- }
- position.setLongitude(lon);
- position.setValid(BitUtil.check(flags, 11));
-
- buf.readerIndex(blockEnd);
-
// LBS info
- blockLength = buf.readUnsignedShort();
- blockEnd = buf.readerIndex() + blockLength;
+ int blockLength = buf.readUnsignedShort();
+ int blockEnd = buf.readerIndex() + blockLength;
- if (blockLength > 0 && (hardware == 0x10A || hardware == 0x10B)) {
+ if (blockLength > 0 && (hardware == 0x10A || hardware == 0x10B || hardware == 0x406)) {
position.setNetwork(new Network(
CellTower.fromLacCid(buf.readUnsignedShort(), buf.readUnsignedShort())));
}
@@ -226,7 +269,7 @@ public class TzoneProtocolDecoder extends BaseProtocolDecoder {
buf.readerIndex(blockEnd);
- if (hardware == 0x10A || hardware == 0x10B) {
+ if (hardware == 0x10B) {
decodeCards(position, buf);
@@ -237,6 +280,12 @@ public class TzoneProtocolDecoder extends BaseProtocolDecoder {
}
+ if (hardware == 0x406) {
+
+ decodeTags(position, buf);
+
+ }
+
return position;
}