diff options
-rw-r--r-- | src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java | 62 | ||||
-rw-r--r-- | src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java | 3 |
2 files changed, 43 insertions, 22 deletions
diff --git a/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java index 98f74ac84..193452a3f 100644 --- a/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java @@ -83,6 +83,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { public static final int MSG_X1_PHOTO_DATA = 0x36; public static final int MSG_WIFI_2 = 0x69; public static final int MSG_GPS_MODULAR = 0x70; + public static final int MSG_WIFI_4 = 0xF3; public static final int MSG_COMMAND_0 = 0x80; public static final int MSG_COMMAND_1 = 0x81; public static final int MSG_COMMAND_2 = 0x82; @@ -521,7 +522,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { return decodeX1(channel, buf, deviceSession, type); - } else if (type == MSG_WIFI || type == MSG_WIFI_2) { + } else if (type == MSG_WIFI || type == MSG_WIFI_2 || type == MSG_WIFI_4) { return decodeWifi(channel, buf, deviceSession, type); @@ -620,35 +621,52 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { Network network = new Network(); - int wifiCount = buf.getByte(2); + int wifiCount; + if (type == MSG_WIFI_4) { + wifiCount = buf.readUnsignedByte(); + } else { + wifiCount = buf.getUnsignedByte(2); + } + for (int i = 0; i < wifiCount; i++) { - String mac = String.format("%02x:%02x:%02x:%02x:%02x:%02x", + if (type == MSG_WIFI_4) { + buf.skipBytes(2); + } + WifiAccessPoint wifiAccessPoint = new WifiAccessPoint(); + wifiAccessPoint.setMacAddress(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())); + buf.readUnsignedByte(), buf.readUnsignedByte(), buf.readUnsignedByte())); + if (type != MSG_WIFI_4) { + wifiAccessPoint.setSignalStrength((int) buf.readUnsignedByte()); + } + network.addWifiAccessPoint(wifiAccessPoint); } - 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())); - } + if (type != MSG_WIFI_4) { - position.setNetwork(network); + 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())); + } + + if (channel != null) { + ByteBuf response = Unpooled.buffer(); + response.writeShort(0x7878); + response.writeByte(0); + response.writeByte(type); + response.writeBytes(time.resetReaderIndex()); + response.writeByte('\r'); + response.writeByte('\n'); + channel.writeAndFlush(new NetworkMessage(response, channel.remoteAddress())); + } - if (channel != null) { - ByteBuf response = Unpooled.buffer(); - response.writeShort(0x7878); - response.writeByte(0); - response.writeByte(type); - response.writeBytes(time.resetReaderIndex()); - response.writeByte('\r'); - response.writeByte('\n'); - channel.writeAndFlush(new NetworkMessage(response, channel.remoteAddress())); } + position.setNetwork(network); + return position; } diff --git a/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java index d63dc2d9a..518aeed9d 100644 --- a/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java @@ -20,6 +20,9 @@ public class Gt06ProtocolDecoderTest extends ProtocolTest { verifyNull(decoder, binary( "797900099b0380d600046f91e90d0a")); + verifyNotNull(decoder, binary( + "787844F3140C0B0A262A070000DC9FDB1C1D760000C83A3569A37100008825937287000000EC41180C8209000088C39749553700003891D5604D6300003891D5604D68002EC4230D0A")); + verifyAttribute(decoder, binary( "7979000E9B0332382E33A1E60D0A0289BE490D0A"), Position.PREFIX_TEMP + 1, 28.3); |