diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2019-11-12 22:43:56 -0800 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2019-11-12 22:43:56 -0800 |
commit | 1ec1f09932200815fbdf64c5efa6529d919ec643 (patch) | |
tree | 3f64dfc0a1e7d97e4603e24e2720bc58ab385a6e /src/main | |
parent | 01b7edfdb45fc77b760b441627971d29af9ea60f (diff) | |
download | trackermap-server-1ec1f09932200815fbdf64c5efa6529d919ec643.tar.gz trackermap-server-1ec1f09932200815fbdf64c5efa6529d919ec643.tar.bz2 trackermap-server-1ec1f09932200815fbdf64c5efa6529d919ec643.zip |
Support WiFi and cell data
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/org/traccar/protocol/TopinProtocolDecoder.java | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/main/java/org/traccar/protocol/TopinProtocolDecoder.java b/src/main/java/org/traccar/protocol/TopinProtocolDecoder.java index 4334ae5cb..ea72b7cb8 100644 --- a/src/main/java/org/traccar/protocol/TopinProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/TopinProtocolDecoder.java @@ -23,7 +23,10 @@ import org.traccar.BaseProtocolDecoder; import org.traccar.DeviceSession; import org.traccar.NetworkMessage; import org.traccar.Protocol; +import org.traccar.model.CellTower; +import org.traccar.model.Network; import org.traccar.model.Position; +import org.traccar.model.WifiAccessPoint; import java.net.SocketAddress; import java.util.TimeZone; @@ -38,6 +41,8 @@ public class TopinProtocolDecoder extends BaseProtocolDecoder { public static final int MSG_GPS = 0x10; public static final int MSG_GPS_OFFLINE = 0x11; public static final int MSG_STATUS = 0x13; + public static final int MSG_WIFI_OFFLINE = 0x17; + public static final int MSG_WIFI = 0x69; private void sendResponse(Channel channel, int type, ByteBuf content) { if (channel != null) { @@ -126,6 +131,39 @@ public class TopinProtocolDecoder extends BaseProtocolDecoder { return position; + } else if (type == MSG_WIFI || type == MSG_WIFI_OFFLINE) { + + Position position = new Position(getProtocolName()); + position.setDeviceId(deviceSession.getDeviceId()); + + getLastLocation(position, null); + + ByteBuf time = buf.readSlice(6); + + Network network = new Network(); + for (int i = 0; i < length; i++) { + String mac = String.format("%02x:%02x:%02x:%02x:%02x:%02x", + buf.readUnsignedByte(), buf.readUnsignedByte(), buf.readUnsignedByte(), + buf.readUnsignedByte(), buf.readUnsignedByte(), buf.readUnsignedByte()); + network.addWifiAccessPoint(WifiAccessPoint.from(mac, buf.readUnsignedByte())); + } + + int cellCount = buf.readUnsignedByte(); + int mcc = buf.readUnsignedShort(); + int mnc = buf.readUnsignedByte(); + for (int i = 0; i < cellCount; i++) { + network.addCellTower(CellTower.from( + mcc, mnc, buf.readUnsignedShort(), buf.readUnsignedShort(), buf.readUnsignedByte())); + } + + position.setNetwork(network); + + ByteBuf content = Unpooled.buffer(); + content.writeBytes(time); + sendResponse(channel, type, content); + + return position; + } return null; |