Search in sources :

Example 46 with IeeeAddress

use of com.zsmartsystems.zigbee.IeeeAddress in project com.zsmartsystems.zigbee by zsmartsystems.

the class XBeeEventFactoryTest method testBootloaderEvent.

@Test
public void testBootloaderEvent() {
    int[] data = getPacketData("00 16 A0 00 13 A2 00 41 62 F6 1A 00 00 01 40 00 00 00 00 00 00 00 FF FF B8");
    XBeeEvent frame = XBeeEventFactory.getXBeeFrame(data);
    assertTrue(frame instanceof XBeeOtaFirmwareUpdateStatusEvent);
    System.out.println(frame);
    XBeeOtaFirmwareUpdateStatusEvent event = (XBeeOtaFirmwareUpdateStatusEvent) frame;
    assertEquals(Integer.valueOf(0), event.getBlockNumber());
    assertEquals(new IeeeAddress("0013A2004162F61A"), event.getIeeeAddress());
    assertEquals(Integer.valueOf(0), event.getNetworkAddress());
}
Also used : XBeeOtaFirmwareUpdateStatusEvent(com.zsmartsystems.zigbee.dongle.xbee.internal.protocol.XBeeOtaFirmwareUpdateStatusEvent) XBeeEvent(com.zsmartsystems.zigbee.dongle.xbee.internal.protocol.XBeeEvent) IeeeAddress(com.zsmartsystems.zigbee.IeeeAddress) Test(org.junit.Test)

Example 47 with IeeeAddress

use of com.zsmartsystems.zigbee.IeeeAddress in project com.zsmartsystems.zigbee by zsmartsystems.

the class TelegesisSetIeeeAddressCommandTest method test.

@Test
public void test() {
    TelegesisSetIeeeAddressCommand command = new TelegesisSetIeeeAddressCommand();
    command.setIeeeAddress(new IeeeAddress("1234567890ABCDEF"));
    System.out.println(command);
    assertEquals("ATS04=1234567890ABCDEF\r\n", intArrayToString(command.serialize()));
    command.deserialize(stringToIntArray("OK\r\n"));
    System.out.println(command);
    assertEquals(TelegesisStatusCode.SUCCESS, command.getStatus());
}
Also used : IeeeAddress(com.zsmartsystems.zigbee.IeeeAddress) Test(org.junit.Test)

Example 48 with IeeeAddress

use of com.zsmartsystems.zigbee.IeeeAddress in project com.zsmartsystems.zigbee by zsmartsystems.

the class XBeeReceivePacketExplicitEventTest method test.

@Test
public void test() {
    XBeeReceivePacketExplicitEvent event = new XBeeReceivePacketExplicitEvent();
    event.deserialize(getPacketData("00 18 91 00 13 A2 00 40 52 2B AA 7D 84 E0 E0 22 11 C1 05 02 52 78 44 61 74 61 52"));
    System.out.println(event);
    assertEquals(0x91, event.getFrameType());
    assertEquals(Integer.valueOf(0x7D84), event.getNetworkAddress());
    assertEquals(Integer.valueOf(224), event.getSourceEndpoint());
    assertEquals(Integer.valueOf(224), event.getDestinationEndpoint());
    assertEquals(Integer.valueOf(0x2211), event.getClusterId());
    assertEquals(Integer.valueOf(0xC105), event.getProfileId());
    assertEquals(ReceiveOptions.PACKET_BROADCAST, event.getReceiveOptions());
    assertEquals(new IeeeAddress("0013A20040522BAA"), event.getIeeeAddress());
    assertTrue(Arrays.equals(getPacketData("52 78 44 61 74 61"), event.getData()));
}
Also used : IeeeAddress(com.zsmartsystems.zigbee.IeeeAddress) Test(org.junit.Test)

Example 49 with IeeeAddress

use of com.zsmartsystems.zigbee.IeeeAddress in project com.zsmartsystems.zigbee by zsmartsystems.

the class ZigBeeNodeDaoTest method testSerialize.

