From d8da0a28c50993e275b5ce9028d9e21ab23944aa Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 16 Jul 2016 17:24:19 +1200 Subject: Implement T800X custom commands --- .../traccar/protocol/T800xProtocolEncoderTest.java | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 test/org/traccar/protocol/T800xProtocolEncoderTest.java (limited to 'test/org/traccar/protocol') diff --git a/test/org/traccar/protocol/T800xProtocolEncoderTest.java b/test/org/traccar/protocol/T800xProtocolEncoderTest.java new file mode 100644 index 000000000..af3700225 --- /dev/null +++ b/test/org/traccar/protocol/T800xProtocolEncoderTest.java @@ -0,0 +1,23 @@ +package org.traccar.protocol; + +import org.junit.Test; +import org.traccar.ProtocolTest; +import org.traccar.model.Command; + +public class T800xProtocolEncoderTest extends ProtocolTest { + + @Test + public void testEncode() throws Exception { + + T800xProtocolEncoder encoder = new T800xProtocolEncoder(); + + Command command = new Command(); + command.setDeviceId(1); + command.setType(Command.TYPE_CUSTOM); + command.set(Command.KEY_DATA, "RELAY,0000,On#"); + + verifyCommand(encoder, command, binary("232381001e000101234567890123450152454c41592c303030302c4f6e23")); + + } + +} -- cgit v1.2.3 From 24fa824e20cf68d36f760e4b921edb1fb25525b3 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 18 Jul 2016 14:25:18 +1200 Subject: Support GT06 external power subtype --- src/org/traccar/protocol/Gt06ProtocolDecoder.java | 14 +++++++++++++- test/org/traccar/protocol/Gt06ProtocolDecoderTest.java | 3 +++ 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'test/org/traccar/protocol') diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java index ce915fde8..57e2d64b7 100644 --- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java @@ -277,7 +277,19 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { if (type == MSG_INFO) { int subType = buf.readUnsignedByte(); - if (subType == 0x05) { + if (subType == 0x00) { + + Position position = new Position(); + position.setDeviceId(getDeviceId()); + position.setProtocol(getProtocolName()); + + getLastLocation(position, null); + + position.set(Position.KEY_POWER, buf.readUnsignedShort() * 0.01); + + return position; + + } else if (subType == 0x05) { Position position = new Position(); position.setDeviceId(getDeviceId()); diff --git a/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java b/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java index 94d665478..9201caac6 100644 --- a/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java @@ -13,6 +13,9 @@ public class Gt06ProtocolDecoderTest extends ProtocolTest { verifyNothing(decoder, binary( "787805120099abec0d0a")); + verifyAttributes(decoder, binary( + "797900089400000002e852d70d0a")); + verifyNothing(decoder, binary( "78780D01086471700328358100093F040D0A")); -- cgit v1.2.3