use of com.zsmartsystems.zigbee.ZigBeeEndpointAddress in project com.zsmartsystems.zigbee by zsmartsystems.
the class ConBeeEnqueueSendDataRequestTest method doRequest.
@Test
public void doRequest() {
ConBeeEnqueueSendDataRequest request = new ConBeeEnqueueSendDataRequest();
request.setSequence(0x11);
request.setRequestId(0x22);
request.setDestinationAddress(new ZigBeeEndpointAddress(0x9876, 0x54));
request.setDestinationAddressMode(ConBeeAddressMode.NWK);
request.setProfileId(0x4444);
request.setClusterId(0x0000);
request.setRadius(0x1F);
request.setSourceEndpoint(0x33);
request.setAdsuData(new int[] { 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF });
System.out.println(request);
assertTrue(Arrays.equals(new int[] { 0x12, 0x11, 0x00, 0x1C, 0x00, 0x15, 0x00, 0x22, 0x00, 0x02, 0x76, 0x98, 0x54, 0x44, 0x44, 0x00, 0x00, 0x33, 0x06, 0x00, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x04, 0x1f, 0x47, 0xf8 }, request.getOutputBuffer()));
}
use of com.zsmartsystems.zigbee.ZigBeeEndpointAddress in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZigBeeApi method on.
/**
* Switches destination on.
*
* @param destination the {@link ZigBeeAddress}
* @return the command result future.
*/
public Future<CommandResult> on(final ZigBeeAddress destination) {
if (!(destination instanceof ZigBeeEndpointAddress)) {
return null;
}
ZigBeeEndpointAddress endpointAddress = (ZigBeeEndpointAddress) destination;
ZigBeeEndpoint endpoint = networkManager.getNode(endpointAddress.getAddress()).getEndpoint(endpointAddress.getEndpoint());
if (endpoint == null) {
return null;
}
ZclOnOffCluster cluster = (ZclOnOffCluster) endpoint.getInputCluster(ZclOnOffCluster.CLUSTER_ID);
return cluster.onCommand();
}
use of com.zsmartsystems.zigbee.ZigBeeEndpointAddress in project com.zsmartsystems.zigbee by zsmartsystems.
the class EzspSendBroadcastTest method testSendPermitJoining.
@Test
public void testSendPermitJoining() {
ManagementPermitJoiningRequest permitJoining = new ManagementPermitJoiningRequest();
permitJoining.setDestinationAddress(new ZigBeeEndpointAddress(0xFFFC));
permitJoining.setSourceAddress(new ZigBeeEndpointAddress(0));
permitJoining.setTcSignificance(true);
permitJoining.setPermitDuration(255);
DefaultSerializer serializer = new DefaultSerializer();
ZclFieldSerializer fieldSerializer = new ZclFieldSerializer(serializer);
permitJoining.serialize(fieldSerializer);
int[] payload = serializer.getPayload();
EzspSendBroadcastRequest emberBroadcast = new EzspSendBroadcastRequest();
EmberApsFrame apsFrame = new EmberApsFrame();
apsFrame.setClusterId(permitJoining.getClusterId());
apsFrame.setProfileId(0);
apsFrame.setSourceEndpoint(0);
apsFrame.setDestinationEndpoint(0);
apsFrame.setSequence(5);
apsFrame.addOptions(EmberApsOption.EMBER_APS_OPTION_RETRY);
apsFrame.addOptions(EmberApsOption.EMBER_APS_OPTION_ENABLE_ADDRESS_DISCOVERY);
apsFrame.addOptions(EmberApsOption.EMBER_APS_OPTION_ENABLE_ROUTE_DISCOVERY);
apsFrame.setGroupId(0);
emberBroadcast.setMessageTag(5);
emberBroadcast.setSequenceNumber(5);
emberBroadcast.setApsFrame(apsFrame);
emberBroadcast.setDestination(permitJoining.getDestinationAddress().getAddress());
emberBroadcast.setMessageContents(payload);
emberBroadcast.setRadius(31);
int[] messageToSend = emberBroadcast.serialize();
String out = "";
for (int c : messageToSend) {
out += String.format("%02X ", c);
}
System.out.println(out);
assertTrue(Arrays.equals(getPacketData("05 00 36 FC FF 00 00 36 00 00 00 40 11 00 00 05 1F 05 03 00 FF 01"), messageToSend));
}
use of com.zsmartsystems.zigbee.ZigBeeEndpointAddress in project com.zsmartsystems.zigbee by zsmartsystems.
the class ClusterMatcherTest method testMatcherMatchOut.
@Test
public void testMatcherMatchOut() {
ClusterMatcher matcher = getMatcher();
matcher.addCluster(0x500);
matcher.addCluster(0x600);
List<Integer> clusterListIn = new ArrayList<Integer>();
List<Integer> clusterListOut = new ArrayList<Integer>();
clusterListOut.add(0x500);
MatchDescriptorRequest request = new MatchDescriptorRequest();
request.setSourceAddress(new ZigBeeEndpointAddress(1234, 5));
request.setProfileId(0x104);
request.setInClusterList(clusterListIn);
request.setOutClusterList(clusterListOut);
matcher.commandReceived(request);
assertEquals(1, mockedCommandCaptor.getAllValues().size());
}
use of com.zsmartsystems.zigbee.ZigBeeEndpointAddress in project com.zsmartsystems.zigbee by zsmartsystems.
the class ClusterMatcherTest method testMatcherMatchInOut.
@Test
public void testMatcherMatchInOut() {
ClusterMatcher matcher = getMatcher();
matcher.addCluster(0x500);
matcher.addCluster(0x600);
List<Integer> clusterListIn = new ArrayList<Integer>();
List<Integer> clusterListOut = new ArrayList<Integer>();
clusterListIn.add(0x500);
clusterListOut.add(0x500);
MatchDescriptorRequest request = new MatchDescriptorRequest();
request.setSourceAddress(new ZigBeeEndpointAddress(1234, 5));
request.setProfileId(0x104);
request.setInClusterList(clusterListIn);
request.setOutClusterList(clusterListOut);
matcher.commandReceived(request);
assertEquals(1, mockedCommandCaptor.getAllValues().size());
}
Aggregations