aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-03-15 16:22:35 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2020-03-15 16:22:35 -0700
commitf85af44e180c87993d2d8d760f64af775f99531f (patch)
treec6b150fb8b52323c81140668cf7686b4a395f481 /src
parent0164474c700337c686fea93e2ca4875adaaf35d5 (diff)
downloadtrackermap-server-f85af44e180c87993d2d8d760f64af775f99531f.tar.gz
trackermap-server-f85af44e180c87993d2d8d760f64af775f99531f.tar.bz2
trackermap-server-f85af44e180c87993d2d8d760f64af775f99531f.zip
Support commands for OsmAnd
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/protocol/OsmAndProtocolDecoder.java23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/main/java/org/traccar/protocol/OsmAndProtocolDecoder.java b/src/main/java/org/traccar/protocol/OsmAndProtocolDecoder.java
index 3bc71de81..ec9bbc240 100644
--- a/src/main/java/org/traccar/protocol/OsmAndProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/OsmAndProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 - 2018 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2020 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,15 +15,19 @@
*/
package org.traccar.protocol;
+import io.netty.buffer.Unpooled;
import io.netty.channel.Channel;
import io.netty.handler.codec.http.FullHttpRequest;
import io.netty.handler.codec.http.HttpResponseStatus;
import io.netty.handler.codec.http.QueryStringDecoder;
import org.traccar.BaseHttpProtocolDecoder;
+import org.traccar.Context;
import org.traccar.DeviceSession;
import org.traccar.Protocol;
+import org.traccar.database.CommandsManager;
import org.traccar.helper.DateUtil;
import org.traccar.model.CellTower;
+import org.traccar.model.Command;
import org.traccar.model.Network;
import org.traccar.model.Position;
import org.traccar.model.WifiAccessPoint;
@@ -173,7 +177,18 @@ public class OsmAndProtocolDecoder extends BaseHttpProtocolDecoder {
}
if (position.getDeviceId() != 0) {
- sendResponse(channel, HttpResponseStatus.OK);
+ String response = null;
+ CommandsManager commandsManager = Context.getCommandsManager();
+ if (commandsManager != null) {
+ for (Command command : commandsManager.readQueuedCommands(position.getDeviceId(), 1)) {
+ response = command.getString(Command.KEY_DATA);
+ }
+ }
+ if (response != null) {
+ sendResponse(channel, HttpResponseStatus.OK, Unpooled.copiedBuffer(response, StandardCharsets.UTF_8));
+ } else {
+ sendResponse(channel, HttpResponseStatus.OK);
+ }
return position;
} else {
sendResponse(channel, HttpResponseStatus.BAD_REQUEST);
@@ -181,4 +196,8 @@ public class OsmAndProtocolDecoder extends BaseHttpProtocolDecoder {
}
}
+ @Override
+ protected void sendQueuedCommands(Channel channel, SocketAddress remoteAddress, long deviceId) {
+ }
+
}