Search in sources :

Example 56 with IeeeAddress

use of com.zsmartsystems.zigbee.IeeeAddress in project com.zsmartsystems.zigbee by zsmartsystems.

the class ZclClusterTest method getClusterName.

@Test
public void getClusterName() {
    createNetworkManager();
    ZigBeeNode node = new ZigBeeNode(networkManager, new IeeeAddress());
    node.setNetworkAddress(1234);
    ZigBeeEndpoint device = new ZigBeeEndpoint(networkManager, node, 5);
    ZclCluster cluster = new ZclLevelControlCluster(networkManager, device);
    assertEquals("Level Control", cluster.getClusterName());
}
Also used : ZigBeeNode(com.zsmartsystems.zigbee.ZigBeeNode) ZclLevelControlCluster(com.zsmartsystems.zigbee.zcl.clusters.ZclLevelControlCluster) ZigBeeEndpoint(com.zsmartsystems.zigbee.ZigBeeEndpoint) IeeeAddress(com.zsmartsystems.zigbee.IeeeAddress) Test(org.junit.Test)

Example 57 with IeeeAddress

use of com.zsmartsystems.zigbee.IeeeAddress in project com.zsmartsystems.zigbee by zsmartsystems.

the class ZclClusterTest method getClusterId.

@Test
public void getClusterId() {
    createNetworkManager();
    ZigBeeNode node = new ZigBeeNode(networkManager, new IeeeAddress());
    node.setNetworkAddress(1234);
    ZigBeeEndpoint device = new ZigBeeEndpoint(networkManager, node, 5);
    ZclCluster cluster = new ZclOnOffCluster(networkManager, device);
    assertEquals(Integer.valueOf(6), cluster.getClusterId());
}
Also used : ZclOnOffCluster(com.zsmartsystems.zigbee.zcl.clusters.ZclOnOffCluster) ZigBeeNode(com.zsmartsystems.zigbee.ZigBeeNode) ZigBeeEndpoint(com.zsmartsystems.zigbee.ZigBeeEndpoint) IeeeAddress(com.zsmartsystems.zigbee.IeeeAddress) Test(org.junit.Test)

Example 58 with IeeeAddress

use of com.zsmartsystems.zigbee.IeeeAddress in project com.zsmartsystems.zigbee by zsmartsystems.

the class ZclClusterTest method setReporting.

@Test
public void setReporting() {
    createNetworkManager();
    ZigBeeNode node = new ZigBeeNode(networkManager, new IeeeAddress());
    node.setNetworkAddress(1234);
    ZigBeeEndpoint device = new ZigBeeEndpoint(networkManager, node, 5);
    ZclCluster cluster = new ZclOnOffCluster(networkManager, device);
    ZclAttribute attribute = cluster.getAttribute(0);
    cluster.setReporting(attribute, 22, 33);
    assertEquals(1, commandCapture.getAllValues().size());
    ZigBeeCommand command = commandCapture.getValue();
    assertNotNull(command);
    System.out.println(command);
    assertTrue(command instanceof ConfigureReportingCommand);
    ConfigureReportingCommand cfgCommand = (ConfigureReportingCommand) command;
    assertEquals(1, cfgCommand.getRecords().size());
    AttributeReportingConfigurationRecord record = cfgCommand.getRecords().get(0);
    assertEquals(0, record.getAttributeIdentifier());
    assertEquals(0, record.getDirection());
}
Also used : ZclOnOffCluster(com.zsmartsystems.zigbee.zcl.clusters.ZclOnOffCluster) ZigBeeCommand(com.zsmartsystems.zigbee.ZigBeeCommand) AttributeReportingConfigurationRecord(com.zsmartsystems.zigbee.zcl.field.AttributeReportingConfigurationRecord) ZigBeeNode(com.zsmartsystems.zigbee.ZigBeeNode) ConfigureReportingCommand(com.zsmartsystems.zigbee.zcl.clusters.general.ConfigureReportingCommand) ZigBeeEndpoint(com.zsmartsystems.zigbee.ZigBeeEndpoint) IeeeAddress(com.zsmartsystems.zigbee.IeeeAddress) Test(org.junit.Test)

Example 59 with IeeeAddress

use of com.zsmartsystems.zigbee.IeeeAddress in project com.zsmartsystems.zigbee by zsmartsystems.

the class NetworkAddressResponseTest method testReceive.

