aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/database/CommandsManager.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar/database/CommandsManager.java')
-rw-r--r--src/main/java/org/traccar/database/CommandsManager.java21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/main/java/org/traccar/database/CommandsManager.java b/src/main/java/org/traccar/database/CommandsManager.java
index d6fdd66ca..dc9512d9e 100644
--- a/src/main/java/org/traccar/database/CommandsManager.java
+++ b/src/main/java/org/traccar/database/CommandsManager.java
@@ -20,6 +20,7 @@ import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Queue;
@@ -106,17 +107,21 @@ public class CommandsManager extends ExtendedObjectManager<Command> {
}
public Collection<Typed> getCommandTypes(long deviceId, boolean textChannel) {
- List<Typed> result = new ArrayList<>();
Position lastPosition = Context.getIdentityManager().getLastPosition(deviceId);
if (lastPosition != null) {
- BaseProtocol protocol = Context.getServerManager().getProtocol(lastPosition.getProtocol());
- Collection<String> commands;
- commands = textChannel ? protocol.getSupportedTextCommands() : protocol.getSupportedDataCommands();
- for (String commandKey : commands) {
- result.add(new Typed(commandKey));
- }
+ return getCommandTypes(lastPosition.getProtocol(), textChannel);
} else {
- result.add(new Typed(Command.TYPE_CUSTOM));
+ return Collections.singletonList(new Typed(Command.TYPE_CUSTOM));
+ }
+ }
+
+ public Collection<Typed> getCommandTypes(String protocolName, boolean textChannel) {
+ List<Typed> result = new ArrayList<>();
+ BaseProtocol protocol = Context.getServerManager().getProtocol(protocolName);
+ Collection<String> commands;
+ commands = textChannel ? protocol.getSupportedTextCommands() : protocol.getSupportedDataCommands();
+ for (String commandKey : commands) {
+ result.add(new Typed(commandKey));
}
return result;
}