@Test public void dongleSetChannel() { CommandInterface commandInterface = getCommandInterface(); ZigBeeNetworkManager networkManager = new ZigBeeNetworkManager(commandInterface, null, 0); networkManager.setRetryConfiguration(1, 0); Method privateMethod; try { privateMethod = ZigBeeNetworkManager.class.getDeclaredMethod("dongleSetChannel", new Class[] { int[].class }); privateMethod.setAccessible(true); privateMethod.invoke(networkManager, new int[] { 0x00, 0x08, 0x00, 0x00 }); ZToolPacket packet = argumentPacket.getAllValues().get(0); assertTrue(Arrays.equals(new int[] { 254, 6, 38, 5, 132, 0x04, 0x00, 0x08, 0x00, 0x00, 173 }, packet.getPacket())); privateMethod.invoke(networkManager, new int[] { 0x01, 0x08, 0x00, 0x00 }); packet = argumentPacket.getAllValues().get(1); assertTrue(Arrays.equals(new int[] { 254, 6, 38, 5, 132, 0x04, 0x00, 0x08, 0x00, 0x00, 173 }, packet.getPacket())); privateMethod.invoke(networkManager, new int[] { 0x00, 0x00, 0x00, 0x00 }); packet = argumentPacket.getAllValues().get(2); assertTrue(Arrays.equals(new int[] { 254, 6, 38, 5, 132, 0x04, 0x00, 0x08, 0x00, 0x00, 173 }, packet.getPacket())); privateMethod.invoke(networkManager, new int[] { 0x00, 0xff, 0x00, 0x00 }); packet = argumentPacket.getAllValues().get(3); assertTrue(Arrays.equals(new int[] { 254, 6, 38, 5, 132, 0x04, 0x00, 0xf8, 0x00, 0x00, 0x5D }, packet.getPacket())); networkManager.setZigBeeChannel(12); packet = argumentPacket.getAllValues().get(4); assertTrue(Arrays.equals(new int[] { 254, 6, 38, 5, 132, 0x04, 0x00, 0x10, 0x00, 0x00, 0xB5 }, packet.getPacket())); } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { e.printStackTrace(); } }
private boolean dongleSetChannel(int[] channelMask) { channelMask[0] &= ZNP_CHANNEL_MASK0; channelMask[1] &= ZNP_CHANNEL_MASK1; channelMask[2] &= ZNP_CHANNEL_MASK2; channelMask[3] &= ZNP_CHANNEL_MASK3; if (channelMask[0] == 0 && channelMask[1] == 0 && channelMask[2] == 0 && channelMask[3] == 0) { channelMask[0] = ZNP_CHANNEL_DEFAULT0; channelMask[1] = ZNP_CHANNEL_DEFAULT1; channelMask[2] = ZNP_CHANNEL_DEFAULT2; channelMask[3] = ZNP_CHANNEL_DEFAULT3; } logger.trace("Setting the channel to {}{}{}{}", new Object[] { Integer.toHexString(channelMask[0]), Integer.toHexString(channelMask[1]), Integer.toHexString(channelMask[2]), Integer.toHexString(channelMask[3]) }); ZB_WRITE_CONFIGURATION_RSP response = (ZB_WRITE_CONFIGURATION_RSP) sendSynchronous( new ZB_WRITE_CONFIGURATION(ZB_WRITE_CONFIGURATION.CONFIG_ID.ZCD_NV_CHANLIST, channelMask)); return response != null && response.Status == 0; }
ZigBeeNetworkManager { private boolean dongleSetChannel(int[] channelMask) { channelMask[0] &= ZNP_CHANNEL_MASK0; channelMask[1] &= ZNP_CHANNEL_MASK1; channelMask[2] &= ZNP_CHANNEL_MASK2; channelMask[3] &= ZNP_CHANNEL_MASK3; if (channelMask[0] == 0 && channelMask[1] == 0 && channelMask[2] == 0 && channelMask[3] == 0) { channelMask[0] = ZNP_CHANNEL_DEFAULT0; channelMask[1] = ZNP_CHANNEL_DEFAULT1; channelMask[2] = ZNP_CHANNEL_DEFAULT2; channelMask[3] = ZNP_CHANNEL_DEFAULT3; } logger.trace("Setting the channel to {}{}{}{}", new Object[] { Integer.toHexString(channelMask[0]), Integer.toHexString(channelMask[1]), Integer.toHexString(channelMask[2]), Integer.toHexString(channelMask[3]) }); ZB_WRITE_CONFIGURATION_RSP response = (ZB_WRITE_CONFIGURATION_RSP) sendSynchronous( new ZB_WRITE_CONFIGURATION(ZB_WRITE_CONFIGURATION.CONFIG_ID.ZCD_NV_CHANLIST, channelMask)); return response != null && response.Status == 0; } }
ZigBeeNetworkManager { private boolean dongleSetChannel(int[] channelMask) { channelMask[0] &= ZNP_CHANNEL_MASK0; channelMask[1] &= ZNP_CHANNEL_MASK1; channelMask[2] &= ZNP_CHANNEL_MASK2; channelMask[3] &= ZNP_CHANNEL_MASK3; if (channelMask[0] == 0 && channelMask[1] == 0 && channelMask[2] == 0 && channelMask[3] == 0) { channelMask[0] = ZNP_CHANNEL_DEFAULT0; channelMask[1] = ZNP_CHANNEL_DEFAULT1; channelMask[2] = ZNP_CHANNEL_DEFAULT2; channelMask[3] = ZNP_CHANNEL_DEFAULT3; } logger.trace("Setting the channel to {}{}{}{}", new Object[] { Integer.toHexString(channelMask[0]), Integer.toHexString(channelMask[1]), Integer.toHexString(channelMask[2]), Integer.toHexString(channelMask[3]) }); ZB_WRITE_CONFIGURATION_RSP response = (ZB_WRITE_CONFIGURATION_RSP) sendSynchronous( new ZB_WRITE_CONFIGURATION(ZB_WRITE_CONFIGURATION.CONFIG_ID.ZCD_NV_CHANLIST, channelMask)); return response != null && response.Status == 0; } ZigBeeNetworkManager(CommandInterface commandInterface, NetworkMode mode, long timeout); }
ZigBeeNetworkManager { private boolean dongleSetChannel(int[] channelMask) { channelMask[0] &= ZNP_CHANNEL_MASK0; channelMask[1] &= ZNP_CHANNEL_MASK1; channelMask[2] &= ZNP_CHANNEL_MASK2; channelMask[3] &= ZNP_CHANNEL_MASK3; if (channelMask[0] == 0 && channelMask[1] == 0 && channelMask[2] == 0 && channelMask[3] == 0) { channelMask[0] = ZNP_CHANNEL_DEFAULT0; channelMask[1] = ZNP_CHANNEL_DEFAULT1; channelMask[2] = ZNP_CHANNEL_DEFAULT2; channelMask[3] = ZNP_CHANNEL_DEFAULT3; } logger.trace("Setting the channel to {}{}{}{}", new Object[] { Integer.toHexString(channelMask[0]), Integer.toHexString(channelMask[1]), Integer.toHexString(channelMask[2]), Integer.toHexString(channelMask[3]) }); ZB_WRITE_CONFIGURATION_RSP response = (ZB_WRITE_CONFIGURATION_RSP) sendSynchronous( new ZB_WRITE_CONFIGURATION(ZB_WRITE_CONFIGURATION.CONFIG_ID.ZCD_NV_CHANLIST, channelMask)); return response != null && response.Status == 0; } ZigBeeNetworkManager(CommandInterface commandInterface, NetworkMode mode, long timeout); void setMagicNumber(int magicNumber); void setRetryConfiguration(int retries, int timeout); String startup(); void shutdown(); boolean initializeZigBeeNetwork(boolean cleanStatus); void setZigBeeNodeMode(NetworkMode networkMode); void setZigBeeNetworkKey(byte[] networkKey); boolean setZigBeePanId(int panId); boolean setZigBeeChannel(int channel); boolean setZigBeeExtendedPanId(ExtendedPanId panId); boolean setNetworkKey(byte[] networkKey); boolean setDistributeNetworkKey(boolean distributeNetworkKey); boolean setSecurityMode(int securityMode); ZigBeeStatus setTxPower(int txPower); ZigBeeStatus setLedMode(int ledId, boolean mode); void addAsynchronousCommandListener(final AsynchronousCommandListener asynchronousCommandListener); RESPONSE sendLocalRequest(REQUEST request); RESPONSE sendRemoteRequest(REQUEST request); ZToolPacket sendCommand(final ZToolPacket request); AF_REGISTER_SRSP sendAFRegister(AF_REGISTER request); AF_DATA_CONFIRM sendAFDataRequest(AF_DATA_REQUEST request); AF_DATA_SRSP_EXT sendAFDataRequestExt(AF_DATA_REQUEST_EXT request); boolean removeAFMessageListener(ApplicationFrameworkMessageListener listener); boolean addAFMessageListener(ApplicationFrameworkMessageListener listener); ExtendedPanId getCurrentExtendedPanId(); long getIeeeAddress(); int getCurrentPanId(); int getCurrentChannel(); int getZigBeeNodeMode(); ZigBeeKey getZigBeeNetworkKey(); DriverStatus getDriverStatus(); }
ZigBeeNetworkManager { private boolean dongleSetChannel(int[] channelMask) { channelMask[0] &= ZNP_CHANNEL_MASK0; channelMask[1] &= ZNP_CHANNEL_MASK1; channelMask[2] &= ZNP_CHANNEL_MASK2; channelMask[3] &= ZNP_CHANNEL_MASK3; if (channelMask[0] == 0 && channelMask[1] == 0 && channelMask[2] == 0 && channelMask[3] == 0) { channelMask[0] = ZNP_CHANNEL_DEFAULT0; channelMask[1] = ZNP_CHANNEL_DEFAULT1; channelMask[2] = ZNP_CHANNEL_DEFAULT2; channelMask[3] = ZNP_CHANNEL_DEFAULT3; } logger.trace("Setting the channel to {}{}{}{}", new Object[] { Integer.toHexString(channelMask[0]), Integer.toHexString(channelMask[1]), Integer.toHexString(channelMask[2]), Integer.toHexString(channelMask[3]) }); ZB_WRITE_CONFIGURATION_RSP response = (ZB_WRITE_CONFIGURATION_RSP) sendSynchronous( new ZB_WRITE_CONFIGURATION(ZB_WRITE_CONFIGURATION.CONFIG_ID.ZCD_NV_CHANLIST, channelMask)); return response != null && response.Status == 0; } ZigBeeNetworkManager(CommandInterface commandInterface, NetworkMode mode, long timeout); void setMagicNumber(int magicNumber); void setRetryConfiguration(int retries, int timeout); String startup(); void shutdown(); boolean initializeZigBeeNetwork(boolean cleanStatus); void setZigBeeNodeMode(NetworkMode networkMode); void setZigBeeNetworkKey(byte[] networkKey); boolean setZigBeePanId(int panId); boolean setZigBeeChannel(int channel); boolean setZigBeeExtendedPanId(ExtendedPanId panId); boolean setNetworkKey(byte[] networkKey); boolean setDistributeNetworkKey(boolean distributeNetworkKey); boolean setSecurityMode(int securityMode); ZigBeeStatus setTxPower(int txPower); ZigBeeStatus setLedMode(int ledId, boolean mode); void addAsynchronousCommandListener(final AsynchronousCommandListener asynchronousCommandListener); RESPONSE sendLocalRequest(REQUEST request); RESPONSE sendRemoteRequest(REQUEST request); ZToolPacket sendCommand(final ZToolPacket request); AF_REGISTER_SRSP sendAFRegister(AF_REGISTER request); AF_DATA_CONFIRM sendAFDataRequest(AF_DATA_REQUEST request); AF_DATA_SRSP_EXT sendAFDataRequestExt(AF_DATA_REQUEST_EXT request); boolean removeAFMessageListener(ApplicationFrameworkMessageListener listener); boolean addAFMessageListener(ApplicationFrameworkMessageListener listener); ExtendedPanId getCurrentExtendedPanId(); long getIeeeAddress(); int getCurrentPanId(); int getCurrentChannel(); int getZigBeeNodeMode(); ZigBeeKey getZigBeeNetworkKey(); DriverStatus getDriverStatus();  }