Search in sources :

Example 1 with BindRequest

use of com.zsmartsystems.zigbee.zdo.command.BindRequest in project com.zsmartsystems.zigbee by zsmartsystems.

the class ZdoResponseMatcherTest method testMatch.

@Test
public void testMatch() {
    ZdoTransactionMatcher matcher = new ZdoTransactionMatcher();
    ZdoRequest zdoCommand = new BindRequest();
    BindResponse zdoResponse = new BindResponse();
    zdoCommand.setDestinationAddress(new ZigBeeEndpointAddress(1234));
    zdoResponse.setSourceAddress(new ZigBeeEndpointAddress(1234));
    assertTrue(matcher.isTransactionMatch(zdoCommand, zdoResponse));
    zdoResponse.setSourceAddress(new ZigBeeEndpointAddress(5678));
    assertFalse(matcher.isTransactionMatch(zdoCommand, zdoResponse));
    ZclCommand zclResponse = new OffCommand();
    assertFalse(matcher.isTransactionMatch(zdoCommand, zclResponse));
}
Also used : ZigBeeEndpointAddress(com.zsmartsystems.zigbee.ZigBeeEndpointAddress) BindRequest(com.zsmartsystems.zigbee.zdo.command.BindRequest) OffCommand(com.zsmartsystems.zigbee.zcl.clusters.onoff.OffCommand) BindResponse(com.zsmartsystems.zigbee.zdo.command.BindResponse) ZclCommand(com.zsmartsystems.zigbee.zcl.ZclCommand) Test(org.junit.Test)

Example 2 with BindRequest

use of com.zsmartsystems.zigbee.zdo.command.BindRequest in project com.zsmartsystems.zigbee by zsmartsystems.

the class ZclClusterTest method bind.

@Test
public void bind() {
    createNetworkManager();
    ZigBeeNode node = new ZigBeeNode(networkManager, new IeeeAddress());
    node.setNetworkAddress(1234);
    ZigBeeEndpoint device = new ZigBeeEndpoint(networkManager, node, 5);
    ZclCluster cluster = new ZclOnOffCluster(networkManager, device);
    cluster.bind(new IeeeAddress("1234567890ABCDEF"), 11);
    assertEquals(1, commandCapture.getAllValues().size());
    ZigBeeCommand command = commandCapture.getValue();
    assertNotNull(command);
    System.out.println(command);
    assertTrue(command instanceof BindRequest);
    BindRequest bindCommand = (BindRequest) command;
    assertEquals(new ZigBeeEndpointAddress(1234, 0), bindCommand.getDestinationAddress());
    assertEquals(new IeeeAddress("1234567890ABCDEF"), bindCommand.getDstAddress());
    assertEquals(Integer.valueOf(5), bindCommand.getSrcEndpoint());
    assertEquals(Integer.valueOf(11), bindCommand.getDstEndpoint());
    assertEquals(Integer.valueOf(3), bindCommand.getDstAddrMode());
    assertEquals(Integer.valueOf(0x0021), bindCommand.getClusterId());
    assertEquals(Integer.valueOf(6), bindCommand.getBindCluster());
}
Also used : ZclOnOffCluster(com.zsmartsystems.zigbee.zcl.clusters.ZclOnOffCluster) ZigBeeCommand(com.zsmartsystems.zigbee.ZigBeeCommand) ZigBeeEndpointAddress(com.zsmartsystems.zigbee.ZigBeeEndpointAddress) BindRequest(com.zsmartsystems.zigbee.zdo.command.BindRequest) ZigBeeNode(com.zsmartsystems.zigbee.ZigBeeNode) ZigBeeEndpoint(com.zsmartsystems.zigbee.ZigBeeEndpoint) IeeeAddress(com.zsmartsystems.zigbee.IeeeAddress) Test(org.junit.Test)

Example 3 with BindRequest

use of com.zsmartsystems.zigbee.zdo.command.BindRequest in project com.zsmartsystems.zigbee by zsmartsystems.

the class ZclCluster method bind.

/**
 * Adds a binding from the cluster to the destination {@link ZigBeeEndpoint}.
 *
 * @param address the destination {@link IeeeAddress}
 * @param endpointId the destination endpoint ID
 * @return Command future
 */
public Future<CommandResult> bind(IeeeAddress address, int endpointId) {
    final BindRequest command = new BindRequest();
    command.setDestinationAddress(new ZigBeeEndpointAddress(zigbeeEndpoint.getEndpointAddress().getAddress()));
    command.setSrcAddress(zigbeeEndpoint.getIeeeAddress());
    command.setSrcEndpoint(zigbeeEndpoint.getEndpointId());
    command.setBindCluster(clusterId);
    // 64 bit addressing
    command.setDstAddrMode(3);
    command.setDstAddress(address);
    command.setDstEndpoint(endpointId);
    return zigbeeManager.unicast(command, new BindRequest());
}
Also used : ZigBeeEndpointAddress(com.zsmartsystems.zigbee.ZigBeeEndpointAddress) BindRequest(com.zsmartsystems.zigbee.zdo.command.BindRequest)

Aggregations

ZigBeeEndpointAddress (com.zsmartsystems.zigbee.ZigBeeEndpointAddress)3 BindRequest (com.zsmartsystems.zigbee.zdo.command.BindRequest)3 Test (org.junit.Test)2 IeeeAddress (com.zsmartsystems.zigbee.IeeeAddress)1 ZigBeeCommand (com.zsmartsystems.zigbee.ZigBeeCommand)1 ZigBeeEndpoint (com.zsmartsystems.zigbee.ZigBeeEndpoint)1 ZigBeeNode (com.zsmartsystems.zigbee.ZigBeeNode)1 ZclCommand (com.zsmartsystems.zigbee.zcl.ZclCommand)1 ZclOnOffCluster (com.zsmartsystems.zigbee.zcl.clusters.ZclOnOffCluster)1 OffCommand (com.zsmartsystems.zigbee.zcl.clusters.onoff.OffCommand)1 BindResponse (com.zsmartsystems.zigbee.zdo.command.BindResponse)1