aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar/protocol')
-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;
}