Search in sources :

Example 16 with ZigBeeEndpointAddress

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()));
}
Also used : ConBeeEnqueueSendDataRequest(com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeEnqueueSendDataRequest) ZigBeeEndpointAddress(com.zsmartsystems.zigbee.ZigBeeEndpointAddress) Test(org.junit.Test)

Example 17 with ZigBeeEndpointAddress

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();
}
Also used : ZclOnOffCluster(com.zsmartsystems.zigbee.zcl.clusters.ZclOnOffCluster) ZigBeeEndpointAddress(com.zsmartsystems.zigbee.ZigBeeEndpointAddress) ZigBeeEndpoint(com.zsmartsystems.zigbee.ZigBeeEndpoint)

Example 18 with ZigBeeEndpointAddress

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));
}
Also used : DefaultSerializer(com.zsmartsystems.zigbee.serialization.DefaultSerializer) ZigBeeEndpointAddress(com.zsmartsystems.zigbee.ZigBeeEndpointAddress) EzspSendBroadcastRequest(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspSendBroadcastRequest) EmberApsFrame(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberApsFrame) ZclFieldSerializer(com.zsmartsystems.zigbee.zcl.ZclFieldSerializer) ManagementPermitJoiningRequest(com.zsmartsystems.zigbee.zdo.command.ManagementPermitJoiningRequest) EzspFrameTest(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.EzspFrameTest) Test(org.junit.Test)

Example 19 with ZigBeeEndpointAddress

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());
}
Also used : ZigBeeEndpointAddress(com.zsmartsystems.zigbee.ZigBeeEndpointAddress) ArrayList(java.util.ArrayList) MatchDescriptorRequest(com.zsmartsystems.zigbee.zdo.command.MatchDescriptorRequest) Test(org.junit.Test)

Example 20 with ZigBeeEndpointAddress

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());
}
Also used : ZigBeeEndpointAddress(com.zsmartsystems.zigbee.ZigBeeEndpointAddress) ArrayList(java.util.ArrayList) MatchDescriptorRequest(com.zsmartsystems.zigbee.zdo.command.MatchDescriptorRequest) Test(org.junit.Test)

Aggregations

ZigBeeEndpointAddress (com.zsmartsystems.zigbee.ZigBeeEndpointAddress)35 Test (org.junit.Test)20 CommandResult (com.zsmartsystems.zigbee.CommandResult)10 ArrayList (java.util.ArrayList)10 ZigBeeEndpoint (com.zsmartsystems.zigbee.ZigBeeEndpoint)9 DefaultSerializer (com.zsmartsystems.zigbee.serialization.DefaultSerializer)8 ZclFieldSerializer (com.zsmartsystems.zigbee.zcl.ZclFieldSerializer)8 CommandTest (com.zsmartsystems.zigbee.CommandTest)6 IeeeAddress (com.zsmartsystems.zigbee.IeeeAddress)6 HashSet (java.util.HashSet)5 ZigBeeNode (com.zsmartsystems.zigbee.ZigBeeNode)4 MatchDescriptorRequest (com.zsmartsystems.zigbee.zdo.command.MatchDescriptorRequest)4 ZigBeeCommand (com.zsmartsystems.zigbee.ZigBeeCommand)3 ZigBeeSerializer (com.zsmartsystems.zigbee.serialization.ZigBeeSerializer)3 ZclOnOffCluster (com.zsmartsystems.zigbee.zcl.clusters.ZclOnOffCluster)3 BindRequest (com.zsmartsystems.zigbee.zdo.command.BindRequest)3 IeeeAddressResponse (com.zsmartsystems.zigbee.zdo.command.IeeeAddressResponse)3 ConBeeEnqueueSendDataRequest (com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeEnqueueSendDataRequest)2 EzspFrameTest (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.EzspFrameTest)2 EmberApsFrame (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberApsFrame)2