diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2017-10-28 21:05:56 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2017-10-28 21:05:56 +1300 |
commit | 9bc7deb97f2751ee0fd7e5ba198d2c030d149e01 (patch) | |
tree | 75acd9fe2aa773d1b802cfe7d42e200d4e5eddac | |
parent | 7ee3f22184bfe4ed61f6a0eaf2f52116ac02b2ee (diff) | |
download | trackermap-server-9bc7deb97f2751ee0fd7e5ba198d2c030d149e01.tar.gz trackermap-server-9bc7deb97f2751ee0fd7e5ba198d2c030d149e01.tar.bz2 trackermap-server-9bc7deb97f2751ee0fd7e5ba198d2c030d149e01.zip |
Extend Bofan PT600 support
4 files changed, 22 insertions, 1 deletions
diff --git a/src/org/traccar/protocol/Pt502Protocol.java b/src/org/traccar/protocol/Pt502Protocol.java index ad97a777e..0116422c2 100644 --- a/src/org/traccar/protocol/Pt502Protocol.java +++ b/src/org/traccar/protocol/Pt502Protocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2016 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,6 +31,7 @@ public class Pt502Protocol extends BaseProtocol { public Pt502Protocol() { super("pt502"); setSupportedDataCommands( + Command.TYPE_CUSTOM, Command.TYPE_SET_TIMEZONE, Command.TYPE_ALARM_SPEED, Command.TYPE_OUTPUT_CONTROL, diff --git a/src/org/traccar/protocol/Pt502ProtocolDecoder.java b/src/org/traccar/protocol/Pt502ProtocolDecoder.java index fef5d9b39..1d976dcd5 100644 --- a/src/org/traccar/protocol/Pt502ProtocolDecoder.java +++ b/src/org/traccar/protocol/Pt502ProtocolDecoder.java @@ -62,6 +62,10 @@ public class Pt502ProtocolDecoder extends BaseProtocolDecoder { private String decodeAlarm(String value) {
switch (value) {
+ case "IN1":
+ return Position.ALARM_SOS;
+ case "GOF":
+ return Position.ALARM_GEOFENCE;
case "TOW":
return Position.ALARM_TOW;
case "HDA":
diff --git a/src/org/traccar/protocol/Pt502ProtocolEncoder.java b/src/org/traccar/protocol/Pt502ProtocolEncoder.java index 4a876f6da..bd56e306a 100644 --- a/src/org/traccar/protocol/Pt502ProtocolEncoder.java +++ b/src/org/traccar/protocol/Pt502ProtocolEncoder.java @@ -41,6 +41,8 @@ public class Pt502ProtocolEncoder extends StringProtocolEncoder implements Strin protected Object encodeCommand(Command command) { switch (command.getType()) { + case Command.TYPE_CUSTOM: + return formatCommand(command, "{%s}\r\n", Command.KEY_DATA); case Command.TYPE_OUTPUT_CONTROL: return formatCommand(command, "#OPC{%s},{%s}\r\n", Command.KEY_INDEX, Command.KEY_DATA); case Command.TYPE_SET_TIMEZONE: diff --git a/test/org/traccar/protocol/Pt502ProtocolEncoderTest.java b/test/org/traccar/protocol/Pt502ProtocolEncoderTest.java index 62406d3f2..39ca2fe65 100644 --- a/test/org/traccar/protocol/Pt502ProtocolEncoderTest.java +++ b/test/org/traccar/protocol/Pt502ProtocolEncoderTest.java @@ -8,6 +8,20 @@ import org.traccar.model.Command; public class Pt502ProtocolEncoderTest extends ProtocolTest { @Test + public void testEncodeCustom() throws Exception { + + Pt502ProtocolEncoder encoder = new Pt502ProtocolEncoder(); + + Command command = new Command(); + command.setDeviceId(1); + command.setType(Command.TYPE_CUSTOM); + command.set(Command.KEY_DATA, "#PTI300"); + + Assert.assertEquals("#PTI300\r\n", encoder.encodeCommand(command)); + + } + + @Test public void testEncodeOutputControl() throws Exception { Pt502ProtocolEncoder encoder = new Pt502ProtocolEncoder(); |