diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2018-11-15 11:24:22 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2018-11-15 11:24:22 +1300 |
commit | 8023e4e3de6fa791157bdec913abcafb511512c9 (patch) | |
tree | 3e5340216dbceaaa5c27a147707847812f62c2b7 | |
parent | 7de7d81c59eef4a134e313615012a2694a8ca572 (diff) | |
download | traccar-server-8023e4e3de6fa791157bdec913abcafb511512c9.tar.gz traccar-server-8023e4e3de6fa791157bdec913abcafb511512c9.tar.bz2 traccar-server-8023e4e3de6fa791157bdec913abcafb511512c9.zip |
Support new protocol version
-rw-r--r-- | src/org/traccar/protocol/Xrb28ProtocolDecoder.java | 6 | ||||
-rw-r--r-- | src/org/traccar/protocol/Xrb28ProtocolEncoder.java | 2 | ||||
-rw-r--r-- | test/org/traccar/protocol/Xrb28ProtocolEncoderTest.java | 4 |
3 files changed, 7 insertions, 5 deletions
diff --git a/src/org/traccar/protocol/Xrb28ProtocolDecoder.java b/src/org/traccar/protocol/Xrb28ProtocolDecoder.java index c1854e4b0..a50716abb 100644 --- a/src/org/traccar/protocol/Xrb28ProtocolDecoder.java +++ b/src/org/traccar/protocol/Xrb28ProtocolDecoder.java @@ -77,11 +77,13 @@ public class Xrb28ProtocolDecoder extends BaseProtocolDecoder { if (channel != null) { if (type.matches("L0|L1|W0|E1")) { channel.write(new NetworkMessage( - sentence.substring(0, 27) + "#\n", remoteAddress)); + sentence.substring(0, 27).replace("SCOR", "SCOS") + "#\n", + remoteAddress)); } else if (type.equals("R0") && pendingCommand != null) { String command = pendingCommand.equals(Command.TYPE_ALARM_ARM) ? "L1," : "L0,"; channel.write(new NetworkMessage( - sentence.substring(0, 25) + command + sentence.substring(30) + "\n", remoteAddress)); + sentence.substring(0, 25).replace("SCOR", "SCOS") + command + sentence.substring(30) + "\n", + remoteAddress)); pendingCommand = null; } } diff --git a/src/org/traccar/protocol/Xrb28ProtocolEncoder.java b/src/org/traccar/protocol/Xrb28ProtocolEncoder.java index af60661fa..617639312 100644 --- a/src/org/traccar/protocol/Xrb28ProtocolEncoder.java +++ b/src/org/traccar/protocol/Xrb28ProtocolEncoder.java @@ -22,7 +22,7 @@ import org.traccar.model.Command; public class Xrb28ProtocolEncoder extends BaseProtocolEncoder { private String formatCommand(Command command, String content) { - return String.format("\u00ff\u00ff*HBCS,OM,%s,%s#\n", getUniqueId(command.getDeviceId()), content); + return String.format("\u00ff\u00ff*SCOS,OM,%s,%s#\n", getUniqueId(command.getDeviceId()), content); } @Override diff --git a/test/org/traccar/protocol/Xrb28ProtocolEncoderTest.java b/test/org/traccar/protocol/Xrb28ProtocolEncoderTest.java index 4b2ac2045..49476d694 100644 --- a/test/org/traccar/protocol/Xrb28ProtocolEncoderTest.java +++ b/test/org/traccar/protocol/Xrb28ProtocolEncoderTest.java @@ -18,7 +18,7 @@ public class Xrb28ProtocolEncoderTest extends ProtocolTest { command.setType(Command.TYPE_POSITION_PERIODIC); command.set(Command.KEY_FREQUENCY, 300); - assertEquals("\u00ff\u00ff*HBCS,OM,123456789012345,D1,300#\n", encoder.encodeCommand(null, command)); + assertEquals("\u00ff\u00ff*SCOS,OM,123456789012345,D1,300#\n", encoder.encodeCommand(null, command)); } @@ -32,7 +32,7 @@ public class Xrb28ProtocolEncoderTest extends ProtocolTest { command.setType(Command.TYPE_CUSTOM); command.set(Command.KEY_DATA, "S7,0,3,0,0,20,25"); - assertEquals("\u00ff\u00ff*HBCS,OM,123456789012345,S7,0,3,0,0,20,25#\n", encoder.encodeCommand(null, command)); + assertEquals("\u00ff\u00ff*SCOS,OM,123456789012345,S7,0,3,0,0,20,25#\n", encoder.encodeCommand(null, command)); } |