From 1ec1f09932200815fbdf64c5efa6529d919ec643 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 12 Nov 2019 22:43:56 -0800 Subject: Support WiFi and cell data --- .../org/traccar/protocol/TopinProtocolDecoder.java | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'src/main/java/org/traccar/protocol/TopinProtocolDecoder.java') 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; -- cgit v1.2.3