diff --git a/zigbee-common/src/main/java/org/bubblecloud/zigbee/v3/ZigBeeApi.java b/zigbee-common/src/main/java/org/bubblecloud/zigbee/v3/ZigBeeApi.java index 2caa2d23f..97c0b34e8 100644 --- a/zigbee-common/src/main/java/org/bubblecloud/zigbee/v3/ZigBeeApi.java +++ b/zigbee-common/src/main/java/org/bubblecloud/zigbee/v3/ZigBeeApi.java @@ -39,20 +39,14 @@ public class ZigBeeApi { * The {@link Logger}. */ private final static Logger LOGGER = LoggerFactory.getLogger(ZigBeeApi.class); - /** - * The network. - */ - private ZigBeeNetwork network; - /** - * The network state. - */ - private ZigBeeNetworkState networkState; /** * The command listener creation times. */ private Set commandExecutions = new HashSet(); + private ZigBeeNetworkManager networkManager; + /** * Default constructor inheritance. */ @@ -63,40 +57,16 @@ public ZigBeeApi() { * Constructor for setting the ZCL API. * @param network the ZCL API */ - public ZigBeeApi(final ZigBeeNetwork network) { - this.network = network; - } - - /** - * Sets network. - * @param network the network - */ - public void setNetwork(final ZigBeeNetwork network) { - this.network = network; + public ZigBeeApi(final ZigBeeNetworkManager networkManager) { + this.networkManager = networkManager; } /** * Gets the ZigBee network. * @return the ZigBee network */ - public ZigBeeNetwork getNetwork() { - return network; - } - - /** - * Sets network state. - * @param networkState the network state - */ - public void setNetworkState(final ZigBeeNetworkState networkState) { - this.networkState = networkState; - } - - /** - * Gets the ZigBee network state. - * @return the ZigBee network state - */ - public ZigBeeNetworkState getNetworkState() { - return networkState; + public ZigBeeNetworkManager getNetwork() { + return networkManager; } /** @@ -106,9 +76,7 @@ public ZigBeeNetworkState getNetworkState() { * @param label the label */ public void setDeviceLabel(final int networkAddress, final int endPointId, final String label) { - final ZigBeeDevice device = networkState.getDevice(networkAddress, endPointId); - device.setLabel(label); - networkState.updateDevice(device); + networkManager.setDeviceLabel(networkAddress, endPointId, label); } /** @@ -116,17 +84,7 @@ public void setDeviceLabel(final int networkAddress, final int endPointId, final * @param networkAddress the network address */ public void removeDevice(final int networkAddress) { - final List devices = networkState.getDevices(); - final List devicesToRemove = new ArrayList(); - for (final ZigBeeDevice device : devices) { - if (device.getNetworkAddress() == networkAddress) { - devicesToRemove.add(device); - } - } - - for (final ZigBeeDevice device : devicesToRemove) { - networkState.removeDevice(device.getNetworkAddress(), device.getEndpoint()); - } + networkManager.removeDevice(networkAddress); } @@ -135,7 +93,7 @@ public void removeDevice(final int networkAddress) { * @return list of ZigBee devices */ public List getDevices() { - return getNetworkState().getDevices(); + return networkManager.getDevices(); } /** @@ -144,13 +102,7 @@ public List getDevices() { * @param label the label */ public void addMembership(final int groupId, final String label) { - if (networkState.getGroup(groupId) == null) { - networkState.addGroup(new ZigBeeGroup(groupId, label)); - } else { - final ZigBeeGroup group = networkState.getGroup(groupId); - group.setLabel(label); - networkState.updateGroup(group); - } + networkManager.addMembership(groupId, label); } /** @@ -158,7 +110,7 @@ public void addMembership(final int groupId, final String label) { * @param groupId the group ID */ public void removeMembership(final int groupId) { - networkState.removeGroup(groupId); + networkManager.removeMembership(groupId); } /** @@ -167,7 +119,7 @@ public void removeMembership(final int groupId) { * @return the ZigBee group or null if no exists with given group ID. */ public ZigBeeGroup getGroup(final int groupId) { - return networkState.getGroup(groupId); + return networkManager.getGroup(groupId); } /** @@ -175,7 +127,7 @@ public ZigBeeGroup getGroup(final int groupId) { * @return list of groups. */ public List getGroups() { - return networkState.getGroups(); + return networkManager.getGroups(); } /** @@ -500,7 +452,7 @@ public void permitJoin(final boolean enable) { command.setTrustCenterSignificance(1); try { - network.sendCommand(command); + networkManager.sendCommand(command); } catch (final ZigBeeException e) { throw new ZigBeeApiException("Error sending permit join command.", e); } @@ -639,7 +591,7 @@ public void commandReceived(Command receivedCommand) { commandExecution.setCommandListener(commandListener); addCommandExecution(commandExecution); try { - int transactionId = network.sendCommand(command); + int transactionId = networkManager.sendCommand(command); if (command instanceof ZclCommand) { ((ZclCommand) command).setTransactionId((byte) transactionId); } @@ -661,7 +613,7 @@ private Future broadcast(final Command command) { final CommandResultFuture future = new CommandResultFuture(this); try { - network.sendCommand(command); + networkManager.sendCommand(command); future.set(new CommandResult(new BroadcastResponse())); } catch (final ZigBeeException e) { future.set(new CommandResult(e.toString())); @@ -690,7 +642,7 @@ private void addCommandExecution(final CommandExecution commandExecution) { removeCommandExecution(expiredCommandExecution); } commandExecutions.add(commandExecution); - network.addCommandListener(commandExecution.getCommandListener()); + networkManager.addCommandListener(commandExecution.getCommandListener()); } } @@ -700,10 +652,15 @@ private void addCommandExecution(final CommandExecution commandExecution) { */ protected void removeCommandExecution(CommandExecution expiredCommandExecution) { commandExecutions.remove(expiredCommandExecution); - network.removeCommandListener(expiredCommandExecution.getCommandListener()); + networkManager.removeCommandListener(expiredCommandExecution.getCommandListener()); synchronized (expiredCommandExecution.getFuture()) { expiredCommandExecution.getFuture().notify(); } } + public ZigBeeNetworkState getNetworkState() { + // TODO Auto-generated method stub + return networkManager.getNetworkState(); + } + } diff --git a/zigbee-common/src/main/java/org/bubblecloud/zigbee/v3/ZigBeeApiDongleImpl.java b/zigbee-common/src/main/java/org/bubblecloud/zigbee/v3/ZigBeeApiDongleImpl.java deleted file mode 100644 index ebc7813d0..000000000 --- a/zigbee-common/src/main/java/org/bubblecloud/zigbee/v3/ZigBeeApiDongleImpl.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.bubblecloud.zigbee.v3; - -/** - * Local implementation of ZigBee API connects - * directly to local ZigBee dongle. - */ -public class ZigBeeApiDongleImpl extends ZigBeeApi { - /** - * The dongle implementation. - */ - private final ZigBeeDongle dongle; - /** - * The ZigBee network state. - */ - private final ZigBeeNetworkStateImpl networkState; - /** - * The ZigBee network networkDiscoverer. - */ - private final ZigBeeNetworkDiscoverer networkDiscoverer; - - /** - * Constructor which configures serial port and ZigBee network. - * @param dongle the dongle - * @param resetNetwork whether network is to be reset - */ - public ZigBeeApiDongleImpl(final ZigBeeDongle dongle, final boolean resetNetwork) { - this.dongle = dongle; - this.networkState = new ZigBeeNetworkStateImpl(resetNetwork); - this.networkDiscoverer = new ZigBeeNetworkDiscoverer(networkState, dongle); - - setNetwork(dongle); - setNetworkState(networkState); - } - - /** - * Starts up ZigBee API components. - * @return TRUE if startup was successful. - */ - public boolean startup() { - networkState.startup(); - if (dongle.startup()) { - networkDiscoverer.startup(); - return true; - } else { - return false; - } - } - - /** - * Shuts down ZigBee API components. - */ - public void shutdown() { - networkDiscoverer.shutdown(); - dongle.shutdown(); - networkState.shutdown(); - } - -} diff --git a/zigbee-common/src/main/java/org/bubblecloud/zigbee/v3/ZigBeeDongle.java b/zigbee-common/src/main/java/org/bubblecloud/zigbee/v3/ZigBeeDongle.java index dbb176e3b..02e626c8a 100644 --- a/zigbee-common/src/main/java/org/bubblecloud/zigbee/v3/ZigBeeDongle.java +++ b/zigbee-common/src/main/java/org/bubblecloud/zigbee/v3/ZigBeeDongle.java @@ -3,7 +3,7 @@ /** * ZigBee dongle interface implemented by different dongle hardware drivers. */ -public interface ZigBeeDongle extends ZigBeeNetwork { +public interface ZigBeeDongle { /** * Starts up dongle. * @@ -15,4 +15,16 @@ public interface ZigBeeDongle extends ZigBeeNetwork { * Shuts down dongle. */ void shutdown(); + + /** + * Sends ZigBee library command without waiting for response. + * @param command the command + * @return transaction ID + * @throws ZigBeeException if exception occurs in sending + */ + int sendCommand(final Command command) throws ZigBeeException; + + + void setZigBeeNetwork(ZigBeeNetwork zigbeeNetwork); + } diff --git a/zigbee-common/src/main/java/org/bubblecloud/zigbee/v3/ZigBeeNetwork.java b/zigbee-common/src/main/java/org/bubblecloud/zigbee/v3/ZigBeeNetwork.java index 6da20543f..a519ebcc0 100644 --- a/zigbee-common/src/main/java/org/bubblecloud/zigbee/v3/ZigBeeNetwork.java +++ b/zigbee-common/src/main/java/org/bubblecloud/zigbee/v3/ZigBeeNetwork.java @@ -5,20 +5,25 @@ */ public interface ZigBeeNetwork { /** - * Sends ZigBee Cluster Library command without waiting for response. + * Sends ZigBee library command without waiting for response. * @param command the command * @return transaction ID * @throws ZigBeeException if exception occurs in sending */ int sendCommand(final Command command) throws ZigBeeException; /** - * Adds ZigBee Cluster Library command listener. + * Adds ZigBee library command listener. * @param commandListener the command listener */ void addCommandListener(final CommandListener commandListener); /** - * Removes ZigBee Cluster Library command listener. + * Removes ZigBee library command listener. * @param commandListener the command listener */ void removeCommandListener(final CommandListener commandListener); + + void receiveCommand(final Command command); + + void setZigBeeNetwork(ZigBeeNetwork zigbeeNetwork); + } diff --git a/zigbee-common/src/main/java/org/bubblecloud/zigbee/v3/ZigBeeNetworkDiscoverer.java b/zigbee-common/src/main/java/org/bubblecloud/zigbee/v3/ZigBeeNetworkDiscoverer.java index bea9e3cc1..a0e13d36a 100644 --- a/zigbee-common/src/main/java/org/bubblecloud/zigbee/v3/ZigBeeNetworkDiscoverer.java +++ b/zigbee-common/src/main/java/org/bubblecloud/zigbee/v3/ZigBeeNetworkDiscoverer.java @@ -27,7 +27,7 @@ public class ZigBeeNetworkDiscoverer implements CommandListener { /** * The ZigBee command interface. */ - private ZigBeeNetwork commandInterface; + private ZigBeeNetworkManager commandInterface; /** * The received IEEE addresses. */ @@ -62,12 +62,12 @@ public class ZigBeeNetworkDiscoverer implements CommandListener { /** * Discovers ZigBee network state. * @param networkState the network state - * @param commandInterface the command interface + * @param dongle the command interface */ public ZigBeeNetworkDiscoverer(final ZigBeeNetworkState networkState, - final ZigBeeNetwork commandInterface) { + final ZigBeeNetworkManager networkManager) { this.networkState = networkState; - this.commandInterface = commandInterface; + this.commandInterface = networkManager; } /** diff --git a/zigbee-common/src/main/java/org/bubblecloud/zigbee/v3/ZigBeeNetworkManager.java b/zigbee-common/src/main/java/org/bubblecloud/zigbee/v3/ZigBeeNetworkManager.java new file mode 100644 index 000000000..637cb0bc8 --- /dev/null +++ b/zigbee-common/src/main/java/org/bubblecloud/zigbee/v3/ZigBeeNetworkManager.java @@ -0,0 +1,186 @@ +package org.bubblecloud.zigbee.v3; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * Implements functions for managing the ZigBee interface + * + * @author Chris Jackson + */ +public class ZigBeeNetworkManager implements ZigBeeNetwork { + /** + * The dongle implementation. + */ + private final ZigBeeDongle dongle; + /** + * The ZigBee network networkDiscoverer. + */ + private final ZigBeeNetworkDiscoverer networkDiscoverer; + + /** + * The network state. + */ + private ZigBeeNetworkStateImpl networkState; + + ZigBeeNetwork zigbeeNetwork; + + /** + * The command listeners. + */ + private List commandListeners = new ArrayList(); + + /** + * Constructor which configures serial port and ZigBee network. + * @param dongle the dongle + * @param resetNetwork whether network is to be reset + */ + public ZigBeeNetworkManager(final ZigBeeDongle dongle, final boolean resetNetwork) { + this.dongle = dongle; + this.networkState = new ZigBeeNetworkStateImpl(resetNetwork); + this.networkDiscoverer = new ZigBeeNetworkDiscoverer(networkState, this); + +// setNetwork(dongle); + + dongle.setZigBeeNetwork(this); +// setNetworkState(networkState); + } + + /** + * Starts up ZigBee API components. + * @return TRUE if startup was successful. + */ + public boolean startup() { + networkState.startup(); + if (dongle.startup()) { + networkDiscoverer.startup(); + return true; + } else { + return false; + } + } + + /** + * Shuts down ZigBee API components. + */ + public void shutdown() { + networkDiscoverer.shutdown(); + dongle.shutdown(); + networkState.shutdown(); + } + + @Override + public int sendCommand(Command command) throws ZigBeeException { + return dongle.sendCommand(command); + } + + @Override + public void addCommandListener(CommandListener commandListener) { + final List modifiedCommandListeners = new ArrayList(commandListeners); + modifiedCommandListeners.add(commandListener); + commandListeners = Collections.unmodifiableList(modifiedCommandListeners); + } + + @Override + public void removeCommandListener(CommandListener commandListener) { + final List modifiedCommandListeners = new ArrayList(commandListeners); + modifiedCommandListeners.remove(commandListener); + commandListeners = Collections.unmodifiableList(modifiedCommandListeners); + } + + @Override + public void receiveCommand(Command command) { + for (final CommandListener commandListener : commandListeners) { + commandListener.commandReceived(command); + } + } + + @Override + public void setZigBeeNetwork(ZigBeeNetwork zigbeeNetwork) { + this.zigbeeNetwork = zigbeeNetwork; + } + + /** + * Sets device label. + * @param networkAddress the network address + * @param endPointId the end point ID + * @param label the label + */ + public void setDeviceLabel(final int networkAddress, final int endPointId, final String label) { + final ZigBeeDevice device = networkState.getDevice(networkAddress, endPointId); + device.setLabel(label); + networkState.updateDevice(device); + } + + /** + * Removes device(s) by network address. + * @param networkAddress the network address + */ + public void removeDevice(final int networkAddress) { + final List devices = networkState.getDevices(); + final List devicesToRemove = new ArrayList(); + for (final ZigBeeDevice device : devices) { + if (device.getNetworkAddress() == networkAddress) { + devicesToRemove.add(device); + } + } + + for (final ZigBeeDevice device : devicesToRemove) { + networkState.removeDevice(device.getNetworkAddress(), device.getEndpoint()); + } + } + + + /** + * Gets ZigBee devices. + * @return list of ZigBee devices + */ + public List getDevices() { + return networkState.getDevices(); + } + + /** + * Sets group label. + * @param groupId the group ID + * @param label the label + */ + public void addMembership(final int groupId, final String label) { + if (networkState.getGroup(groupId) == null) { + networkState.addGroup(new ZigBeeGroup(groupId, label)); + } else { + final ZigBeeGroup group = networkState.getGroup(groupId); + group.setLabel(label); + networkState.updateGroup(group); + } + } + + /** + * Removes group label. + * @param groupId the group ID + */ + public void removeMembership(final int groupId) { + networkState.removeGroup(groupId); + } + + /** + * Gets group by network address. + * @param groupId the group ID + * @return the ZigBee group or null if no exists with given group ID. + */ + public ZigBeeGroup getGroup(final int groupId) { + return networkState.getGroup(groupId); + } + + /** + * Gets all groups. + * @return list of groups. + */ + public List getGroups() { + return networkState.getGroups(); + } + + public ZigBeeNetworkState getNetworkState() { + return networkState; + } +} diff --git a/zigbee-common/src/main/java/org/bubblecloud/zigbee/v3/ZigBeeNetworkState.java b/zigbee-common/src/main/java/org/bubblecloud/zigbee/v3/ZigBeeNetworkState.java index 00700d51b..68ddb075e 100644 --- a/zigbee-common/src/main/java/org/bubblecloud/zigbee/v3/ZigBeeNetworkState.java +++ b/zigbee-common/src/main/java/org/bubblecloud/zigbee/v3/ZigBeeNetworkState.java @@ -70,6 +70,7 @@ public interface ZigBeeNetworkState { /** * Adds network listener. + * The listener will be notified about device additions, removals and updates within the network. * @param networkListener the network listener */ void addNetworkListener(ZigBeeNetworkStateListener networkListener); diff --git a/zigbee-common/src/main/java/org/bubblecloud/zigbee/v3/ZigBeeNetworkStateListener.java b/zigbee-common/src/main/java/org/bubblecloud/zigbee/v3/ZigBeeNetworkStateListener.java index dde5f6284..8901329c4 100644 --- a/zigbee-common/src/main/java/org/bubblecloud/zigbee/v3/ZigBeeNetworkStateListener.java +++ b/zigbee-common/src/main/java/org/bubblecloud/zigbee/v3/ZigBeeNetworkStateListener.java @@ -2,6 +2,7 @@ /** * ZigBee network listener. + * Provides notifications on devices - eg devices added to the network, removed from the network, or updated. */ public interface ZigBeeNetworkStateListener { /** diff --git a/zigbee-dongle-cc2531/src/main/java/org/bubblecloud/zigbee/v3/ZigBeeDongleTiCc2531Impl.java b/zigbee-dongle-cc2531/src/main/java/org/bubblecloud/zigbee/v3/ZigBeeDongleTiCc2531Impl.java index 5a5ef24c8..263b1a4b5 100644 --- a/zigbee-dongle-cc2531/src/main/java/org/bubblecloud/zigbee/v3/ZigBeeDongleTiCc2531Impl.java +++ b/zigbee-dongle-cc2531/src/main/java/org/bubblecloud/zigbee/v3/ZigBeeDongleTiCc2531Impl.java @@ -13,7 +13,7 @@ /** * ZigBee Dongle TI CC2531 implementation. */ -public class ZigBeeDongleTiCc2531Impl implements ZigBeeDongle { +public class ZigBeeDongleTiCc2531Impl implements ZigBeeDongle, CommandListener { /** * The {@link Logger}. */ @@ -33,22 +33,30 @@ public class ZigBeeDongleTiCc2531Impl implements ZigBeeDongle { /** * Flag to reset the network on startup */ - private boolean resetNetwork = false; + private boolean resetNetwork = false; + + private ZigBeeNetwork zigbeeNetwork; /** * Constructor to configure the port interface. * - * @param serialPort the serial port - * @param pan the pan - * @param channel the channel - * @param networkKey the network key or null for default testing key - * @param resetNetwork the reset network flag + * @param serialPort + * the serial port + * @param pan + * the pan + * @param channel + * the channel + * @param networkKey + * the network key or null for default testing key + * @param resetNetwork + * the reset network flag */ public ZigBeeDongleTiCc2531Impl(final SerialPort serialPort, final int pan, final int channel, - final byte[] networkKey, final boolean resetNetwork) { - this.resetNetwork = resetNetwork; + final byte[] networkKey, final boolean resetNetwork) { + this.resetNetwork = resetNetwork; - networkManager = new ZigBeeNetworkManagerImpl(serialPort, NetworkMode.Coordinator, pan, channel, networkKey, 2500L); + networkManager = new ZigBeeNetworkManagerImpl(serialPort, NetworkMode.Coordinator, pan, + channel, networkKey, 2500L); zclCommandTransmitter = new ZclCommandTransmitter(networkManager); zdoCommandTransmitter = new ZdoCommandTransmitter(networkManager); } @@ -82,6 +90,9 @@ public boolean startup() { ApplicationFrameworkLayer.getAFLayer(networkManager).createDefaultSendingEndPoint(); + zclCommandTransmitter.addCommandListener(this); + zdoCommandTransmitter.addCommandListener(this); + return true; } @@ -92,24 +103,23 @@ public void shutdown() { @Override public int sendCommand(org.bubblecloud.zigbee.v3.Command command) throws ZigBeeException { - if (command instanceof ZclCommand) { - return zclCommandTransmitter.sendCommand(((ZclCommand)command).toCommandMessage()); - } else { + if (command instanceof ZclCommand) { + return zclCommandTransmitter.sendCommand(((ZclCommand) command).toCommandMessage()); + } else { zdoCommandTransmitter.sendCommand((ZdoCommand) command); return -1; } } @Override - public void addCommandListener(final CommandListener commandListener) { - this.zclCommandTransmitter.addCommandListener(commandListener); - this.zdoCommandTransmitter.addCommandListener(commandListener); + public void commandReceived(Command command) { + zigbeeNetwork.receiveCommand(command); } - + @Override - public void removeCommandListener(final CommandListener commandListener) { - this.zclCommandTransmitter.removeCommandListener(commandListener); - this.zdoCommandTransmitter.removeCommandListener(commandListener); + public + void setZigBeeNetwork(ZigBeeNetwork zigbeeNetwork) { + this.zigbeeNetwork = zigbeeNetwork; } } diff --git a/zigbee-gateway-server/src/main/java/org/bubblecloud/zigbee/v3/ZigBeeGateway.java b/zigbee-gateway-server/src/main/java/org/bubblecloud/zigbee/v3/ZigBeeGateway.java index edbb13167..e12b2d747 100644 --- a/zigbee-gateway-server/src/main/java/org/bubblecloud/zigbee/v3/ZigBeeGateway.java +++ b/zigbee-gateway-server/src/main/java/org/bubblecloud/zigbee/v3/ZigBeeGateway.java @@ -50,8 +50,10 @@ public final class ZigBeeGateway { /** * The ZigBee API. */ - private ZigBeeApiDongleImpl zigBeeApi; + private ZigBeeApi zigBeeApi; + private ZigBeeNetworkManager networkManager; + /** * Constructor which configures ZigBee API and constructs commands. * @@ -97,7 +99,8 @@ public ZigBeeGateway(final ZigBeeDongle dongle, final boolean resetNetwork) { commands.put("unlock", new DoorUnlockCommand()); commands.put("enroll", new EnrollCommand()); - zigBeeApi = new ZigBeeApiDongleImpl(dongle, resetNetwork); + networkManager = new ZigBeeNetworkManager(dongle, resetNetwork); + zigBeeApi = new ZigBeeApi(networkManager); } /** @@ -107,7 +110,7 @@ public void start() { mainThread = Thread.currentThread(); System.out.print("ZigBee API starting up..."); - if (!zigBeeApi.startup()) { + if (!networkManager.startup()) { print("ZigBee API starting up ... [FAIL]", System.out); return; } else { @@ -165,7 +168,7 @@ public void run() { processInputLine(inputLine, System.out); } - zigBeeApi.shutdown(); + networkManager.shutdown(); } /** @@ -199,7 +202,7 @@ public void processArgs(final String[] args, final PrintStream out) { } } - public ZigBeeApiDongleImpl getZigBeeApi() { + public ZigBeeApi getZigBeeApi() { return zigBeeApi; } @@ -210,7 +213,7 @@ public ZigBeeApiDongleImpl getZigBeeApi() { * @param args the arguments including the command * @param out the output stream */ - private void executeCommand(final ZigBeeApiDongleImpl zigbeeApi, final String command, final String[] args, final PrintStream out) { + private void executeCommand(final ZigBeeApi zigbeeApi, final String command, final String[] args, final PrintStream out) { final ConsoleCommand consoleCommand = commands.get(command); try { if (!consoleCommand.process(zigbeeApi, args, out)) { @@ -269,7 +272,7 @@ private String getDeviceSummary(final ZigBeeDevice device) { * @param destinationIdentifier the device identifier or group ID * @return the device */ - private ZigBeeDestination getDestination(final ZigBeeApiDongleImpl zigbeeApi, final String destinationIdentifier + private ZigBeeDestination getDestination(final ZigBeeApi zigbeeApi, final String destinationIdentifier ,final PrintStream out) { final ZigBeeDevice device = getDevice(zigbeeApi, destinationIdentifier); @@ -301,7 +304,7 @@ private ZigBeeDestination getDestination(final ZigBeeApiDongleImpl zigbeeApi, fi * @param deviceIdentifier the device identifier * @return the device */ - private ZigBeeDevice getDevice(ZigBeeApiDongleImpl zigbeeApi, final String deviceIdentifier) { + private ZigBeeDevice getDevice(ZigBeeApi zigbeeApi, final String deviceIdentifier) { for (final ZigBeeDevice zigBeeDevice : zigbeeApi.getNetworkState().getDevices()) { if (deviceIdentifier.equals(zigBeeDevice.getNetworkAddress() + "/" + zigBeeDevice.getEndpoint())) { return zigBeeDevice; @@ -336,7 +339,7 @@ private interface ConsoleCommand { * @param out the output PrintStream * @return true if command syntax was correct. */ - boolean process(final ZigBeeApiDongleImpl zigbeeApi, final String[] args, PrintStream out) throws Exception; + boolean process(final ZigBeeApi zigbeeApi, final String[] args, PrintStream out) throws Exception; } /** @@ -358,7 +361,7 @@ public String getSyntax() { /** * {@inheritDoc} */ - public boolean process(final ZigBeeApiDongleImpl zigbeeApi, final String[] args, PrintStream out) { + public boolean process(final ZigBeeApi zigbeeApi, final String[] args, PrintStream out) { shutdown = true; return true; } @@ -383,7 +386,7 @@ public String getSyntax() { /** * {@inheritDoc} */ - public boolean process(final ZigBeeApiDongleImpl zigbeeApi, final String[] args, PrintStream out) { + public boolean process(final ZigBeeApi zigbeeApi, final String[] args, PrintStream out) { if (args.length == 2) { if (commands.containsKey(args[1])) { @@ -428,7 +431,7 @@ public String getSyntax() { /** * {@inheritDoc} */ - public boolean process(final ZigBeeApiDongleImpl zigbeeApi, final String[] args, PrintStream out) { + public boolean process(final ZigBeeApi zigbeeApi, final String[] args, PrintStream out) { final List devices = zigbeeApi.getDevices(); for (final ZigBeeDevice device : devices) { print(getDeviceSummary(device), out); @@ -456,7 +459,7 @@ public String getSyntax() { /** * {@inheritDoc} */ - public boolean process(final ZigBeeApiDongleImpl zigbeeApi, final String[] args, PrintStream out) { + public boolean process(final ZigBeeApi zigbeeApi, final String[] args, PrintStream out) { final List groups = zigbeeApi.getGroups(); for (final ZigBeeGroup group : groups) { print(StringUtils.leftPad(Integer.toString(group.getGroupId()), 10) + " " + group.getLabel(), out); @@ -484,7 +487,7 @@ public String getSyntax() { /** * {@inheritDoc} */ - public boolean process(final ZigBeeApiDongleImpl zigbeeApi, final String[] args, PrintStream out) { + public boolean process(final ZigBeeApi zigbeeApi, final String[] args, PrintStream out) { if (args.length != 2) { return false; } @@ -557,7 +560,7 @@ public String getSyntax() { /** * {@inheritDoc} */ - public boolean process(final ZigBeeApiDongleImpl zigbeeApi, final String[] args, PrintStream out) throws Exception { + public boolean process(final ZigBeeApi zigbeeApi, final String[] args, PrintStream out) throws Exception { if (args.length != 4) { return false; } @@ -599,7 +602,7 @@ public String getSyntax() { /** * {@inheritDoc} */ - public boolean process(final ZigBeeApiDongleImpl zigbeeApi, final String[] args, PrintStream out) throws Exception { + public boolean process(final ZigBeeApi zigbeeApi, final String[] args, PrintStream out) throws Exception { if (args.length != 4) { return false; } @@ -641,7 +644,7 @@ public String getSyntax() { /** * {@inheritDoc} */ - public boolean process(final ZigBeeApiDongleImpl zigbeeApi, final String[] args, PrintStream out) throws Exception { + public boolean process(final ZigBeeApi zigbeeApi, final String[] args, PrintStream out) throws Exception { if (args.length != 2) { return false; } @@ -677,7 +680,7 @@ public String getSyntax() { /** * {@inheritDoc} */ - public boolean process(final ZigBeeApiDongleImpl zigbeeApi, final String[] args, PrintStream out) throws Exception { + public boolean process(final ZigBeeApi zigbeeApi, final String[] args, PrintStream out) throws Exception { if (args.length != 2) { return false; } @@ -712,7 +715,7 @@ public String getSyntax() { /** * {@inheritDoc} */ - public boolean process(final ZigBeeApiDongleImpl zigbeeApi, final String[] args, PrintStream out) throws Exception { + public boolean process(final ZigBeeApi zigbeeApi, final String[] args, PrintStream out) throws Exception { if (args.length != 5) { return false; } @@ -765,7 +768,7 @@ public String getSyntax() { /** * {@inheritDoc} */ - public boolean process(final ZigBeeApiDongleImpl zigbeeApi, final String[] args, PrintStream out) throws Exception { + public boolean process(final ZigBeeApi zigbeeApi, final String[] args, PrintStream out) throws Exception { if (args.length != 3) { return false; } @@ -801,7 +804,7 @@ public String getSyntax() { /** * {@inheritDoc} */ - public boolean process(final ZigBeeApiDongleImpl zigbeeApi, final String[] args, PrintStream out) throws Exception { + public boolean process(final ZigBeeApi zigbeeApi, final String[] args, PrintStream out) throws Exception { if (args.length != 3) { return false; } @@ -840,7 +843,7 @@ public String getSyntax() { /** * {@inheritDoc} */ - public boolean process(final ZigBeeApiDongleImpl zigbeeApi, final String[] args, PrintStream out) throws Exception { + public boolean process(final ZigBeeApi zigbeeApi, final String[] args, PrintStream out) throws Exception { if (args.length != 2) { return false; } @@ -874,7 +877,7 @@ public String getSyntax() { /** * {@inheritDoc} */ - public boolean process(final ZigBeeApiDongleImpl zigbeeApi, final String[] args, PrintStream out) throws Exception { + public boolean process(final ZigBeeApi zigbeeApi, final String[] args, PrintStream out) throws Exception { if (args.length != 2) { return false; } @@ -912,7 +915,7 @@ public String getSyntax() { /** * {@inheritDoc} */ - public boolean process(final ZigBeeApiDongleImpl zigbeeApi, final String[] args, PrintStream out) throws Exception { + public boolean process(final ZigBeeApi zigbeeApi, final String[] args, PrintStream out) throws Exception { if (args.length != 3) { return false; } @@ -949,7 +952,7 @@ public String getSyntax() { /** * {@inheritDoc} */ - public boolean process(final ZigBeeApiDongleImpl zigbeeApi, final String[] args, PrintStream out) throws Exception { + public boolean process(final ZigBeeApi zigbeeApi, final String[] args, PrintStream out) throws Exception { if (args.length != 3) { return false; } @@ -990,7 +993,7 @@ public String getSyntax() { /** * {@inheritDoc} */ - public boolean process(final ZigBeeApiDongleImpl zigbeeApi, final String[] args, PrintStream out) throws Exception { + public boolean process(final ZigBeeApi zigbeeApi, final String[] args, PrintStream out) throws Exception { if (args.length != 3) { return false; } @@ -1026,7 +1029,7 @@ public String getSyntax() { /** * {@inheritDoc} */ - public boolean process(final ZigBeeApiDongleImpl zigbeeApi, final String[] args, PrintStream out) throws Exception { + public boolean process(final ZigBeeApi zigbeeApi, final String[] args, PrintStream out) throws Exception { if (args.length != 3) { return false; } @@ -1062,7 +1065,7 @@ public String getSyntax() { /** * {@inheritDoc} */ - public boolean process(final ZigBeeApiDongleImpl zigbeeApi, final String[] args, PrintStream out) { + public boolean process(final ZigBeeApi zigbeeApi, final String[] args, PrintStream out) { if (args.length != 1) { return false; } @@ -1094,7 +1097,7 @@ public String getSyntax() { /** * {@inheritDoc} */ - public boolean process(final ZigBeeApiDongleImpl zigbeeApi, final String[] args, PrintStream out) { + public boolean process(final ZigBeeApi zigbeeApi, final String[] args, PrintStream out) { if (args.length != 1) { return false; } @@ -1126,7 +1129,7 @@ public String getSyntax() { /** * {@inheritDoc} */ - public boolean process(final ZigBeeApiDongleImpl zigbeeApi, final String[] args, PrintStream out) throws Exception { + public boolean process(final ZigBeeApi zigbeeApi, final String[] args, PrintStream out) throws Exception { if (args.length != 6 && args.length != 7) { return false; } @@ -1207,7 +1210,7 @@ public String getSyntax() { /** * {@inheritDoc} */ - public boolean process(final ZigBeeApiDongleImpl zigbeeApi, final String[] args, PrintStream out) throws Exception { + public boolean process(final ZigBeeApi zigbeeApi, final String[] args, PrintStream out) throws Exception { if (args.length != 4 && args.length != 5) { return false; } @@ -1272,7 +1275,7 @@ public String getSyntax() { /** * {@inheritDoc} */ - public boolean process(final ZigBeeApiDongleImpl zigbeeApi, final String[] args, PrintStream out) throws Exception { + public boolean process(final ZigBeeApi zigbeeApi, final String[] args, PrintStream out) throws Exception { if (args.length != 4) { return false; } @@ -1337,7 +1340,7 @@ public String getSyntax() { /** * {@inheritDoc} */ - public boolean process(final ZigBeeApiDongleImpl zigbeeApi, final String[] args, PrintStream out) throws Exception { + public boolean process(final ZigBeeApi zigbeeApi, final String[] args, PrintStream out) throws Exception { if (args.length != 5) { return false; } @@ -1404,7 +1407,7 @@ public String getSyntax() { /** * {@inheritDoc} */ - public boolean process(final ZigBeeApiDongleImpl zigbeeApi, final String[] args, PrintStream out) { + public boolean process(final ZigBeeApi zigbeeApi, final String[] args, PrintStream out) { // ZigBeeDiscoveryManager discoveryMan = zigbeeApi.getZigBeeDiscoveryManager(); // NetworkNeighbourLinks neighbors = discoveryMan.getLinkQualityInfo(); // final List nodes = zigbeeApi.getNodes(); @@ -1443,7 +1446,7 @@ public String getSyntax() { } @Override - public boolean process(ZigBeeApiDongleImpl zigbeeApi, String[] args, PrintStream out) throws Exception { + public boolean process(ZigBeeApi zigbeeApi, String[] args, PrintStream out) throws Exception { if (args.length != 5) { return false; } @@ -1507,7 +1510,7 @@ public String getSyntax() { } @Override - public boolean process(ZigBeeApiDongleImpl zigbeeApi, String[] args, PrintStream out) throws Exception { + public boolean process(ZigBeeApi zigbeeApi, String[] args, PrintStream out) throws Exception { if (args.length != 5) { return false; } @@ -1574,7 +1577,7 @@ public String getSyntax() { /** * {@inheritDoc} */ - public boolean process(final ZigBeeApiDongleImpl zigbeeApi, final String[] args, PrintStream out) throws Exception { + public boolean process(final ZigBeeApi zigbeeApi, final String[] args, PrintStream out) throws Exception { if (args.length != 2) { return false; } @@ -1619,7 +1622,7 @@ public String getSyntax() { /** * {@inheritDoc} */ - public boolean process(final ZigBeeApiDongleImpl zigbeeApi, final String[] args, PrintStream out) { + public boolean process(final ZigBeeApi zigbeeApi, final String[] args, PrintStream out) { if (args.length != 2) { return false; } @@ -1682,7 +1685,7 @@ public String getSyntax() { /** * {@inheritDoc} */ - public boolean process(final ZigBeeApiDongleImpl zigbeeApi, final String[] args, PrintStream out) + public boolean process(final ZigBeeApi zigbeeApi, final String[] args, PrintStream out) throws Exception { if (args.length != 4) { return false; @@ -1729,7 +1732,7 @@ public String getSyntax() { /** * {@inheritDoc} */ - public boolean process(final ZigBeeApiDongleImpl zigbeeApi, final String[] args, PrintStream out) + public boolean process(final ZigBeeApi zigbeeApi, final String[] args, PrintStream out) throws Exception { if (args.length != 3) { return false; @@ -1773,7 +1776,7 @@ public String getSyntax() { /** * {@inheritDoc} */ - public boolean process(final ZigBeeApiDongleImpl zigbeeApi, final String[] args, PrintStream out) + public boolean process(final ZigBeeApi zigbeeApi, final String[] args, PrintStream out) throws Exception { if (args.length != 3) { return false; @@ -1830,7 +1833,7 @@ public String getSyntax() { /** * {@inheritDoc} */ - public boolean process(final ZigBeeApiDongleImpl zigbeeApi, final String[] args, PrintStream out) + public boolean process(final ZigBeeApi zigbeeApi, final String[] args, PrintStream out) throws Exception { if (args.length != 2) { return false;