@Test public void buildChannelMask() { ZigBeeNetworkManager networkManager = new ZigBeeNetworkManager(null, null, 0); int[] mask; Method privateMethod; try { privateMethod = ZigBeeNetworkManager.class.getDeclaredMethod("buildChannelMask", new Class[] { int.class }); privateMethod.setAccessible(true); mask = (int[]) privateMethod.invoke(networkManager, -1); assertTrue(Arrays.equals(new int[] { 0x00, 0x00, 0x00, 0x00 }, mask)); mask = (int[]) privateMethod.invoke(networkManager, 32); assertTrue(Arrays.equals(new int[] { 0x00, 0x00, 0x00, 0x00 }, mask)); mask = (int[]) privateMethod.invoke(networkManager, 11); assertTrue(Arrays.equals(new int[] { 0x00, 0x08, 0x00, 0x00 }, mask)); mask = (int[]) privateMethod.invoke(networkManager, 27); assertTrue(Arrays.equals(new int[] { 0x00, 0x00, 0x00, 0x08 }, mask)); } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { e.printStackTrace(); } }
private final int[] buildChannelMask(int channel) { if (channel < 11 || channel > 27) { return new int[] { 0, 0, 0, 0 }; } int channelMask = 1 << channel; int[] mask = new int[4]; for (int i = 0; i < mask.length; i++) { mask[i] = Integers.getByteAsInteger(channelMask, i); } return mask; }
ZigBeeNetworkManager { private final int[] buildChannelMask(int channel) { if (channel < 11 || channel > 27) { return new int[] { 0, 0, 0, 0 }; } int channelMask = 1 << channel; int[] mask = new int[4]; for (int i = 0; i < mask.length; i++) { mask[i] = Integers.getByteAsInteger(channelMask, i); } return mask; } }
ZigBeeNetworkManager { private final int[] buildChannelMask(int channel) { if (channel < 11 || channel > 27) { return new int[] { 0, 0, 0, 0 }; } int channelMask = 1 << channel; int[] mask = new int[4]; for (int i = 0; i < mask.length; i++) { mask[i] = Integers.getByteAsInteger(channelMask, i); } return mask; } ZigBeeNetworkManager(CommandInterface commandInterface, NetworkMode mode, long timeout); }
ZigBeeNetworkManager { private final int[] buildChannelMask(int channel) { if (channel < 11 || channel > 27) { return new int[] { 0, 0, 0, 0 }; } int channelMask = 1 << channel; int[] mask = new int[4]; for (int i = 0; i < mask.length; i++) { mask[i] = Integers.getByteAsInteger(channelMask, i); } return mask; } 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 final int[] buildChannelMask(int channel) { if (channel < 11 || channel > 27) { return new int[] { 0, 0, 0, 0 }; } int channelMask = 1 << channel; int[] mask = new int[4]; for (int i = 0; i < mask.length; i++) { mask[i] = Integers.getByteAsInteger(channelMask, i); } return mask; } 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();  }