diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2019-06-01 11:36:16 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2019-06-01 11:36:16 -0700 |
commit | 48b7368edb18985265dcba2fdaf4d80fc9f19bae (patch) | |
tree | 14395bb36ba2cd9d83d6c6955f8495cf6a23ad61 /src/main/java/org/traccar/protocol/T800xProtocolDecoder.java | |
parent | af8c41c0b0ce8cd2ce942f6e665dbfaba86a1703 (diff) | |
download | trackermap-server-48b7368edb18985265dcba2fdaf4d80fc9f19bae.tar.gz trackermap-server-48b7368edb18985265dcba2fdaf4d80fc9f19bae.tar.bz2 trackermap-server-48b7368edb18985265dcba2fdaf4d80fc9f19bae.zip |
Decode additional parameters
Diffstat (limited to 'src/main/java/org/traccar/protocol/T800xProtocolDecoder.java')
-rw-r--r-- | src/main/java/org/traccar/protocol/T800xProtocolDecoder.java | 55 |
1 files changed, 39 insertions, 16 deletions
diff --git a/src/main/java/org/traccar/protocol/T800xProtocolDecoder.java b/src/main/java/org/traccar/protocol/T800xProtocolDecoder.java index 6b7f47afd..940d43a56 100644 --- a/src/main/java/org/traccar/protocol/T800xProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/T800xProtocolDecoder.java @@ -33,6 +33,7 @@ import org.traccar.model.Position; import java.net.SocketAddress; import java.nio.charset.StandardCharsets; +import java.util.Date; public class T800xProtocolDecoder extends BaseProtocolDecoder { @@ -92,6 +93,17 @@ public class T800xProtocolDecoder extends BaseProtocolDecoder { } } + private Date readDate(ByteBuf buf) { + return new DateBuilder() + .setYear(BcdUtil.readInteger(buf, 2)) + .setMonth(BcdUtil.readInteger(buf, 2)) + .setDay(BcdUtil.readInteger(buf, 2)) + .setHour(BcdUtil.readInteger(buf, 2)) + .setMinute(BcdUtil.readInteger(buf, 2)) + .setSecond(BcdUtil.readInteger(buf, 2)) + .getDate(); + } + @Override protected Object decode( Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { @@ -110,10 +122,33 @@ public class T800xProtocolDecoder extends BaseProtocolDecoder { return null; } + if (type != MSG_GPS && type != MSG_ALARM) { + sendResponse(channel, header, type, index, imei, 0); + } + if (type == MSG_GPS || type == MSG_ALARM) { return decodePosition(channel, deviceSession, buf, header, type, index, imei); + } else if (type == MSG_NETWORK) { + + Position position = new Position(getProtocolName()); + position.setDeviceId(deviceSession.getDeviceId()); + + getLastLocation(position, readDate(buf)); + + position.set(Position.KEY_OPERATOR, buf.readCharSequence( + buf.readUnsignedByte(), StandardCharsets.UTF_16LE).toString()); + position.set("networkTechnology", buf.readCharSequence( + buf.readUnsignedByte(), StandardCharsets.US_ASCII).toString()); + position.set("networkBand", buf.readCharSequence( + buf.readUnsignedByte(), StandardCharsets.US_ASCII).toString()); + buf.readCharSequence(buf.readUnsignedByte(), StandardCharsets.US_ASCII); // imsi + position.set(Position.KEY_ICCID, buf.readCharSequence( + buf.readUnsignedByte(), StandardCharsets.US_ASCII).toString()); + + return position; + } else if (type == MSG_COMMAND) { Position position = new Position(getProtocolName()); @@ -125,14 +160,10 @@ public class T800xProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_RESULT, buf.toString(StandardCharsets.UTF_16LE)); - sendResponse(channel, header, type, index, imei, 0); - return position; } - sendResponse(channel, header, type, index, imei, 0); - return null; } @@ -196,18 +227,10 @@ public class T800xProtocolDecoder extends BaseProtocolDecoder { } - DateBuilder dateBuilder = new DateBuilder() - .setYear(BcdUtil.readInteger(buf, 2)) - .setMonth(BcdUtil.readInteger(buf, 2)) - .setDay(BcdUtil.readInteger(buf, 2)) - .setHour(BcdUtil.readInteger(buf, 2)) - .setMinute(BcdUtil.readInteger(buf, 2)) - .setSecond(BcdUtil.readInteger(buf, 2)); - if (BitUtil.check(status, 6)) { position.setValid(!BitUtil.check(status, 7)); - position.setTime(dateBuilder.getDate()); + position.setTime(readDate(buf)); position.setAltitude(buf.readFloatLE()); position.setLongitude(buf.readFloatLE()); position.setLatitude(buf.readFloatLE()); @@ -216,7 +239,7 @@ public class T800xProtocolDecoder extends BaseProtocolDecoder { } else { - getLastLocation(position, dateBuilder.getDate()); + getLastLocation(position, readDate(buf)); int mcc = buf.readUnsignedShortLE(); int mnc = buf.readUnsignedShortLE(); @@ -237,9 +260,9 @@ public class T800xProtocolDecoder extends BaseProtocolDecoder { buf.skipBytes(5); // acceleration position.set(Position.KEY_BATTERY_LEVEL, BcdUtil.readInteger(buf, 2)); position.set(Position.KEY_DEVICE_TEMP, (int) buf.readByte()); - buf.readUnsignedByte(); // front light sensor voltage + position.set("lightSensor", BcdUtil.readInteger(buf, 2) * 0.1); position.set(Position.KEY_BATTERY, BcdUtil.readInteger(buf, 2) * 0.1); - buf.readUnsignedByte(); // solar panel voltage + position.set("solarPanel", BcdUtil.readInteger(buf, 2) * 0.1); position.set(Position.KEY_ODOMETER, buf.readUnsignedInt()); position.set(Position.KEY_STATUS, buf.readUnsignedShort()); |