aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/protocol/RuptelaProtocolEncoder.java11
-rw-r--r--src/test/java/org/traccar/protocol/RuptelaProtocolEncoderTest.java5
2 files changed, 13 insertions, 3 deletions
diff --git a/src/main/java/org/traccar/protocol/RuptelaProtocolEncoder.java b/src/main/java/org/traccar/protocol/RuptelaProtocolEncoder.java
index 51967403d..5c053dbcb 100644
--- a/src/main/java/org/traccar/protocol/RuptelaProtocolEncoder.java
+++ b/src/main/java/org/traccar/protocol/RuptelaProtocolEncoder.java
@@ -19,6 +19,7 @@ import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import org.traccar.BaseProtocolEncoder;
import org.traccar.helper.Checksum;
+import org.traccar.helper.DataConverter;
import org.traccar.model.Command;
import org.traccar.Protocol;
@@ -49,8 +50,14 @@ public class RuptelaProtocolEncoder extends BaseProtocolEncoder {
switch (command.getType()) {
case Command.TYPE_CUSTOM:
- content.writeBytes(command.getString(Command.KEY_DATA).getBytes(StandardCharsets.US_ASCII));
- return encodeContent(RuptelaProtocolDecoder.MSG_SMS_VIA_GPRS, content);
+ String data = command.getString(Command.KEY_DATA);
+ if (data.matches("(\\p{XDigit}{2})+")) {
+ content.writeBytes(DataConverter.parseHex(data));
+ return content;
+ } else {
+ content.writeBytes(data.getBytes(StandardCharsets.US_ASCII));
+ return encodeContent(RuptelaProtocolDecoder.MSG_SMS_VIA_GPRS, content);
+ }
case Command.TYPE_REQUEST_PHOTO:
content.writeByte(1); // sub-command
content.writeByte(0); // source
diff --git a/src/test/java/org/traccar/protocol/RuptelaProtocolEncoderTest.java b/src/test/java/org/traccar/protocol/RuptelaProtocolEncoderTest.java
index 5868b07df..613a89b96 100644
--- a/src/test/java/org/traccar/protocol/RuptelaProtocolEncoderTest.java
+++ b/src/test/java/org/traccar/protocol/RuptelaProtocolEncoderTest.java
@@ -14,10 +14,13 @@ public class RuptelaProtocolEncoderTest extends ProtocolTest {
Command command = new Command();
command.setDeviceId(1);
command.setType(Command.TYPE_CUSTOM);
- command.set(Command.KEY_DATA, " Setio 2,1");
+ command.set(Command.KEY_DATA, " Setio 2,1");
verifyCommand(encoder, command, binary("000b6c20536574696F20322C31eb3e"));
+ command.set(Command.KEY_DATA, "000b890100000000007fffffff89f0");
+ verifyCommand(encoder, command, binary("000b890100000000007fffffff89f0"));
+
}
}