diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/org/traccar/model/CellTower.java | 6 | ||||
-rw-r--r-- | src/org/traccar/protocol/TeltonikaProtocolDecoder.java | 120 |
2 files changed, 114 insertions, 12 deletions
diff --git a/src/org/traccar/model/CellTower.java b/src/org/traccar/model/CellTower.java index 2eb56dd33..6d1dfbd7f 100644 --- a/src/org/traccar/model/CellTower.java +++ b/src/org/traccar/model/CellTower.java @@ -106,4 +106,10 @@ public class CellTower { this.signalStrength = signalStrength; } + public void setOperator(long operator) { + String operatorString = String.valueOf(operator); + mobileCountryCode = Integer.parseInt(operatorString.substring(0, 3)); + mobileNetworkCode = Integer.parseInt(operatorString.substring(3)); + } + } diff --git a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java index 4700350d4..3dd00ead7 100644 --- a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java +++ b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java @@ -113,15 +113,15 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder { case 19: position.set("axisZ", readValue(buf, length, true)); break; + case 21: + position.set("gsmLevel", readValue(buf, length, false)); + break; case 66: position.set(Position.KEY_POWER, readValue(buf, length, false) * 0.001); break; case 67: position.set(Position.KEY_BATTERY, readValue(buf, length, false) * 0.001); break; - case 70: - position.set(Position.KEY_DEVICE_TEMP, readValue(buf, length, true) * 0.1); - break; case 72: position.set(Position.PREFIX_TEMP + 1, readValue(buf, length, true) * 0.1); break; @@ -134,15 +134,92 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder { case 78: position.set(Position.KEY_DRIVER_UNIQUE_ID, String.valueOf(readValue(buf, length, false))); break; + case 80: + position.set("workMode", readValue(buf, length, false)); + break; + case 179: + position.set(Position.PREFIX_OUT + 1, readValue(buf, length, false) == 1); + break; + case 180: + position.set(Position.PREFIX_OUT + 2, readValue(buf, length, false) == 1); + break; + case 181: + position.set(Position.KEY_PDOP, readValue(buf, length, false) * 0.1); + break; case 182: position.set(Position.KEY_HDOP, readValue(buf, length, false) * 0.1); break; + case 239: + position.set(Position.KEY_IGNITION, readValue(buf, length, false) == 1); + break; + case 240: + position.set(Position.KEY_MOTION, readValue(buf, length, false) == 1); + break; + case 241: + position.set(Position.KEY_OPERATOR, readValue(buf, length, false)); + break; + default: + position.set(Position.PREFIX_IO + id, readValue(buf, length, false)); + break; + } + } + + private void decodeGh3000Parameter(Position position, int id, ChannelBuffer buf, int length) { + switch (id) { + case 1: + position.set(Position.KEY_BATTERY_LEVEL, readValue(buf, length, false)); + break; + case 2: + position.set("usbConnected", readValue(buf, length, false) == 1); + break; + case 5: + position.set("uptime", readValue(buf, length, false)); + break; + case 20: + position.set(Position.KEY_HDOP, readValue(buf, length, false) * 0.1); + break; + case 21: + position.set(Position.KEY_VDOP, readValue(buf, length, false) * 0.1); + break; + case 22: + position.set(Position.KEY_PDOP, readValue(buf, length, false) * 0.1); + break; + case 67: + position.set(Position.KEY_BATTERY, readValue(buf, length, false) * 0.001); + break; + case 221: + position.set("button", readValue(buf, length, false)); + break; + case 222: + if (readValue(buf, length, false) == 1) { + position.set(Position.KEY_ALARM, Position.ALARM_SOS); + } + break; + case 240: + position.set(Position.KEY_MOTION, readValue(buf, length, false) == 1); + break; + case 244: + position.set("roaming", readValue(buf, length, false) == 1); + break; default: position.set(Position.PREFIX_IO + id, readValue(buf, length, false)); break; } } + private void decodeNetwork(Position position) { + long cid = position.getLong(Position.PREFIX_IO + 205); + int lac = position.getInteger(Position.PREFIX_IO + 206); + if (cid != 0 && lac != 0) { + CellTower cellTower = CellTower.fromLacCid(lac, cid); + long operator = position.getInteger(Position.KEY_OPERATOR); + if (operator != 0) { + cellTower.setOperator(operator); + } + position.setNetwork(new Network(cellTower)); + } + } + private void decodeLocation(Position position, ChannelBuffer buf, int codec) { int globalMask = 0x0f; @@ -189,14 +266,19 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder { cellTower.setSignalStrength((int) buf.readUnsignedByte()); } - position.setNetwork(new Network(cellTower)); + if (BitUtil.check(locationMask, 7)) { + cellTower.setOperator(buf.readUnsignedInt()); + } - } else if (BitUtil.check(locationMask, 6)) { - position.set(Position.KEY_RSSI, buf.readUnsignedByte()); - } + position.setNetwork(new Network(cellTower)); - if (BitUtil.check(locationMask, 7)) { - position.set(Position.KEY_OPERATOR, buf.readUnsignedInt()); + } else { + if (BitUtil.check(locationMask, 6)) { + position.set(Position.KEY_RSSI, buf.readUnsignedByte()); + } + if (BitUtil.check(locationMask, 7)) { + position.set(Position.KEY_OPERATOR, buf.readUnsignedInt()); + } } } else { @@ -233,7 +315,11 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder { if (BitUtil.check(globalMask, 1)) { int cnt = buf.readUnsignedByte(); for (int j = 0; j < cnt; j++) { - decodeParameter(position, buf.readUnsignedByte(), buf, 1); + if (codec == CODEC_GH3000) { + decodeGh3000Parameter(position, buf.readUnsignedByte(), buf, 1); + } else { + decodeParameter(position, buf.readUnsignedByte(), buf, 1); + } } } @@ -241,7 +327,11 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder { if (BitUtil.check(globalMask, 2)) { int cnt = buf.readUnsignedByte(); for (int j = 0; j < cnt; j++) { - decodeParameter(position, buf.readUnsignedByte(), buf, 2); + if (codec == CODEC_GH3000) { + decodeGh3000Parameter(position, buf.readUnsignedByte(), buf, 2); + } else { + decodeParameter(position, buf.readUnsignedByte(), buf, 2); + } } } @@ -249,7 +339,11 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder { if (BitUtil.check(globalMask, 3)) { int cnt = buf.readUnsignedByte(); for (int j = 0; j < cnt; j++) { - decodeParameter(position, buf.readUnsignedByte(), buf, 4); + if (codec == CODEC_GH3000) { + decodeGh3000Parameter(position, buf.readUnsignedByte(), buf, 4); + } else { + decodeParameter(position, buf.readUnsignedByte(), buf, 4); + } } } @@ -269,6 +363,8 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder { } } + decodeNetwork(position); + } private List<Position> parseData( |