aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-07-11 16:15:02 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2016-07-11 16:15:24 +1200
commit946ea72000eec3a1c38856e5649372d1ee7dd2b0 (patch)
tree9eaabc68e8083dbb006c5cea8f8827107ffefae8 /src/org/traccar
parent2815920deeffdc60edffa10bca4a5915d0dc2c35 (diff)
downloadtrackermap-server-946ea72000eec3a1c38856e5649372d1ee7dd2b0.tar.gz
trackermap-server-946ea72000eec3a1c38856e5649372d1ee7dd2b0.tar.bz2
trackermap-server-946ea72000eec3a1c38856e5649372d1ee7dd2b0.zip
Change command sending logic
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/BaseProtocol.java12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/org/traccar/BaseProtocol.java b/src/org/traccar/BaseProtocol.java
index f968e81cc..352895629 100644
--- a/src/org/traccar/BaseProtocol.java
+++ b/src/org/traccar/BaseProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton.tananaev@gmail.com)
+ * Copyright 2015 - 2016 Anton Tananaev (anton.tananaev@gmail.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -52,7 +52,9 @@ public abstract class BaseProtocol implements Protocol {
@Override
public void sendCommand(ActiveDevice activeDevice, Command command) {
- if (command.getType().equals(Command.TYPE_CUSTOM)) {
+ if (supportedCommands.contains(command.getType())) {
+ activeDevice.write(command);
+ } else if (command.getType().equals(Command.TYPE_CUSTOM)) {
String data = (String) command.getAttributes().get(Command.KEY_DATA);
if (activeDevice.getChannel().getPipeline().get(StringEncoder.class) != null) {
activeDevice.write(data);
@@ -60,11 +62,7 @@ public abstract class BaseProtocol implements Protocol {
activeDevice.write(ChannelBuffers.wrappedBuffer(DatatypeConverter.parseHexBinary(data)));
}
} else {
- if (!supportedCommands.contains(command.getType())) {
- throw new RuntimeException("Command "
- + command.getType() + " is not supported in protocol " + getName());
- }
- activeDevice.write(command);
+ throw new RuntimeException("Command " + command.getType() + " is not supported in protocol " + getName());
}
}