@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((availablePowerSources == null) ? 0 : availablePowerSources.hashCode()); result = prime * result + ((currentPowerMode == null) ? 0 : currentPowerMode.hashCode()); result = prime * result + ((currentPowerSource == null) ? 0 : currentPowerSource.hashCode()); result = prime * result + ((powerLevel == null) ? 0 : powerLevel.hashCode()); return result; }
public NodeDescriptor(int apsFlags, int bufferSize, int macCapabilities, boolean complexDescriptorAvailable, int manufacturerCode, int logicalType, int serverMask, int transferSize, boolean userDescriptorAvailable, int frequencyBands) { this.complexDescriptorAvailable = complexDescriptorAvailable; this.userDescriptorAvailable = userDescriptorAvailable; this.manufacturerCode = manufacturerCode; this.bufferSize = bufferSize; this.incomingTransferSize = transferSize; setLogicalType(logicalType); setMacCapabilities(macCapabilities); setFrequencyBands(frequencyBands); setServerCapabilities(serverMask); this.apsFlags = apsFlags; }
/** * Creates a PowerDescriptor * * @param currentPowerMode * @param availablePowerSources * @param currentPowerSource * @param powerLevel */ public PowerDescriptor(int currentPowerMode, int availablePowerSources, int currentPowerSource, int powerLevel) { setCurrentPowerMode(currentPowerMode); setAvailablePowerSources(availablePowerSources); setCurrentPowerSource(currentPowerSource); setCurrentPowerLevel(powerLevel); }
@Test public void testNodeDescriptorDeserialize() { int[] packet = getPacketData("00 00 00 00 00 40 8F CD AB 52 80 00 41 2A 80 00 00"); NodeDescriptor descriptor = new NodeDescriptor(); DefaultDeserializer deserializer = new DefaultDeserializer(packet); descriptor.deserialize(deserializer); System.out.println(descriptor); assertEquals(0, descriptor.getManufacturerCode()); assertEquals(LogicalType.COORDINATOR, descriptor.getLogicalType()); }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((depth == null) ? 0 : depth.hashCode()); result = prime * result + ((deviceType == null) ? 0 : deviceType.hashCode()); result = prime * result + ((extendedAddress == null) ? 0 : extendedAddress.hashCode()); result = prime * result + ((extendedPanId == null) ? 0 : extendedPanId.hashCode()); result = prime * result + ((lqi == null) ? 0 : lqi.hashCode()); result = prime * result + ((networkAddress == null) ? 0 : networkAddress.hashCode()); result = prime * result + ((permitJoining == null) ? 0 : permitJoining.hashCode()); result = prime * result + ((relationship == null) ? 0 : relationship.hashCode()); result = prime * result + ((rxOnWhenIdle == null) ? 0 : rxOnWhenIdle.hashCode()); return result; }
private NeighborTable getNeighborTable(int[] packet) { DefaultDeserializer deserializer = new DefaultDeserializer(packet); NeighborTable neighbor = new NeighborTable(); neighbor.deserialize(deserializer); return neighbor; }
/** * Deserialise the contents of the structure. * * @param deserializer the {@link ZigBeeDeserializer} used to deserialize */ public void deserialize(ZigBeeDeserializer deserializer) { // Deserialize the fields extendedPanId = (ExtendedPanId) deserializer.readZigBeeType(ZclDataType.EXTENDED_PANID); extendedAddress = (IeeeAddress) deserializer.readZigBeeType(ZclDataType.IEEE_ADDRESS); networkAddress = (Integer) deserializer.readZigBeeType(ZclDataType.UNSIGNED_16_BIT_INTEGER); int temp = (int) deserializer.readZigBeeType(ZclDataType.UNSIGNED_8_BIT_INTEGER); setDeviceType(temp & 0x03); setRxOnWhenIdle((temp & 0x0c) >> 2); setRelationship((temp & 0x70) >> 4); temp = (int) deserializer.readZigBeeType(ZclDataType.UNSIGNED_8_BIT_INTEGER); setPermitJoining(temp & 0x03); depth = (int) deserializer.readZigBeeType(ZclDataType.UNSIGNED_8_BIT_INTEGER); lqi = (int) deserializer.readZigBeeType(ZclDataType.UNSIGNED_8_BIT_INTEGER); }
@Test public void testNodeDescriptorR21() { NodeDescriptor descriptor = new NodeDescriptor(0, 0, 0, true, 0, 0, 0x2A00, 0, true, 0); assertEquals(21, descriptor.getStackCompliance()); }
/** * Gets the {@link LogicalType} of the node. * <p> * Possible types are -: * <ul> * <li>{@link LogicalType#COORDINATOR} * <li>{@link LogicalType#ROUTER} * <li>{@link LogicalType#END_DEVICE} * <ul> * * @return the {@link LogicalType} of the node */ public LogicalType getLogicalType() { return nodeDescriptor.getLogicalType(); }
public boolean isSecurityCapable() { if (nodeDescriptor == null) { return false; } return nodeDescriptor.getMacCapabilities().contains(MacCapabilitiesType.SECURITY_CAPABLE); }
@Test public void testHashCodeAndEquals() { NeighborTable neighbor1 = getNeighborTable(12345, "123456789", 0); NeighborTable neighbor2 = getNeighborTable(12345, "123456789", 0); NeighborTable neighbor3 = getNeighborTable(54321, "987654321", 0); NeighborTable neighbor4 = getNeighborTable(54321, "987654321", 11); assertEquals(neighbor1.hashCode(), neighbor2.hashCode()); assertNotEquals(neighbor1.hashCode(), neighbor3.hashCode()); assertTrue(neighbor1.equals(neighbor2)); assertFalse(neighbor1.equals(neighbor3)); assertFalse(neighbor3.equals(neighbor4)); } }
public boolean isPrimaryTrustCenter() { if (nodeDescriptor == null) { return false; } return nodeDescriptor.getServerCapabilities().contains(ServerCapabilitiesType.PRIMARY_TRUST_CENTER); }
@Test public void test() { BindingTable table = new BindingTable(); System.out.println(table); } }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((destinationAddress == null) ? 0 : destinationAddress.hashCode()); result = prime * result + (manyToOne ? 1231 : 1237); result = prime * result + (memoryConstrained ? 1231 : 1237); result = prime * result + ((nextHopAddress == null) ? 0 : nextHopAddress.hashCode()); result = prime * result + (routeRecordRequired ? 1231 : 1237); result = prime * result + ((status == null) ? 0 : status.hashCode()); return result; }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + apsFlags; result = prime * result + bufferSize; result = prime * result + (complexDescriptorAvailable ? 1231 : 1237); result = prime * result + (extendedEndpointListAvailable ? 1231 : 1237); result = prime * result + (extendedSimpleDescriptorListAvailable ? 1231 : 1237); result = prime * result + ((frequencyBands == null) ? 0 : frequencyBands.hashCode()); result = prime * result + incomingTransferSize; result = prime * result + ((logicalType == null) ? 0 : logicalType.hashCode()); result = prime * result + ((macCapabilities == null) ? 0 : macCapabilities.hashCode()); result = prime * result + manufacturerCode; result = prime * result + outgoingTransferSize; result = prime * result + ((serverCapabilities == null) ? 0 : serverCapabilities.hashCode()); result = prime * result + (userDescriptorAvailable ? 1231 : 1237); return result; }
/** * Deserialise the contents of the structure. * * @param deserializer the {@link ZigBeeDeserializer} used to deserialize */ public void deserialize(ZigBeeDeserializer deserializer) { // Deserialize the fields int byte1 = (int) deserializer.readZigBeeType(ZclDataType.UNSIGNED_8_BIT_INTEGER); int byte2 = (int) deserializer.readZigBeeType(ZclDataType.UNSIGNED_8_BIT_INTEGER); setCurrentPowerMode(byte1 & 0x0f); setAvailablePowerSources(byte1 >> 4 & 0x0f); setCurrentPowerSource(byte2 & 0x0f); setCurrentPowerLevel(byte2 >> 4 & 0x0f); }
/** * Checks if basic device discovery is complete. This ensures that we have received the {@link NodeDescriptor} and * the {@link SimpleDescriptor} so that we know the endpoints. * * @return true if basic device information is known */ public boolean isDiscovered() { return nodeDescriptor.getLogicalType() != LogicalType.UNKNOWN && endpoints.size() != 0; }
/** * Returns true if the node is a Full Function Device. Returns false if not an FFD or logical type is unknown. * <p> * A FFD (Full Function Device) is a device that has full levels of functionality. * It can be used for sending and receiving data, but it can also route data from other nodes. * FFDs are Coordinators and Routers * * @return true if the device is a Full Function Device. Returns false if not an FFD or logical type is unknown. */ public boolean isFullFuntionDevice() { if (nodeDescriptor == null) { return false; } return nodeDescriptor.getMacCapabilities().contains(MacCapabilitiesType.FULL_FUNCTION_DEVICE); }
@Override public String toString() { StringBuilder builder = new StringBuilder(100); builder.append("ZigBeeNode [state="); builder.append(nodeState); builder.append(", IEEE="); builder.append(ieeeAddress); builder.append(String.format(", NWK=%04X", networkAddress)); if (nodeDescriptor != null) { builder.append(", Type="); builder.append(nodeDescriptor.getLogicalType()); } builder.append(']'); return builder.toString(); }
/** * Returns true if the node is a Reduced Function Device. Returns false if not an RFD or logical type is unknown. * <p> * An RFD (Reduced Function Device) is a device that has a reduced level of functionality. * Typically it is an end node which may be typically a sensor or switch. RFDs can only talk to FFDs * as they contain no routing functionality. These devices can be very low power devices because they * do not need to route other traffic and they can be put into a sleep mode when they are not in use. * * @return true if the device is a Reduced Function Device */ public boolean isReducedFuntionDevice() { if (nodeDescriptor == null) { return false; } return nodeDescriptor.getMacCapabilities().contains(MacCapabilitiesType.REDUCED_FUNCTION_DEVICE); }