aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol
diff options
context:
space:
mode:
authorGavriel Fleischer <flocsy@gmail.com>2019-02-17 04:53:22 +0200
committerGavriel Fleischer <flocsy@gmail.com>2019-02-17 04:53:22 +0200
commitc80d01e1646b8cb1a626f33bbd488d02f15335cc (patch)
treeddcbe707aa6a594c64055336ef218b98f2e82b32 /src/org/traccar/protocol
parent5fe7762b7f17d8d19e86ffb20a3adfc09d700f1a (diff)
downloadtrackermap-server-c80d01e1646b8cb1a626f33bbd488d02f15335cc.tar.gz
trackermap-server-c80d01e1646b8cb1a626f33bbd488d02f15335cc.tar.bz2
trackermap-server-c80d01e1646b8cb1a626f33bbd488d02f15335cc.zip
fixed WatchProtocolDecoder response after removed StringEncoder
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r--src/org/traccar/protocol/WatchProtocolDecoder.java22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/org/traccar/protocol/WatchProtocolDecoder.java b/src/org/traccar/protocol/WatchProtocolDecoder.java
index bf4d99a49..aaf63206c 100644
--- a/src/org/traccar/protocol/WatchProtocolDecoder.java
+++ b/src/org/traccar/protocol/WatchProtocolDecoder.java
@@ -16,6 +16,7 @@
package org.traccar.protocol;
import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
import io.netty.channel.Channel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -66,15 +67,18 @@ public class WatchProtocolDecoder extends BaseProtocolDecoder {
.expression("(.*)") // cell and wifi
.compile();
- private void sendResponse(Channel channel, String id, String index, String content) {
+ private void sendTextResponse(Channel channel, String id, String index, String content) {
if (channel != null) {
+ String response;
if (index != null) {
- channel.writeAndFlush(new NetworkMessage(String.format("[%s*%s*%s*%04x*%s]",
- manufacturer, id, index, content.length(), content), channel.remoteAddress()));
+ response = String.format("[%s*%s*%s*%04x*%s]",
+ manufacturer, id, index, content.length(), content);
} else {
- channel.writeAndFlush(new NetworkMessage(String.format("[%s*%s*%04x*%s]",
- manufacturer, id, content.length(), content), channel.remoteAddress()));
+ response = String.format("[%s*%s*%04x*%s]",
+ manufacturer, id, content.length(), content);
}
+ ByteBuf buf = Unpooled.copiedBuffer(response, StandardCharsets.US_ASCII);
+ channel.writeAndFlush(new NetworkMessage(buf, channel.remoteAddress()));
}
}
@@ -229,11 +233,11 @@ public class WatchProtocolDecoder extends BaseProtocolDecoder {
if (type.equals("INIT")) {
- sendResponse(channel, id, index, "INIT,1");
+ sendTextResponse(channel, id, index, "INIT,1");
} else if (type.equals("LK")) {
- sendResponse(channel, id, index, "LK");
+ sendTextResponse(channel, id, index, "LK");
if (buf.isReadable()) {
String[] values = buf.toString(StandardCharsets.US_ASCII).split(",");
@@ -258,14 +262,14 @@ public class WatchProtocolDecoder extends BaseProtocolDecoder {
if (position != null) {
position.set(Position.KEY_ALARM, Position.ALARM_SOS);
}
- sendResponse(channel, id, index, "AL");
+ sendTextResponse(channel, id, index, "AL");
}
return position;
} else if (type.equals("TKQ")) {
- sendResponse(channel, id, index, "TKQ");
+ sendTextResponse(channel, id, index, "TKQ");
} else if (type.equals("PULSE") || type.equals("heart") || type.equals("bphrt")) {