@Test
public void testReceive() {
    int[] packet = getPacketData("00 00 43 1D A5 00 AA 3E B0 7C 74 3B");
    NetworkAddressResponse addressResponse = new NetworkAddressResponse();
    DefaultDeserializer deserializer = new DefaultDeserializer(packet);
    ZclFieldDeserializer fieldDeserializer = new ZclFieldDeserializer(deserializer);
    addressResponse.deserialize(fieldDeserializer);
    System.out.println(addressResponse);
    assertEquals(new IeeeAddress("7CB03EAA00A51D43"), addressResponse.getIeeeAddrRemoteDev());
    assertEquals(0x8000, (int) addressResponse.getClusterId());
    assertEquals(ZdoStatus.SUCCESS, addressResponse.getStatus());
}
Also used : DefaultDeserializer(com.zsmartsystems.zigbee.serialization.DefaultDeserializer) ZclFieldDeserializer(com.zsmartsystems.zigbee.zcl.ZclFieldDeserializer) IeeeAddress(com.zsmartsystems.zigbee.IeeeAddress) CommandTest(com.zsmartsystems.zigbee.CommandTest) Test(org.junit.Test)

Example 60 with IeeeAddress

use of com.zsmartsystems.zigbee.IeeeAddress in project com.zsmartsystems.zigbee by zsmartsystems.

the class NeighborTableTest method getNeighborTable.

private NeighborTable getNeighborTable(Integer networkAddress, String ieeeAddressString, Integer lqi) {
    NeighborTable neighbor = new NeighborTable();
    try {
        IeeeAddress ieeeAddress = new IeeeAddress(ieeeAddressString);
        Field fieldNetworkAddress = NeighborTable.class.getDeclaredField("networkAddress");
        fieldNetworkAddress.setAccessible(true);
        fieldNetworkAddress.set(neighbor, networkAddress);
        Field fieldExtendedAddress = NeighborTable.class.getDeclaredField("extendedAddress");
        fieldExtendedAddress.setAccessible(true);
        fieldExtendedAddress.set(neighbor, ieeeAddress);
        Field fieldLqi = NeighborTable.class.getDeclaredField("lqi");
        fieldLqi.setAccessible(true);
        fieldLqi.set(neighbor, lqi);
    } catch (IllegalAccessException | IllegalArgumentException e) {
        e.printStackTrace();
    } catch (SecurityException e) {
        e.printStackTrace();
    } catch (NoSuchFieldException e) {
        e.printStackTrace();
    }
    return neighbor;
}
Also used : Field(java.lang.reflect.Field) IeeeAddress(com.zsmartsystems.zigbee.IeeeAddress)

Aggregations

IeeeAddress (com.zsmartsystems.zigbee.IeeeAddress)66 Test (org.junit.Test)53 ZigBeeEndpoint (com.zsmartsystems.zigbee.ZigBeeEndpoint)12 ZigBeeNode (com.zsmartsystems.zigbee.ZigBeeNode)12 CommandTest (com.zsmartsystems.zigbee.CommandTest)7 DefaultDeserializer (com.zsmartsystems.zigbee.serialization.DefaultDeserializer)7 ZclOnOffCluster (com.zsmartsystems.zigbee.zcl.clusters.ZclOnOffCluster)7 ZigBeeEndpointAddress (com.zsmartsystems.zigbee.ZigBeeEndpointAddress)6 ZclFieldDeserializer (com.zsmartsystems.zigbee.zcl.ZclFieldDeserializer)6 ArrayList (java.util.ArrayList)6 ZigBeeCommand (com.zsmartsystems.zigbee.ZigBeeCommand)5 EzspFrameTest (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.EzspFrameTest)4 CommandResult (com.zsmartsystems.zigbee.CommandResult)3 ExtendedPanId (com.zsmartsystems.zigbee.ExtendedPanId)3 NodeDescriptor (com.zsmartsystems.zigbee.zdo.field.NodeDescriptor)3 HashSet (java.util.HashSet)3 ZigBeeNetworkManager (com.zsmartsystems.zigbee.ZigBeeNetworkManager)2 EmberInitialSecurityState (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberInitialSecurityState)2 EmberKeyData (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberKeyData)2 XBeeFrameHandler (com.zsmartsystems.zigbee.dongle.xbee.internal.XBeeFrameHandler)2