aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-11-24 11:06:04 -0800
committerAnton Tananaev <anton@traccar.org>2022-11-24 11:06:04 -0800
commit19d10da19db57b2119c295cb452a271c3de48f85 (patch)
tree9c18cac39f8ad2c9f8d6fe25126309ed7c7e7c13
parent39e12dfb5a9fe13d93c89a078f2dd0c03a55b404 (diff)
downloadtrackermap-server-19d10da19db57b2119c295cb452a271c3de48f85.tar.gz
trackermap-server-19d10da19db57b2119c295cb452a271c3de48f85.tar.bz2
trackermap-server-19d10da19db57b2119c295cb452a271c3de48f85.zip
ATrack AK11 text responses
-rw-r--r--src/main/java/org/traccar/protocol/AtrackProtocolDecoder.java20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/main/java/org/traccar/protocol/AtrackProtocolDecoder.java b/src/main/java/org/traccar/protocol/AtrackProtocolDecoder.java
index 4567582db..340641729 100644
--- a/src/main/java/org/traccar/protocol/AtrackProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/AtrackProtocolDecoder.java
@@ -100,7 +100,7 @@ public class AtrackProtocolDecoder extends BaseProtocolDecoder {
this.form = form;
}
- private static void sendResponse(Channel channel, SocketAddress remoteAddress, long rawId, int index) {
+ private void sendResponse(Channel channel, SocketAddress remoteAddress, long rawId, int index) {
if (channel != null) {
ByteBuf response = Unpooled.buffer(12);
response.writeShort(0xfe02);
@@ -526,20 +526,24 @@ public class AtrackProtocolDecoder extends BaseProtocolDecoder {
private List<Position> decodeText(Channel channel, SocketAddress remoteAddress, String sentence) {
- int startIndex = -1;
- for (int i = 0; i < 4; i++) {
- startIndex = sentence.indexOf(',', startIndex + 1);
+ int positionIndex = -1;
+ for (int i = 0; i < 5; i++) {
+ positionIndex = sentence.indexOf(',', positionIndex + 1);
}
- int endIndex = sentence.indexOf(',', startIndex + 1);
- String imei = sentence.substring(startIndex + 1, endIndex);
- DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, imei);
+ String[] headers = sentence.substring(0, positionIndex).split(",");
+ long id = Long.parseLong(headers[2]);
+ int index = Integer.parseInt(headers[3]);
+
+ DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, headers[4]);
if (deviceSession == null) {
return null;
}
+ sendResponse(channel, remoteAddress, id, index);
+
List<Position> positions = new LinkedList<>();
- String[] lines = sentence.substring(endIndex + 1).split("\r\n");
+ String[] lines = sentence.substring(positionIndex + 1).split("\r\n");
for (String line : lines) {
Position position = decodeTextLine(deviceSession, line);