aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/GpsGateProtocolDecoder.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/protocol/GpsGateProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/GpsGateProtocolDecoder.java21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/org/traccar/protocol/GpsGateProtocolDecoder.java b/src/org/traccar/protocol/GpsGateProtocolDecoder.java
index 5c7096276..6eff3eb76 100644
--- a/src/org/traccar/protocol/GpsGateProtocolDecoder.java
+++ b/src/org/traccar/protocol/GpsGateProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 - 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,9 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.Checksum;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
@@ -65,9 +66,9 @@ public class GpsGateProtocolDecoder extends BaseProtocolDecoder {
.any()
.compile();
- private void send(Channel channel, String message) {
+ private void send(Channel channel, SocketAddress remoteAddress, String message) {
if (channel != null) {
- channel.write(message + Checksum.nmea(message) + "\r\n");
+ channel.writeAndFlush(new NetworkMessage(message + Checksum.nmea(message) + "\r\n", remoteAddress));
}
}
@@ -79,7 +80,6 @@ public class GpsGateProtocolDecoder extends BaseProtocolDecoder {
if (sentence.startsWith("$FRLIN,")) {
- // Login
int beginIndex = sentence.indexOf(',', 7);
if (beginIndex != -1) {
beginIndex += 1;
@@ -89,22 +89,21 @@ public class GpsGateProtocolDecoder extends BaseProtocolDecoder {
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, imei);
if (deviceSession != null) {
if (channel != null) {
- send(channel, "$FRSES," + channel.getId());
+ send(channel, remoteAddress, "$FRSES," + channel.id().asShortText());
}
} else {
- send(channel, "$FRERR,AuthError,Unknown device");
+ send(channel, remoteAddress, "$FRERR,AuthError,Unknown device");
}
} else {
- send(channel, "$FRERR,AuthError,Parse error");
+ send(channel, remoteAddress, "$FRERR,AuthError,Parse error");
}
} else {
- send(channel, "$FRERR,AuthError,Parse error");
+ send(channel, remoteAddress, "$FRERR,AuthError,Parse error");
}
} else if (sentence.startsWith("$FRVER,")) {
- // Version check
- send(channel, "$FRVER,1,0,GpsGate Server 1.0");
+ send(channel, remoteAddress, "$FRVER,1,0,GpsGate Server 1.0");
} else if (sentence.startsWith("$GPRMC,")) {