From b67f1e828ce5bc8fe215d377cd2ae81f23152abd Mon Sep 17 00:00:00 2001 From: jon-stumpf Date: Mon, 20 Feb 2017 18:50:42 -0500 Subject: Updated Atrack protocol to report network information; --- .../traccar/protocol/AtrackProtocolDecoder.java | 23 ++++++++++++++++++---- 1 file 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 -- cgit v1.2.3