Search in sources :

Example 1 with UnbindRequest

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

the class ZclClusterTest method unbind.

@Test
public void unbind() {
    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.unbind(new IeeeAddress("1234567890ABCDEF"), 11);
    assertEquals(1, commandCapture.getAllValues().size());
    ZigBeeCommand command = commandCapture.getValue();
    assertNotNull(command);
    System.out.println(command);
    assertTrue(command instanceof UnbindRequest);
    UnbindRequest unbindCommand = (UnbindRequest) command;
    assertEquals(new ZigBeeEndpointAddress(1234, 0), unbindCommand.getDestinationAddress());
    assertEquals(new IeeeAddress("1234567890ABCDEF"), unbindCommand.getDstAddress());
    assertEquals(Integer.valueOf(5), unbindCommand.getSrcEndpoint());
    assertEquals(Integer.valueOf(11), unbindCommand.getDstEndpoint());
    assertEquals(Integer.valueOf(3), unbindCommand.getDstAddrMode());
    assertEquals(Integer.valueOf(0x0022), unbindCommand.getClusterId());
    assertEquals(Integer.valueOf(6), unbindCommand.getBindCluster());
}
Also used : ZclOnOffCluster(com.zsmartsystems.zigbee.zcl.clusters.ZclOnOffCluster) ZigBeeCommand(com.zsmartsystems.zigbee.ZigBeeCommand) ZigBeeEndpointAddress(com.zsmartsystems.zigbee.ZigBeeEndpointAddress) ZigBeeNode(com.zsmartsystems.zigbee.ZigBeeNode) ZigBeeEndpoint(com.zsmartsystems.zigbee.ZigBeeEndpoint) IeeeAddress(com.zsmartsystems.zigbee.IeeeAddress) UnbindRequest(com.zsmartsystems.zigbee.zdo.command.UnbindRequest) Test(org.junit.Test)

Example 2 with UnbindRequest

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

the class ZclCluster method unbind.

/**
 * Removes 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> unbind(IeeeAddress address, int endpointId) {
    final UnbindRequest command = new UnbindRequest();
    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 UnbindRequest());
}
Also used : ZigBeeEndpointAddress(com.zsmartsystems.zigbee.ZigBeeEndpointAddress) UnbindRequest(com.zsmartsystems.zigbee.zdo.command.UnbindRequest)

Aggregations

ZigBeeEndpointAddress (com.zsmartsystems.zigbee.ZigBeeEndpointAddress)2 UnbindRequest (com.zsmartsystems.zigbee.zdo.command.UnbindRequest)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 ZclOnOffCluster (com.zsmartsystems.zigbee.zcl.clusters.ZclOnOffCluster)1 Test (org.junit.Test)1