@Test
public void testSerialize() {
    ZigBeeTransportTransmit mockedTransport = Mockito.mock(ZigBeeTransportTransmit.class);
    ZigBeeNetworkManager networkManager = new ZigBeeNetworkManager(mockedTransport);
    ZigBeeNode node = new ZigBeeNode(networkManager, new IeeeAddress("1234567890ABCDEF"));
    node.setNetworkAddress(12345);
    ZigBeeEndpoint endpoint;
    endpoint = new ZigBeeEndpoint(networkManager, node, 1);
    endpoint.setProfileId(123);
    node.addEndpoint(endpoint);
    endpoint = new ZigBeeEndpoint(networkManager, node, 2);
    endpoint.setProfileId(321);
    node.addEndpoint(endpoint);
/*
         * ZigBeeNodeDao nodeDao = ZigBeeNodeDao.createFromZigBeeNode(node);
         * assertEquals(new IeeeAddress("1234567890ABCDEF").toString(), nodeDao.getIeeeAddress());
         * assertEquals(Integer.valueOf(12345), nodeDao.getNetworkAddress());
         * 
         * node = ZigBeeNodeDao.createFromZigBeeDao(networkManager, nodeDao);
         * assertEquals(new IeeeAddress("1234567890ABCDEF"), node.getIeeeAddress());
         * assertEquals(Integer.valueOf(12345), node.getNetworkAddress());
         * assertEquals(2, node.getEndpoints().size());
         * 
         * endpoint = node.getEndpoint(1);
         * assertEquals(123, endpoint.getProfileId());
         */
}
Also used : ZigBeeTransportTransmit(com.zsmartsystems.zigbee.transport.ZigBeeTransportTransmit) ZigBeeNode(com.zsmartsystems.zigbee.ZigBeeNode) ZigBeeEndpoint(com.zsmartsystems.zigbee.ZigBeeEndpoint) ZigBeeNetworkManager(com.zsmartsystems.zigbee.ZigBeeNetworkManager) IeeeAddress(com.zsmartsystems.zigbee.IeeeAddress) Test(org.junit.Test)

Example 50 with IeeeAddress

use of com.zsmartsystems.zigbee.IeeeAddress in project com.zsmartsystems.zigbee by zsmartsystems.

the class ZigBeeNetworkDiscovererTest method testNormal.

@Ignore
@Test
public void testNormal() {
    // Add all the required responses to a list
    IeeeAddressResponse ieeeResponse = new IeeeAddressResponse();
    ieeeResponse.setStatus(ZdoStatus.SUCCESS);
    ieeeResponse.setSourceAddress(new ZigBeeEndpointAddress(0));
    ieeeResponse.setDestinationAddress(new ZigBeeEndpointAddress(0));
    ieeeResponse.setIeeeAddrRemoteDev(new IeeeAddress("1234567890ABCDEF"));
    responses.put(ZdoCommandType.IEEE_ADDRESS_REQUEST.getClusterId(), ieeeResponse);
    NodeDescriptorResponse nodeResponse = new NodeDescriptorResponse();
    nodeResponse.setStatus(ZdoStatus.SUCCESS);
    nodeResponse.setSourceAddress(new ZigBeeEndpointAddress(0));
    nodeResponse.setDestinationAddress(new ZigBeeEndpointAddress(0));
    nodeResponse.setNwkAddrOfInterest(0);
    NodeDescriptor nodeDescriptor = new NodeDescriptor();
    nodeResponse.setNodeDescriptor(nodeDescriptor);
    responses.put(ZdoCommandType.NODE_DESCRIPTOR_REQUEST.getClusterId(), nodeResponse);
    PowerDescriptorResponse powerResponse = new PowerDescriptorResponse();
    powerResponse.setStatus(ZdoStatus.SUCCESS);
    powerResponse.setSourceAddress(new ZigBeeEndpointAddress(0));
    powerResponse.setDestinationAddress(new ZigBeeEndpointAddress(0));
    powerResponse.setNwkAddrOfInterest(0);
    PowerDescriptor powerDescriptor = new PowerDescriptor();
    powerResponse.setPowerDescriptor(powerDescriptor);
    responses.put(ZdoCommandType.POWER_DESCRIPTOR_REQUEST.getClusterId(), powerResponse);
    ActiveEndpointsResponse endpointsResponse = new ActiveEndpointsResponse();
    endpointsResponse.setStatus(ZdoStatus.SUCCESS);
    endpointsResponse.setSourceAddress(new ZigBeeEndpointAddress(0));
    endpointsResponse.setDestinationAddress(new ZigBeeEndpointAddress(0));
    endpointsResponse.setNwkAddrOfInterest(0);
    List<Integer> activeEpList = new ArrayList<Integer>();
    activeEpList.add(1);
    endpointsResponse.setActiveEpList(activeEpList);
    responses.put(ZdoCommandType.ACTIVE_ENDPOINTS_REQUEST.getClusterId(), endpointsResponse);
    SimpleDescriptorResponse simpleResponse = new SimpleDescriptorResponse();
    simpleResponse.setStatus(ZdoStatus.SUCCESS);
    simpleResponse.setSourceAddress(new ZigBeeEndpointAddress(0));
    simpleResponse.setDestinationAddress(new ZigBeeEndpointAddress(0, 1));
    simpleResponse.setNwkAddrOfInterest(0);
    SimpleDescriptor simpleDescriptor = new SimpleDescriptor();
    simpleDescriptor.setDeviceId(0);
    simpleDescriptor.setDeviceVersion(0);
    simpleDescriptor.setEndpoint(1);
    simpleDescriptor.setProfileId(0x104);
    List<Integer> inputClusterList = new ArrayList<Integer>();
    List<Integer> outputClusterList = new ArrayList<Integer>();
    simpleDescriptor.setInputClusterList(inputClusterList);
    simpleDescriptor.setOutputClusterList(outputClusterList);
    simpleResponse.setSimpleDescriptor(simpleDescriptor);
    responses.put(ZdoCommandType.SIMPLE_DESCRIPTOR_REQUEST.getClusterId(), simpleResponse);
    ZigBeeNetworkDiscoverer discoverer = new ZigBeeNetworkDiscoverer(networkManager);
    discoverer.setRetryPeriod(1);
    discoverer.startup();
    // Check that the listener registers for startup notifications
    Mockito.verify(networkManager).addNetworkStateListener(discoverer);
    // Put the system online so it initialises
    discoverer.networkStateUpdated(ZigBeeTransportState.ONLINE);
    // Check it registers listeners
    Mockito.verify(networkManager).addCommandListener(discoverer);
    Mockito.verify(networkManager).addAnnounceListener(discoverer);
    // Then wait for the node to be added
    Mockito.verify(networkManager, Mockito.timeout(5000).times(1)).addNode(nodeCapture.capture());
    ZigBeeNode node = nodeCapture.getValue();
    assertNotNull(node);
    assertEquals(Integer.valueOf(0), node.getNetworkAddress());
    assertEquals(new IeeeAddress("1234567890ABCDEF"), node.getIeeeAddress());
    assertEquals(1, node.getEndpoints().size());
}
Also used : IeeeAddressResponse(com.zsmartsystems.zigbee.zdo.command.IeeeAddressResponse) PowerDescriptorResponse(com.zsmartsystems.zigbee.zdo.command.PowerDescriptorResponse) NodeDescriptor(com.zsmartsystems.zigbee.zdo.field.NodeDescriptor) ArrayList(java.util.ArrayList) ZigBeeNode(com.zsmartsystems.zigbee.ZigBeeNode) ActiveEndpointsResponse(com.zsmartsystems.zigbee.zdo.command.ActiveEndpointsResponse) IeeeAddress(com.zsmartsystems.zigbee.IeeeAddress) SimpleDescriptor(com.zsmartsystems.zigbee.zdo.field.SimpleDescriptor) SimpleDescriptorResponse(com.zsmartsystems.zigbee.zdo.command.SimpleDescriptorResponse) NodeDescriptorResponse(com.zsmartsystems.zigbee.zdo.command.NodeDescriptorResponse) ZigBeeEndpointAddress(com.zsmartsystems.zigbee.ZigBeeEndpointAddress) PowerDescriptor(com.zsmartsystems.zigbee.zdo.field.PowerDescriptor) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

