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));
}
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());
}
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());
}
Aggregations