diff options
author | jon-stumpf <jon.stumpf@gmail.com> | 2017-02-20 18:50:42 -0500 |
---|---|---|
committer | jon-stumpf <jon.stumpf@gmail.com> | 2017-02-20 18:50:42 -0500 |
commit | b67f1e828ce5bc8fe215d377cd2ae81f23152abd (patch) | |
tree | 204f6de081cf1ee749ca717b6b48ed44c497a040 /src/org/traccar/protocol/AtrackProtocolDecoder.java | |
parent | 888c392af40187f3a0ecc3395495db9acd85b827 (diff) | |
download | trackermap-server-b67f1e828ce5bc8fe215d377cd2ae81f23152abd.tar.gz trackermap-server-b67f1e828ce5bc8fe215d377cd2ae81f23152abd.tar.bz2 trackermap-server-b67f1e828ce5bc8fe215d377cd2ae81f23152abd.zip |
Updated Atrack protocol to report network information;
Diffstat (limited to 'src/org/traccar/protocol/AtrackProtocolDecoder.java')
-rw-r--r-- | src/org/traccar/protocol/AtrackProtocolDecoder.java | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/org/traccar/protocol/AtrackProtocolDecoder.java b/src/org/traccar/protocol/AtrackProtocolDecoder.java index d80c19706..e2868692e 100644 --- a/src/org/traccar/protocol/AtrackProtocolDecoder.java +++ b/src/org/traccar/protocol/AtrackProtocolDecoder.java @@ -23,6 +23,8 @@ import org.traccar.Context; import org.traccar.DeviceSession; import org.traccar.helper.DateBuilder; import org.traccar.helper.UnitsConverter; +import org.traccar.model.CellTower; +import org.traccar.model.Network; import org.traccar.model.Position; import java.net.SocketAddress; @@ -80,6 +82,7 @@ public class AtrackProtocolDecoder extends BaseProtocolDecoder { } private void readCustomData(Position position, ChannelBuffer buf, String form) { + CellTower cellTower = new CellTower(); String[] keys = form.substring(1).split("%"); for (String key : keys) { switch (key) { @@ -93,16 +96,19 @@ public class AtrackProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_BATTERY, buf.readUnsignedShort()); break; case "GQ": - position.set(Position.KEY_RSSI, buf.readUnsignedByte()); + cellTower.setSignalStrength((int) buf.readUnsignedByte()); break; case "CE": - buf.readUnsignedInt(); // cid + cellTower.setCellId(buf.readUnsignedInt()); // cid break; case "LC": - buf.readUnsignedShort(); // lac + cellTower.setLocationAreaCode(buf.readUnsignedShort()); // lac break; case "CN": - buf.readUnsignedInt(); // mcc + mnc + int combinedMobileCodes; // Decimal: CCCNN + combinedMobileCodes = (int) (buf.readUnsignedInt() % 100000); + cellTower.setMobileCountryCode(combinedMobileCodes / 100); + cellTower.setMobileNetworkCode(combinedMobileCodes % 100); break; case "RL": buf.readUnsignedByte(); // rxlev @@ -168,6 +174,15 @@ public class AtrackProtocolDecoder extends BaseProtocolDecoder { break; } } + + if (cellTower.getMobileCountryCode() != null + && cellTower.getMobileNetworkCode() != null + && cellTower.getCellId() != null + && cellTower.getLocationAreaCode() != null) { + position.setNetwork(new Network(cellTower)); + } else if (cellTower.getSignalStrength() != null) { + position.set(Position.KEY_RSSI, cellTower.getSignalStrength()); + } } @Override |