aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-03-04 18:11:40 -0800
committerAnton Tananaev <anton@traccar.org>2022-03-04 18:11:40 -0800
commit18d8ec9610944aee95aa01ffbe402f3d0c30c39a (patch)
treea9e96b504f773f0106043ba168c4f7ae103fa316 /src/main/java/org
parent76873ef0a00b0b5f71755e754b134c9cb34efc6e (diff)
downloadtrackermap-server-18d8ec9610944aee95aa01ffbe402f3d0c30c39a.tar.gz
trackermap-server-18d8ec9610944aee95aa01ffbe402f3d0c30c39a.tar.bz2
trackermap-server-18d8ec9610944aee95aa01ffbe402f3d0c30c39a.zip
Fix TeraTrack protocol
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/traccar/protocol/TeraTrackProtocolDecoder.java13
1 files changed, 3 insertions, 10 deletions
diff --git a/src/main/java/org/traccar/protocol/TeraTrackProtocolDecoder.java b/src/main/java/org/traccar/protocol/TeraTrackProtocolDecoder.java
index fadccccba..7cd678f8a 100644
--- a/src/main/java/org/traccar/protocol/TeraTrackProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/TeraTrackProtocolDecoder.java
@@ -16,9 +16,7 @@
package org.traccar.protocol;
import io.netty.channel.Channel;
-import io.netty.handler.codec.http.FullHttpRequest;
-import io.netty.handler.codec.http.HttpResponseStatus;
-import org.traccar.BaseHttpProtocolDecoder;
+import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.Protocol;
import org.traccar.helper.UnitsConverter;
@@ -28,12 +26,11 @@ import javax.json.Json;
import javax.json.JsonObject;
import java.io.StringReader;
import java.net.SocketAddress;
-import java.nio.charset.StandardCharsets;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.TimeZone;
-public class TeraTrackProtocolDecoder extends BaseHttpProtocolDecoder {
+public class TeraTrackProtocolDecoder extends BaseProtocolDecoder {
public TeraTrackProtocolDecoder(Protocol protocol) {
super(protocol);
@@ -43,15 +40,12 @@ public class TeraTrackProtocolDecoder extends BaseHttpProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- FullHttpRequest request = (FullHttpRequest) msg;
- JsonObject json = Json.createReader(
- new StringReader(request.content().toString(StandardCharsets.US_ASCII))).readObject();
+ JsonObject json = Json.createReader(new StringReader((String) msg)).readObject();
String deviceId = json.getString("MDeviceID");
String imei = json.getString("IMEI");
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, deviceId, imei);
if (deviceSession == null) {
- sendResponse(channel, HttpResponseStatus.NOT_FOUND);
return null;
}
@@ -73,7 +67,6 @@ public class TeraTrackProtocolDecoder extends BaseHttpProtocolDecoder {
position.set(Position.KEY_ODOMETER, Integer.parseInt(json.getString("Mileage")));
- sendResponse(channel, HttpResponseStatus.OK);
return position;
}