@Test public void setClusters() throws Exception { System.out.println("--- " + Thread.currentThread().getStackTrace()[1].getMethodName()); ArgumentCaptor<EzspPolicyId> policyId = ArgumentCaptor.forClass(EzspPolicyId.class); ArgumentCaptor<EzspDecisionId> decisionId = ArgumentCaptor.forClass(EzspDecisionId.class); final EmberNcp ncp = Mockito.mock(EmberNcp.class); Mockito.when(ncp.setPolicy(policyId.capture(), decisionId.capture())).thenReturn(EzspStatus.EZSP_SUCCESS); ZigBeeDongleEzsp dongle = new ZigBeeDongleEzsp(null) { @Override public EmberNcp getEmberNcp() { return ncp; } }; TransportConfig configuration = new TransportConfig(); Collection<Integer> clusters = new ArrayList<>(); clusters.add(1); clusters.add(2); clusters.add(4); configuration = new TransportConfig(); configuration.addOption(TransportConfigOption.SUPPORTED_INPUT_CLUSTERS, clusters); configuration.addOption(TransportConfigOption.SUPPORTED_OUTPUT_CLUSTERS, clusters); dongle.updateTransportConfig(configuration); assertEquals(ZigBeeStatus.SUCCESS, configuration.getResult(TransportConfigOption.SUPPORTED_INPUT_CLUSTERS)); assertEquals(ZigBeeStatus.SUCCESS, configuration.getResult(TransportConfigOption.SUPPORTED_OUTPUT_CLUSTERS)); clusters.add(10); clusters.add(20); TestUtilities.setField(ZigBeeDongleEzsp.class, dongle, "initialised", true); configuration = new TransportConfig(); configuration.addOption(TransportConfigOption.SUPPORTED_INPUT_CLUSTERS, clusters); configuration.addOption(TransportConfigOption.SUPPORTED_OUTPUT_CLUSTERS, clusters); dongle.updateTransportConfig(configuration); assertEquals(ZigBeeStatus.INVALID_STATE, configuration.getResult(TransportConfigOption.SUPPORTED_INPUT_CLUSTERS)); assertEquals(ZigBeeStatus.INVALID_STATE, configuration.getResult(TransportConfigOption.SUPPORTED_OUTPUT_CLUSTERS)); }
@Override public void updateTransportConfig(TransportConfig configuration) { for (TransportConfigOption option : configuration.getOptions()) { try { switch (option) { case CONCENTRATOR_CONFIG: configuration.setResult(option, setConcentrator((ConcentratorConfig) configuration.getValue(option))); break; case INSTALL_KEY: EmberNcp ncp = getEmberNcp(); ZigBeeKey nodeKey = (ZigBeeKey) configuration.getValue(option); if (!nodeKey.hasAddress()) { logger.debug("Attempt to set INSTALL_KEY without setting address"); configuration.setResult(option, ZigBeeStatus.FAILURE); break; } EmberStatus result = ncp.addTransientLinkKey(nodeKey.getAddress(), nodeKey); configuration.setResult(option, result == EmberStatus.EMBER_SUCCESS ? ZigBeeStatus.SUCCESS : ZigBeeStatus.FAILURE); break; case RADIO_TX_POWER: configuration.setResult(option, setEmberTxPower((int) configuration.getValue(option))); break; case DEVICE_TYPE: deviceType = (DeviceType) configuration.getValue(option); configuration.setResult(option, ZigBeeStatus.SUCCESS); break; case TRUST_CENTRE_LINK_KEY: setTcLinkKey((ZigBeeKey) configuration.getValue(option)); configuration.setResult(option, ZigBeeStatus.SUCCESS); break; case TRUST_CENTRE_JOIN_MODE: configuration.setResult(option, setTcJoinMode((TrustCentreJoinMode) configuration.getValue(option))); break; case SUPPORTED_INPUT_CLUSTERS: configuration.setResult(option, setSupportedInputClusters((Collection<Integer>) configuration.getValue(option))); break; case SUPPORTED_OUTPUT_CLUSTERS: configuration.setResult(option, setSupportedOutputClusters((Collection<Integer>) configuration.getValue(option))); break; default: configuration.setResult(option, ZigBeeStatus.UNSUPPORTED); logger.debug("Unsupported configuration option \"{}\" in EZSP dongle", option); break; } } catch (ClassCastException e) { configuration.setResult(option, ZigBeeStatus.INVALID_ARGUMENTS); } } }
ZigBeeDongleEzsp implements ZigBeeTransportTransmit, ZigBeeTransportFirmwareUpdate, EzspFrameHandler { @Override public void updateTransportConfig(TransportConfig configuration) { for (TransportConfigOption option : configuration.getOptions()) { try { switch (option) { case CONCENTRATOR_CONFIG: configuration.setResult(option, setConcentrator((ConcentratorConfig) configuration.getValue(option))); break; case INSTALL_KEY: EmberNcp ncp = getEmberNcp(); ZigBeeKey nodeKey = (ZigBeeKey) configuration.getValue(option); if (!nodeKey.hasAddress()) { logger.debug("Attempt to set INSTALL_KEY without setting address"); configuration.setResult(option, ZigBeeStatus.FAILURE); break; } EmberStatus result = ncp.addTransientLinkKey(nodeKey.getAddress(), nodeKey); configuration.setResult(option, result == EmberStatus.EMBER_SUCCESS ? ZigBeeStatus.SUCCESS : ZigBeeStatus.FAILURE); break; case RADIO_TX_POWER: configuration.setResult(option, setEmberTxPower((int) configuration.getValue(option))); break; case DEVICE_TYPE: deviceType = (DeviceType) configuration.getValue(option); configuration.setResult(option, ZigBeeStatus.SUCCESS); break; case TRUST_CENTRE_LINK_KEY: setTcLinkKey((ZigBeeKey) configuration.getValue(option)); configuration.setResult(option, ZigBeeStatus.SUCCESS); break; case TRUST_CENTRE_JOIN_MODE: configuration.setResult(option, setTcJoinMode((TrustCentreJoinMode) configuration.getValue(option))); break; case SUPPORTED_INPUT_CLUSTERS: configuration.setResult(option, setSupportedInputClusters((Collection<Integer>) configuration.getValue(option))); break; case SUPPORTED_OUTPUT_CLUSTERS: configuration.setResult(option, setSupportedOutputClusters((Collection<Integer>) configuration.getValue(option))); break; default: configuration.setResult(option, ZigBeeStatus.UNSUPPORTED); logger.debug("Unsupported configuration option \"{}\" in EZSP dongle", option); break; } } catch (ClassCastException e) { configuration.setResult(option, ZigBeeStatus.INVALID_ARGUMENTS); } } } }
ZigBeeDongleEzsp implements ZigBeeTransportTransmit, ZigBeeTransportFirmwareUpdate, EzspFrameHandler { @Override public void updateTransportConfig(TransportConfig configuration) { for (TransportConfigOption option : configuration.getOptions()) { try { switch (option) { case CONCENTRATOR_CONFIG: configuration.setResult(option, setConcentrator((ConcentratorConfig) configuration.getValue(option))); break; case INSTALL_KEY: EmberNcp ncp = getEmberNcp(); ZigBeeKey nodeKey = (ZigBeeKey) configuration.getValue(option); if (!nodeKey.hasAddress()) { logger.debug("Attempt to set INSTALL_KEY without setting address"); configuration.setResult(option, ZigBeeStatus.FAILURE); break; } EmberStatus result = ncp.addTransientLinkKey(nodeKey.getAddress(), nodeKey); configuration.setResult(option, result == EmberStatus.EMBER_SUCCESS ? ZigBeeStatus.SUCCESS : ZigBeeStatus.FAILURE); break; case RADIO_TX_POWER: configuration.setResult(option, setEmberTxPower((int) configuration.getValue(option))); break; case DEVICE_TYPE: deviceType = (DeviceType) configuration.getValue(option); configuration.setResult(option, ZigBeeStatus.SUCCESS); break; case TRUST_CENTRE_LINK_KEY: setTcLinkKey((ZigBeeKey) configuration.getValue(option)); configuration.setResult(option, ZigBeeStatus.SUCCESS); break; case TRUST_CENTRE_JOIN_MODE: configuration.setResult(option, setTcJoinMode((TrustCentreJoinMode) configuration.getValue(option))); break; case SUPPORTED_INPUT_CLUSTERS: configuration.setResult(option, setSupportedInputClusters((Collection<Integer>) configuration.getValue(option))); break; case SUPPORTED_OUTPUT_CLUSTERS: configuration.setResult(option, setSupportedOutputClusters((Collection<Integer>) configuration.getValue(option))); break; default: configuration.setResult(option, ZigBeeStatus.UNSUPPORTED); logger.debug("Unsupported configuration option \"{}\" in EZSP dongle", option); break; } } catch (ClassCastException e) { configuration.setResult(option, ZigBeeStatus.INVALID_ARGUMENTS); } } } ZigBeeDongleEzsp(final ZigBeePort serialPort);  ZigBeeDongleEzsp(final ZigBeePort serialPort, final EmberSerialProtocol protocol); }
ZigBeeDongleEzsp implements ZigBeeTransportTransmit, ZigBeeTransportFirmwareUpdate, EzspFrameHandler { @Override public void updateTransportConfig(TransportConfig configuration) { for (TransportConfigOption option : configuration.getOptions()) { try { switch (option) { case CONCENTRATOR_CONFIG: configuration.setResult(option, setConcentrator((ConcentratorConfig) configuration.getValue(option))); break; case INSTALL_KEY: EmberNcp ncp = getEmberNcp(); ZigBeeKey nodeKey = (ZigBeeKey) configuration.getValue(option); if (!nodeKey.hasAddress()) { logger.debug("Attempt to set INSTALL_KEY without setting address"); configuration.setResult(option, ZigBeeStatus.FAILURE); break; } EmberStatus result = ncp.addTransientLinkKey(nodeKey.getAddress(), nodeKey); configuration.setResult(option, result == EmberStatus.EMBER_SUCCESS ? ZigBeeStatus.SUCCESS : ZigBeeStatus.FAILURE); break; case RADIO_TX_POWER: configuration.setResult(option, setEmberTxPower((int) configuration.getValue(option))); break; case DEVICE_TYPE: deviceType = (DeviceType) configuration.getValue(option); configuration.setResult(option, ZigBeeStatus.SUCCESS); break; case TRUST_CENTRE_LINK_KEY: setTcLinkKey((ZigBeeKey) configuration.getValue(option)); configuration.setResult(option, ZigBeeStatus.SUCCESS); break; case TRUST_CENTRE_JOIN_MODE: configuration.setResult(option, setTcJoinMode((TrustCentreJoinMode) configuration.getValue(option))); break; case SUPPORTED_INPUT_CLUSTERS: configuration.setResult(option, setSupportedInputClusters((Collection<Integer>) configuration.getValue(option))); break; case SUPPORTED_OUTPUT_CLUSTERS: configuration.setResult(option, setSupportedOutputClusters((Collection<Integer>) configuration.getValue(option))); break; default: configuration.setResult(option, ZigBeeStatus.UNSUPPORTED); logger.debug("Unsupported configuration option \"{}\" in EZSP dongle", option); break; } } catch (ClassCastException e) { configuration.setResult(option, ZigBeeStatus.INVALID_ARGUMENTS); } } } ZigBeeDongleEzsp(final ZigBeePort serialPort);  ZigBeeDongleEzsp(final ZigBeePort serialPort, final EmberSerialProtocol protocol); void setEmberNcpResetProvider(EmberNcpResetProvider resetProvider); Integer updateDefaultConfiguration(EzspConfigId configId, Integer value); EzspDecisionId updateDefaultPolicy(EzspPolicyId policyId, EzspDecisionId decisionId); EmberMfglib getEmberMfglib(EmberMfglibListener mfglibListener); @Override void setDefaultProfileId(int defaultProfileId); @Override void setDefaultDeviceId(int defaultDeviceId); @Override ZigBeeStatus initialize(); @Override ZigBeeStatus startup(boolean reinitialize); void setPollRate(int pollRate); @Override void shutdown(); void passLoopbackMessages(boolean passLoopbackMessages); EmberNcp getEmberNcp(); EmberCbkeProvider getEmberCbkeProvider(); @Override IeeeAddress getIeeeAddress(); @Override Integer getNwkAddress(); @Override void sendCommand(final int msgTag, final ZigBeeApsFrame apsFrame); @Override void setZigBeeTransportReceive(ZigBeeTransportReceive zigbeeTransportReceive); @Override void setNodeDescriptor(IeeeAddress ieeeAddress, NodeDescriptor nodeDescriptor); @Override void handlePacket(EzspFrame response); @Override void handleLinkStateChange(final boolean linkState); @Override ZigBeeChannel getZigBeeChannel(); @Override ZigBeeStatus setZigBeeChannel(ZigBeeChannel channel); @Override int getZigBeePanId(); @Override ZigBeeStatus setZigBeePanId(int panId); @Override ExtendedPanId getZigBeeExtendedPanId(); @Override ZigBeeStatus setZigBeeExtendedPanId(ExtendedPanId extendedPanId); @Override ZigBeeStatus setZigBeeNetworkKey(final ZigBeeKey key); @Override ZigBeeKey getZigBeeNetworkKey(); @Override ZigBeeStatus setTcLinkKey(ZigBeeKey key); @Override ZigBeeKey getTcLinkKey(); @Override void updateTransportConfig(TransportConfig configuration); @Override String getVersionString(); @Override boolean updateFirmware(final InputStream firmware, final ZigBeeTransportFirmwareCallback callback); void bootloadComplete(); @Override String getFirmwareVersion(); @Override boolean cancelUpdateFirmware(); Map<String, Long> getCounters(); }
ZigBeeDongleEzsp implements ZigBeeTransportTransmit, ZigBeeTransportFirmwareUpdate, EzspFrameHandler { @Override public void updateTransportConfig(TransportConfig configuration) { for (TransportConfigOption option : configuration.getOptions()) { try { switch (option) { case CONCENTRATOR_CONFIG: configuration.setResult(option, setConcentrator((ConcentratorConfig) configuration.getValue(option))); break; case INSTALL_KEY: EmberNcp ncp = getEmberNcp(); ZigBeeKey nodeKey = (ZigBeeKey) configuration.getValue(option); if (!nodeKey.hasAddress()) { logger.debug("Attempt to set INSTALL_KEY without setting address"); configuration.setResult(option, ZigBeeStatus.FAILURE); break; } EmberStatus result = ncp.addTransientLinkKey(nodeKey.getAddress(), nodeKey); configuration.setResult(option, result == EmberStatus.EMBER_SUCCESS ? ZigBeeStatus.SUCCESS : ZigBeeStatus.FAILURE); break; case RADIO_TX_POWER: configuration.setResult(option, setEmberTxPower((int) configuration.getValue(option))); break; case DEVICE_TYPE: deviceType = (DeviceType) configuration.getValue(option); configuration.setResult(option, ZigBeeStatus.SUCCESS); break; case TRUST_CENTRE_LINK_KEY: setTcLinkKey((ZigBeeKey) configuration.getValue(option)); configuration.setResult(option, ZigBeeStatus.SUCCESS); break; case TRUST_CENTRE_JOIN_MODE: configuration.setResult(option, setTcJoinMode((TrustCentreJoinMode) configuration.getValue(option))); break; case SUPPORTED_INPUT_CLUSTERS: configuration.setResult(option, setSupportedInputClusters((Collection<Integer>) configuration.getValue(option))); break; case SUPPORTED_OUTPUT_CLUSTERS: configuration.setResult(option, setSupportedOutputClusters((Collection<Integer>) configuration.getValue(option))); break; default: configuration.setResult(option, ZigBeeStatus.UNSUPPORTED); logger.debug("Unsupported configuration option \"{}\" in EZSP dongle", option); break; } } catch (ClassCastException e) { configuration.setResult(option, ZigBeeStatus.INVALID_ARGUMENTS); } } } ZigBeeDongleEzsp(final ZigBeePort serialPort);  ZigBeeDongleEzsp(final ZigBeePort serialPort, final EmberSerialProtocol protocol); void setEmberNcpResetProvider(EmberNcpResetProvider resetProvider); Integer updateDefaultConfiguration(EzspConfigId configId, Integer value); EzspDecisionId updateDefaultPolicy(EzspPolicyId policyId, EzspDecisionId decisionId); EmberMfglib getEmberMfglib(EmberMfglibListener mfglibListener); @Override void setDefaultProfileId(int defaultProfileId); @Override void setDefaultDeviceId(int defaultDeviceId); @Override ZigBeeStatus initialize(); @Override ZigBeeStatus startup(boolean reinitialize); void setPollRate(int pollRate); @Override void shutdown(); void passLoopbackMessages(boolean passLoopbackMessages); EmberNcp getEmberNcp(); EmberCbkeProvider getEmberCbkeProvider(); @Override IeeeAddress getIeeeAddress(); @Override Integer getNwkAddress(); @Override void sendCommand(final int msgTag, final ZigBeeApsFrame apsFrame); @Override void setZigBeeTransportReceive(ZigBeeTransportReceive zigbeeTransportReceive); @Override void setNodeDescriptor(IeeeAddress ieeeAddress, NodeDescriptor nodeDescriptor); @Override void handlePacket(EzspFrame response); @Override void handleLinkStateChange(final boolean linkState); @Override ZigBeeChannel getZigBeeChannel(); @Override ZigBeeStatus setZigBeeChannel(ZigBeeChannel channel); @Override int getZigBeePanId(); @Override ZigBeeStatus setZigBeePanId(int panId); @Override ExtendedPanId getZigBeeExtendedPanId(); @Override ZigBeeStatus setZigBeeExtendedPanId(ExtendedPanId extendedPanId); @Override ZigBeeStatus setZigBeeNetworkKey(final ZigBeeKey key); @Override ZigBeeKey getZigBeeNetworkKey(); @Override ZigBeeStatus setTcLinkKey(ZigBeeKey key); @Override ZigBeeKey getTcLinkKey(); @Override void updateTransportConfig(TransportConfig configuration); @Override String getVersionString(); @Override boolean updateFirmware(final InputStream firmware, final ZigBeeTransportFirmwareCallback callback); void bootloadComplete(); @Override String getFirmwareVersion(); @Override boolean cancelUpdateFirmware(); Map<String, Long> getCounters();  }