aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2019-12-02 21:35:36 -0800
committerAnton Tananaev <anton.tananaev@gmail.com>2019-12-02 21:35:36 -0800
commita379356a52cddbd942cee2dfdf87614adba4aa63 (patch)
tree90eb7b51fc0d0c5261d54b9ed1a6cc6b9d2a7358 /src/main/java/org/traccar
parent8a918e12f4a899a4ffdb67c58d57daefb94c5ab4 (diff)
downloadtrackermap-server-a379356a52cddbd942cee2dfdf87614adba4aa63.tar.gz
trackermap-server-a379356a52cddbd942cee2dfdf87614adba4aa63.tar.bz2
trackermap-server-a379356a52cddbd942cee2dfdf87614adba4aa63.zip
Handle binary custom commands
Diffstat (limited to 'src/main/java/org/traccar')
-rw-r--r--src/main/java/org/traccar/protocol/RuptelaProtocolEncoder.java11
1 files changed, 9 insertions, 2 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