aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-03-11 21:17:02 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2020-03-11 21:17:02 -0700
commit578a8544bc0d31569fabbc8c3aa26a53d161d5ed (patch)
tree7ccae102e2ae8ce4a78fd9578a591cba85b4fc48 /src/main/java/org/traccar
parent26cc87fd06b94400ee769e8c2985778b3b6e8ff6 (diff)
downloadtrackermap-server-578a8544bc0d31569fabbc8c3aa26a53d161d5ed.tar.gz
trackermap-server-578a8544bc0d31569fabbc8c3aa26a53d161d5ed.tar.bz2
trackermap-server-578a8544bc0d31569fabbc8c3aa26a53d161d5ed.zip
Fix response index
Diffstat (limited to 'src/main/java/org/traccar')
-rw-r--r--src/main/java/org/traccar/protocol/EskyProtocolDecoder.java15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/main/java/org/traccar/protocol/EskyProtocolDecoder.java b/src/main/java/org/traccar/protocol/EskyProtocolDecoder.java
index f0ae0bc91..1a4f9b906 100644
--- a/src/main/java/org/traccar/protocol/EskyProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/EskyProtocolDecoder.java
@@ -38,7 +38,7 @@ public class EskyProtocolDecoder extends BaseProtocolDecoder {
private static final Pattern PATTERN = new PatternBuilder()
.expression("..;") // header
- .number("(d+);") // index
+ .number("d+;")
.number("(d+);") // imei
.text("R;") // data type
.number("(d+)[+;]") // satellites
@@ -61,16 +61,12 @@ public class EskyProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- Parser parser = new Parser(PATTERN, (String) msg);
+ String sentence = (String) msg;
+ Parser parser = new Parser(PATTERN, sentence);
if (!parser.matches()) {
return null;
}
- int index = parser.nextInt();
- if (channel instanceof DatagramChannel) {
- channel.writeAndFlush(new NetworkMessage("ACK," + index + "#", remoteAddress));
- }
-
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next());
if (deviceSession == null) {
return null;
@@ -99,6 +95,11 @@ public class EskyProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_BATTERY, parser.nextInt() * 0.001);
+ int index = sentence.lastIndexOf('+');
+ if (index > 0 && channel instanceof DatagramChannel) {
+ channel.writeAndFlush(new NetworkMessage("ACK," + sentence.substring(index + 1) + "#", remoteAddress));
+ }
+
return position;
}