IeeeAddress (com.zsmartsystems.zigbee.IeeeAddress)66 Test (org.junit.Test)53 ZigBeeEndpoint (com.zsmartsystems.zigbee.ZigBeeEndpoint)12 ZigBeeNode (com.zsmartsystems.zigbee.ZigBeeNode)12 CommandTest (com.zsmartsystems.zigbee.CommandTest)7 DefaultDeserializer (com.zsmartsystems.zigbee.serialization.DefaultDeserializer)7 ZclOnOffCluster (com.zsmartsystems.zigbee.zcl.clusters.ZclOnOffCluster)7 ZigBeeEndpointAddress (com.zsmartsystems.zigbee.ZigBeeEndpointAddress)6 ZclFieldDeserializer (com.zsmartsystems.zigbee.zcl.ZclFieldDeserializer)6 ArrayList (java.util.ArrayList)6 ZigBeeCommand (com.zsmartsystems.zigbee.ZigBeeCommand)5 EzspFrameTest (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.EzspFrameTest)4 CommandResult (com.zsmartsystems.zigbee.CommandResult)3 ExtendedPanId (com.zsmartsystems.zigbee.ExtendedPanId)3 NodeDescriptor (com.zsmartsystems.zigbee.zdo.field.NodeDescriptor)3 HashSet (java.util.HashSet)3 ZigBeeNetworkManager (com.zsmartsystems.zigbee.ZigBeeNetworkManager)2 EmberInitialSecurityState (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberInitialSecurityState)2 EmberKeyData (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberKeyData)2 XBeeFrameHandler (com.zsmartsystems.zigbee.dongle.xbee.internal.XBeeFrameHandler)2