From 5b56c2cc17fa23251b1985aa4d8f56dd6552b970 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 19 Jul 2017 21:23:48 +1200 Subject: Implement JV200 ignition support --- test/org/traccar/protocol/Gt06ProtocolDecoderTest.java | 3 +++ 1 file changed, 3 insertions(+) (limited to 'test/org/traccar/protocol/Gt06ProtocolDecoderTest.java') diff --git a/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java b/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java index 0ac51f4b2..2e6a53b06 100644 --- a/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java @@ -16,6 +16,9 @@ public class Gt06ProtocolDecoderTest extends ProtocolTest { verifyNull(decoder, binary( "78780D01086471700328358100093F040D0A")); + verifyPosition(decoder, binary( + "787822221106160a1016c60278019407c7783800040001940504700046fc01030100065f570d0a")); + verifyAttributes(decoder, binary( "797900143311070609020b00000000a0030046000109e4610d0a")); -- cgit v1.2.3 From 8b74b160890b9dbdd4a2d660d74d2879df6ceced Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 22 Jul 2017 17:45:51 +1200 Subject: Another GT06 LBS and WiFi message type --- src/org/traccar/protocol/Gt06ProtocolDecoder.java | 122 ++++++++++++--------- .../traccar/protocol/Gt06ProtocolDecoderTest.java | 9 ++ 2 files changed, 79 insertions(+), 52 deletions(-) (limited to 'test/org/traccar/protocol/Gt06ProtocolDecoderTest.java') diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java index aea3a29f4..36358b6e5 100644 --- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java @@ -31,6 +31,7 @@ import org.traccar.model.CellTower; import org.traccar.model.Device; import org.traccar.model.Network; import org.traccar.model.Position; +import org.traccar.model.WifiAccessPoint; import java.net.SocketAddress; import java.nio.charset.StandardCharsets; @@ -68,6 +69,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { public static final int MSG_GPS_LBS_STATUS_1 = 0x16; public static final int MSG_GPS_LBS_STATUS_2 = 0x26; public static final int MSG_GPS_LBS_STATUS_3 = 0x27; + public static final int MSG_LBS_WIFI = 0x2C; public static final int MSG_LBS_PHONE = 0x17; public static final int MSG_LBS_EXTEND = 0x18; public static final int MSG_LBS_STATUS = 0x19; @@ -390,82 +392,98 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { } else { - Position position = new Position(); - position.setDeviceId(deviceSession.getDeviceId()); - position.setProtocol(getProtocolName()); + return decodeBasicOther(channel, buf, deviceSession, type, dataLength); - if (type == MSG_LBS_EXTEND) { + } - DateBuilder dateBuilder = new DateBuilder(timeZone) - .setDate(buf.readUnsignedByte(), buf.readUnsignedByte(), buf.readUnsignedByte()) - .setTime(buf.readUnsignedByte(), buf.readUnsignedByte(), buf.readUnsignedByte()); + return null; + } - getLastLocation(position, dateBuilder.getDate()); + private Object decodeBasicOther(Channel channel, ChannelBuffer buf, + DeviceSession deviceSession, int type, int dataLength) throws Exception { - int mcc = buf.readUnsignedShort(); - int mnc = buf.readUnsignedByte(); - Network network = new Network(); - for (int i = 0; i < 7; i++) { - network.addCellTower(CellTower.from( - mcc, mnc, buf.readUnsignedShort(), buf.readUnsignedMedium(), -buf.readUnsignedByte())); - } - position.setNetwork(network); + Position position = new Position(); + position.setDeviceId(deviceSession.getDeviceId()); + position.setProtocol(getProtocolName()); - } else if (type == MSG_STRING) { + if (type == MSG_LBS_EXTEND || type == MSG_LBS_WIFI) { - getLastLocation(position, null); + DateBuilder dateBuilder = new DateBuilder(timeZone) + .setDate(buf.readUnsignedByte(), buf.readUnsignedByte(), buf.readUnsignedByte()) + .setTime(buf.readUnsignedByte(), buf.readUnsignedByte(), buf.readUnsignedByte()); - int commandLength = buf.readUnsignedByte(); + getLastLocation(position, dateBuilder.getDate()); - if (commandLength > 0) { - buf.readUnsignedByte(); // server flag (reserved) - position.set(Position.KEY_RESULT, - buf.readBytes(commandLength - 1).toString(StandardCharsets.US_ASCII)); - } + int mcc = buf.readUnsignedShort(); + int mnc = buf.readUnsignedByte(); + Network network = new Network(); + for (int i = 0; i < 7; i++) { + network.addCellTower(CellTower.from( + mcc, mnc, buf.readUnsignedShort(), buf.readUnsignedMedium(), -buf.readUnsignedByte())); + } - } else if (isSupported(type)) { + buf.readUnsignedByte(); // time leads - if (hasGps(type)) { - decodeGps(position, buf, false); - } else { - getLastLocation(position, null); - } + int wifiCount = buf.readUnsignedByte(); + for (int i = 0; i < wifiCount; i++) { + String mac = ChannelBuffers.hexDump(buf.readBytes(6)).replaceAll("(..)", "$1:"); + network.addWifiAccessPoint(WifiAccessPoint.from( + mac.substring(0, mac.length() - 1), buf.readUnsignedByte())); + } - if (hasLbs(type)) { - decodeLbs(position, buf, hasStatus(type)); - } + position.setNetwork(network); - if (hasStatus(type)) { - decodeStatus(position, buf); - } + } else if (type == MSG_STRING) { - if (type == MSG_GPS_LBS_1 && buf.readableBytes() >= 4 + 6) { - position.set(Position.KEY_ODOMETER, buf.readUnsignedInt()); - } + getLastLocation(position, null); - if (type == MSG_GPS_LBS_2 && buf.readableBytes() >= 3 + 6) { - position.set(Position.KEY_IGNITION, buf.readUnsignedByte() > 0); - position.set(Position.KEY_EVENT, buf.readUnsignedByte()); // reason - position.set(Position.KEY_ARCHIVE, buf.readUnsignedByte() > 0); - } + int commandLength = buf.readUnsignedByte(); + if (commandLength > 0) { + buf.readUnsignedByte(); // server flag (reserved) + position.set(Position.KEY_RESULT, + buf.readBytes(commandLength - 1).toString(StandardCharsets.US_ASCII)); + } + + } else if (isSupported(type)) { + + if (hasGps(type)) { + decodeGps(position, buf, false); } else { + getLastLocation(position, null); + } - buf.skipBytes(dataLength); - if (type != MSG_COMMAND_0 && type != MSG_COMMAND_1 && type != MSG_COMMAND_2) { - sendResponse(channel, false, type); - } - return null; + if (hasLbs(type)) { + decodeLbs(position, buf, hasStatus(type)); + } + if (hasStatus(type)) { + decodeStatus(position, buf); } - sendResponse(channel, false, type); + if (type == MSG_GPS_LBS_1 && buf.readableBytes() >= 4 + 6) { + position.set(Position.KEY_ODOMETER, buf.readUnsignedInt()); + } - return position; + if (type == MSG_GPS_LBS_2 && buf.readableBytes() >= 3 + 6) { + position.set(Position.KEY_IGNITION, buf.readUnsignedByte() > 0); + position.set(Position.KEY_EVENT, buf.readUnsignedByte()); // reason + position.set(Position.KEY_ARCHIVE, buf.readUnsignedByte() > 0); + } + + } else { + + buf.skipBytes(dataLength); + if (type != MSG_COMMAND_0 && type != MSG_COMMAND_1 && type != MSG_COMMAND_2) { + sendResponse(channel, false, type); + } + return null; } - return null; + sendResponse(channel, false, type); + + return position; } private Object decodeExtended(Channel channel, SocketAddress remoteAddress, ChannelBuffer buf) throws Exception { diff --git a/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java b/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java index 2e6a53b06..3c767c908 100644 --- a/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java @@ -16,6 +16,12 @@ public class Gt06ProtocolDecoderTest extends ProtocolTest { verifyNull(decoder, binary( "78780D01086471700328358100093F040D0A")); + verifyNotNull(decoder, binary( + "7878412c11030b011c1f013604cb8a00b17754cb8a00bef357cb8a00b73f5fcb8900b0e25fcb8900b6655fcb8a00b74960cb8a00b178620701001801eb40393800bbbde10d0a")); + + verifyNotNull(decoder, binary( + "7878412c11030b012629013604cb8a00b17757cb8a00b73f5bcb8a00b7495ecb8900b0e25fcb8a00b1b9620000000000ff0000000000ffff01001801eb40393e00c0e6340d0a")); + verifyPosition(decoder, binary( "787822221106160a1016c60278019407c7783800040001940504700046fc01030100065f570d0a")); @@ -149,6 +155,9 @@ public class Gt06ProtocolDecoderTest extends ProtocolTest { verifyNull(decoder, binary( "787811010123456789012345100B3201000171930D0A")); + verifyNull(decoder, binary( + "78780d1f000000000000000200b196a20d0a")); + } } -- cgit v1.2.3 From 128f4be3a22ec1ea9a296be05f67ce20fbdd99d0 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 19 Aug 2017 18:06:49 +1200 Subject: Implement another GT06 LBS message --- src/org/traccar/protocol/Gt06ProtocolDecoder.java | 23 ++++++++++++++-------- .../traccar/protocol/Gt06ProtocolDecoderTest.java | 3 +++ 2 files changed, 18 insertions(+), 8 deletions(-) (limited to 'test/org/traccar/protocol/Gt06ProtocolDecoderTest.java') diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java index 4cf4a79eb..d8da7e6de 100644 --- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java @@ -69,6 +69,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { public static final int MSG_GPS_LBS_STATUS_1 = 0x16; public static final int MSG_GPS_LBS_STATUS_2 = 0x26; public static final int MSG_GPS_LBS_STATUS_3 = 0x27; + public static final int MSG_LBS_MULTIPLE = 0x28; public static final int MSG_LBS_WIFI = 0x2C; public static final int MSG_LBS_PHONE = 0x17; public static final int MSG_LBS_EXTEND = 0x18; @@ -406,7 +407,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { position.setDeviceId(deviceSession.getDeviceId()); position.setProtocol(getProtocolName()); - if (type == MSG_LBS_EXTEND || type == MSG_LBS_WIFI) { + if (type == MSG_LBS_MULTIPLE || type == MSG_LBS_EXTEND || type == MSG_LBS_WIFI) { DateBuilder dateBuilder = new DateBuilder(timeZone) .setDate(buf.readUnsignedByte(), buf.readUnsignedByte(), buf.readUnsignedByte()) @@ -418,17 +419,23 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { int mnc = buf.readUnsignedByte(); Network network = new Network(); for (int i = 0; i < 7; i++) { - network.addCellTower(CellTower.from( - mcc, mnc, buf.readUnsignedShort(), buf.readUnsignedMedium(), -buf.readUnsignedByte())); + int lac = buf.readUnsignedShort(); + int cid = buf.readUnsignedMedium(); + int rssi = -buf.readUnsignedByte(); + if (lac > 0) { + network.addCellTower(CellTower.from(mcc, mnc, lac, cid, rssi)); + } } buf.readUnsignedByte(); // time leads - int wifiCount = buf.readUnsignedByte(); - for (int i = 0; i < wifiCount; i++) { - String mac = ChannelBuffers.hexDump(buf.readBytes(6)).replaceAll("(..)", "$1:"); - network.addWifiAccessPoint(WifiAccessPoint.from( - mac.substring(0, mac.length() - 1), buf.readUnsignedByte())); + if (type != MSG_LBS_MULTIPLE) { + int wifiCount = buf.readUnsignedByte(); + for (int i = 0; i < wifiCount; i++) { + String mac = ChannelBuffers.hexDump(buf.readBytes(6)).replaceAll("(..)", "$1:"); + network.addWifiAccessPoint(WifiAccessPoint.from( + mac.substring(0, mac.length() - 1), buf.readUnsignedByte())); + } } position.setNetwork(network); diff --git a/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java b/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java index 3c767c908..e449a26d4 100644 --- a/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java @@ -16,6 +16,9 @@ public class Gt06ProtocolDecoderTest extends ProtocolTest { verifyNull(decoder, binary( "78780D01086471700328358100093F040D0A")); + verifyNotNull(decoder, binary( + "78783b281108111002050136041bcf0000bf09000000000000000000000000000000000000000000000000000000000000000000000000ff00020007d3280d0a")); + verifyNotNull(decoder, binary( "7878412c11030b011c1f013604cb8a00b17754cb8a00bef357cb8a00b73f5fcb8900b0e25fcb8900b6655fcb8a00b74960cb8a00b178620701001801eb40393800bbbde10d0a")); -- cgit v1.2.3 From eb96d365786785c6b2d8743c3a57f09bd3021f5f Mon Sep 17 00:00:00 2001 From: Anshul Jain Date: Mon, 28 Aug 2017 16:13:25 +0530 Subject: Updated test cases. --- test/org/traccar/protocol/Gt06ProtocolDecoderTest.java | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'test/org/traccar/protocol/Gt06ProtocolDecoderTest.java') diff --git a/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java b/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java index e449a26d4..4042c3bf0 100644 --- a/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java @@ -161,6 +161,13 @@ public class Gt06ProtocolDecoderTest extends ProtocolTest { verifyNull(decoder, binary( "78780d1f000000000000000200b196a20d0a")); + verifyPosition(decoder, binary( + "78781f12110819110216d402f250340828924055d4c801944600d300c09501429c830d0a")); + + verifyPosition(decoder, binary( + "78782516110819110208d402f264dc08289a4058d4c70901944600d300c0954606040600014057e90d0a")); + + } } -- cgit v1.2.3 From 6c2ef65bce9b3d9c7a88da941acf14603965ef93 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Fri, 29 Sep 2017 19:26:08 +1300 Subject: Add GT06 test cases --- test/org/traccar/protocol/Gt06ProtocolDecoderTest.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'test/org/traccar/protocol/Gt06ProtocolDecoderTest.java') diff --git a/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java b/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java index 4042c3bf0..05acd314e 100644 --- a/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java @@ -16,6 +16,15 @@ public class Gt06ProtocolDecoderTest extends ProtocolTest { verifyNull(decoder, binary( "78780D01086471700328358100093F040D0A")); + verifyPosition(decoder, binary( + "7878121011091c0b1b2999058508040097a89e0034520d0a")); + + verifyNull(decoder, binary( + "78780869170928113413ac9e17b30808514494fcf6e148596cb0ce2c67bd4a6eb0ce2c67bd4b0018e7d4333e55ec086be7f2df5fe48d8c94fc6657e48d8cb8f378510600cc0400d37a3d4600d37a3c5000d37a3b6400d376716400d305ac6400d393506e0d0a")); + + verifyNull(decoder, binary( + "787808171709281135331491827b75594dc8d719a9708452cad719a9708550cad719a97086521491827b75574cac9e17b308085dc8d71939633947cad71939633a480700cc0400d37a3d5a00d37a3d5a00d37a3d5a00d37a3d5a00d37a3d5a00d37a3d5a00d37a3d5a0d0a")); + verifyNotNull(decoder, binary( "78783b281108111002050136041bcf0000bf09000000000000000000000000000000000000000000000000000000000000000000000000ff00020007d3280d0a")); @@ -167,6 +176,14 @@ public class Gt06ProtocolDecoderTest extends ProtocolTest { verifyPosition(decoder, binary( "78782516110819110208d402f264dc08289a4058d4c70901944600d300c0954606040600014057e90d0a")); + verifyNull(decoder, binary( + "78780d010359339075005244340d0a")); + + verifyNull(decoder, binary( + "787800691709261259400700cc0400d376714600d37a3d5000d37a3c5000d393505a00d3765d5a00d376735a00d32e6b640d0a")); + + verifyNull(decoder, binary( + "787801080d0a")); } -- cgit v1.2.3